├── Brewfile ├── .release-please-manifest.json ├── .gitignore ├── internal ├── apiform │ ├── form.go │ └── tag.go ├── version.go ├── param │ └── field.go ├── testutil │ └── testutil.go ├── apiquery │ ├── tag.go │ └── query.go └── apijson │ ├── tag.go │ ├── registry.go │ └── field.go ├── scripts ├── format ├── lint ├── bootstrap └── mock ├── lib └── .keep ├── examples └── .keep ├── go.mod ├── .stats.yml ├── .devcontainer └── devcontainer.json ├── .github ├── ISSUE_TEMPLATE │ └── config.yml ├── pull_request_template.md └── workflows │ ├── stale.yml │ └── detect-breaking-changes.yml ├── go.sum ├── acm └── acm.go ├── kv ├── kv.go └── namespacemetadata_test.go ├── realtime_kit └── realtimekit.go ├── rules ├── rule.go └── listbulkoperation_test.go ├── accounts ├── log.go └── accountorganization_test.go ├── pages ├── page.go └── projectdeploymenthistory.go ├── web3 ├── web3.go └── hostnameipfsuniversalpath.go ├── workers ├── beta.go ├── asset.go ├── scriptasset.go └── observability.go ├── botnet_feed ├── config.go └── botnetfeed.go ├── billing ├── billing.go └── profile_test.go ├── cloudforce_one ├── threateventcron.go ├── threateventinsight.go ├── scan.go ├── threateventdatasethealth.go ├── scanresult_test.go ├── threateventcountry_test.go └── threateventindicatortype_test.go ├── hostnames ├── setting.go └── hostname.go ├── radar ├── bgpleak.go ├── robotstxt.go ├── bgphijack.go ├── verifiedbot.go ├── attack.go ├── quality.go ├── emailsecuritytop.go ├── aiinferencetimeseriesgroup.go ├── entity_test.go └── ai.go ├── vectorize └── vectorize.go ├── registrar └── registrar.go ├── turnstile └── turnstile.go ├── user ├── billingprofile_test.go ├── billing.go └── tokenvalue_test.go ├── calls └── call.go ├── dns ├── analytics.go ├── setting.go ├── zonetransferoutgoingstatus_test.go └── zonetransferforceaxfr_test.go ├── images ├── image.go └── v1stat_test.go ├── ssl ├── universal.go ├── recommendation_test.go └── certificatepackquota_test.go ├── intel ├── indicatorfeeddownload.go ├── iplist_test.go ├── sinkhole_test.go ├── asn_test.go ├── asnsubnet_test.go ├── whois_test.go ├── domain_test.go ├── ip_test.go ├── domainbulk_test.go ├── attacksurfacereportissuetype_test.go ├── domainhistory_test.go └── attacksurfacereport.go ├── logs ├── controlcmb.go ├── control.go ├── log.go └── receivedfield_test.go ├── rum └── rum.go ├── dns_firewall └── analytics.go ├── connectivity ├── directory.go └── connectivity.go ├── magic_network_monitoring ├── vpcflow.go ├── configfull_test.go └── vpcflowtoken_test.go ├── request_tracers └── requesttracer.go ├── api_gateway ├── setting.go ├── expressiontemplate.go └── discovery_test.go ├── cloud_connector └── cloudconnector.go ├── workers_for_platforms ├── dispatch.go └── workersforplatform.go ├── durable_objects └── durableobject.go ├── security_center └── securitycenter.go ├── logpush ├── dataset.go └── logpush.go ├── zero_trust ├── accessaicontrol.go ├── accessinfrastructure.go ├── dlpemail.go ├── accesslog.go ├── deviceresilience.go ├── dlplimit_test.go ├── dextraceroutetestresult.go ├── riskscoringsummary_test.go ├── dexcommandquota_test.go ├── gatewayapptype_test.go ├── gatewaycategory_test.go ├── accessaicontrolmcp.go ├── identityproviderscim.go ├── devicerevoke_test.go ├── deviceunrevoke_test.go └── gatewaylistitem_test.go ├── argo └── argo.go ├── option └── middleware.go ├── url_scanner ├── urlscanner.go └── response_test.go ├── secrets_store ├── secretsstore.go └── quota_test.go ├── ips └── ip_test.go ├── spectrum ├── analyticsaggregate.go └── analytics.go ├── ai ├── task_test.go ├── author_test.go ├── modelschema_test.go └── ai_test.go ├── custom_hostnames └── certificatepack.go ├── r2 ├── bucketdomain.go ├── r2.go ├── superslurper.go └── bucketmetric_test.go ├── zaraz ├── export_test.go ├── default_test.go ├── workflow_test.go ├── zaraz_test.go ├── historyconfig_test.go └── publish_test.go ├── usage_test.go ├── paginationauto_test.go ├── zones ├── rateplan_test.go └── activationcheck_test.go ├── schema_validation └── schemavalidation.go ├── speed └── availability_test.go ├── addressing ├── service_test.go └── regionalhostnameregion_test.go ├── token_validation └── tokenvalidation.go ├── diagnostics └── diagnostic.go ├── certificate_authorities └── certificateauthority.go ├── alerting ├── availablealert_test.go ├── destinationeligible_test.go └── destination.go ├── content_scanning └── setting_test.go ├── dcv_delegation └── dcvdelegation_test.go ├── stream ├── embed_test.go ├── caption_test.go ├── video_test.go └── captionlanguagevtt_test.go ├── ai_gateway └── url_test.go ├── email_security ├── emailsecurity.go ├── investigateraw_test.go ├── investigatetrace_test.go └── investigaterelease_test.go ├── waiting_rooms └── status_test.go ├── iam └── iam.go └── load_balancers ├── preview_test.go └── poolreference_test.go /Brewfile: -------------------------------------------------------------------------------- 1 | brew "go" 2 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "6.4.0" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .prism.log 2 | codegen.log 3 | Brewfile.lock.json 4 | .idea/ 5 | -------------------------------------------------------------------------------- /internal/apiform/form.go: -------------------------------------------------------------------------------- 1 | package apiform 2 | 3 | type Marshaler interface { 4 | MarshalMultipart() ([]byte, string, error) 5 | } 6 | -------------------------------------------------------------------------------- /scripts/format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | echo "==> Running gofmt -s -w" 8 | gofmt -s -w . 9 | -------------------------------------------------------------------------------- /internal/version.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package internal 4 | 5 | const PackageVersion = "6.4.0" // x-release-please-version 6 | -------------------------------------------------------------------------------- /scripts/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | echo "==> Running Go build" 8 | go build ./... 9 | 10 | echo "==> Checking tests compile" 11 | go test -run=^$ ./... 12 | -------------------------------------------------------------------------------- /lib/.keep: -------------------------------------------------------------------------------- 1 | File generated from our OpenAPI spec by Stainless. 2 | 3 | This directory can be used to store custom files to expand the SDK. 4 | It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. -------------------------------------------------------------------------------- /examples/.keep: -------------------------------------------------------------------------------- 1 | File generated from our OpenAPI spec by Stainless. 2 | 3 | This directory can be used to store example files demonstrating usage of this SDK. 4 | It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cloudflare/cloudflare-go/v6 2 | 3 | go 1.22 4 | 5 | require ( 6 | github.com/tidwall/gjson v1.14.4 7 | github.com/tidwall/sjson v1.2.5 8 | ) 9 | 10 | require ( 11 | github.com/tidwall/match v1.1.1 // indirect 12 | github.com/tidwall/pretty v1.2.1 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /.stats.yml: -------------------------------------------------------------------------------- 1 | configured_endpoints: 1932 2 | openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6183ef87f1b8eea6ad4bae542bfde2ec23a5526ae2b7bacdf6c6a4c48d990995.yml 3 | openapi_spec_hash: 9c8ac3d56571ebf1e170d993b71ccb4d 4 | config_hash: aaacea52b646facd5527d7b1e928123d 5 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/debian 3 | { 4 | "name": "Development", 5 | "image": "mcr.microsoft.com/devcontainers/go:1.23-bookworm", 6 | "postCreateCommand": "go mod tidy" 7 | } 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Cloudflare support 4 | url: https://developers.cloudflare.com/support/contacting-cloudflare-support 5 | about: | 6 | Please only file issues here that you believe represent actual bugs for the Cloudflare Go library. 7 | If you're having general trouble with the Cloudflare API, please visit our help center to get support. 8 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | - [ ] I understand that this repository is auto-generated and my pull request may not be merged 7 | 8 | ## Changes being requested 9 | 10 | ## Additional context & links 11 | -------------------------------------------------------------------------------- /scripts/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then 8 | brew bundle check >/dev/null 2>&1 || { 9 | echo -n "==> Install Homebrew dependencies? (y/N): " 10 | read -r response 11 | case "$response" in 12 | [yY][eE][sS]|[yY]) 13 | brew bundle 14 | ;; 15 | *) 16 | ;; 17 | esac 18 | echo 19 | } 20 | fi 21 | 22 | echo "==> Installing Go dependencies…" 23 | 24 | go mod tidy -e 25 | -------------------------------------------------------------------------------- /internal/param/field.go: -------------------------------------------------------------------------------- 1 | package param 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type FieldLike interface{ field() } 8 | 9 | // Field is a wrapper used for all values sent to the API, 10 | // to distinguish zero values from null or omitted fields. 11 | // 12 | // It also allows sending arbitrary deserializable values. 13 | // 14 | // To instantiate a Field, use the helpers exported from 15 | // the package root: `F()`, `Null()`, `Raw()`, etc. 16 | type Field[T any] struct { 17 | FieldLike 18 | Value T 19 | Null bool 20 | Present bool 21 | Raw any 22 | } 23 | 24 | func (f Field[T]) String() string { 25 | if s, ok := any(f.Value).(fmt.Stringer); ok { 26 | return s.String() 27 | } 28 | return fmt.Sprintf("%v", f.Value) 29 | } 30 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: '38 16 * * *' 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | steps: 16 | - uses: actions/stale@v5 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | stale-issue-message: "This issue hasn't been updated in a while. If it's still reproducing, please comment to let us know. Thank you!" 20 | stale-pr-message: "This pull request hasn't been updated in a while, and is being marked as stale. Thanks!" 21 | stale-issue-label: 'no-issue-activity' 22 | stale-pr-label: 'no-pr-activity' 23 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= 2 | github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= 3 | github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= 4 | github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= 5 | github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= 6 | github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= 7 | github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= 8 | github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= 9 | github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= 10 | github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= 11 | -------------------------------------------------------------------------------- /internal/testutil/testutil.go: -------------------------------------------------------------------------------- 1 | package testutil 2 | 3 | import ( 4 | "net/http" 5 | "os" 6 | "strconv" 7 | "testing" 8 | ) 9 | 10 | func CheckTestServer(t *testing.T, url string) bool { 11 | if _, err := http.Get(url); err != nil { 12 | const SKIP_MOCK_TESTS = "SKIP_MOCK_TESTS" 13 | if str, ok := os.LookupEnv(SKIP_MOCK_TESTS); ok { 14 | skip, err := strconv.ParseBool(str) 15 | if err != nil { 16 | t.Fatalf("strconv.ParseBool(os.LookupEnv(%s)) failed: %s", SKIP_MOCK_TESTS, err) 17 | } 18 | if skip { 19 | t.Skip("The test will not run without a mock Prism server running against your OpenAPI spec") 20 | return false 21 | } 22 | t.Errorf("The test will not run without a mock Prism server running against your OpenAPI spec. You can set the environment variable %s to true to skip running any tests that require the mock server", SKIP_MOCK_TESTS) 23 | return false 24 | } 25 | } 26 | return true 27 | } 28 | -------------------------------------------------------------------------------- /internal/apiquery/tag.go: -------------------------------------------------------------------------------- 1 | package apiquery 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | ) 7 | 8 | const queryStructTag = "query" 9 | const formatStructTag = "format" 10 | 11 | type parsedStructTag struct { 12 | name string 13 | omitempty bool 14 | inline bool 15 | } 16 | 17 | func parseQueryStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) { 18 | raw, ok := field.Tag.Lookup(queryStructTag) 19 | if !ok { 20 | return 21 | } 22 | parts := strings.Split(raw, ",") 23 | if len(parts) == 0 { 24 | return tag, false 25 | } 26 | tag.name = parts[0] 27 | for _, part := range parts[1:] { 28 | switch part { 29 | case "omitempty": 30 | tag.omitempty = true 31 | case "inline": 32 | tag.inline = true 33 | } 34 | } 35 | return 36 | } 37 | 38 | func parseFormatStructTag(field reflect.StructField) (format string, ok bool) { 39 | format, ok = field.Tag.Lookup(formatStructTag) 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /acm/acm.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package acm 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ACMService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewACMService] method instead. 15 | type ACMService struct { 16 | Options []option.RequestOption 17 | TotalTLS *TotalTLSService 18 | } 19 | 20 | // NewACMService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewACMService(opts ...option.RequestOption) (r *ACMService) { 24 | r = &ACMService{} 25 | r.Options = opts 26 | r.TotalTLS = NewTotalTLSService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /kv/kv.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package kv 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // KVService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewKVService] method instead. 15 | type KVService struct { 16 | Options []option.RequestOption 17 | Namespaces *NamespaceService 18 | } 19 | 20 | // NewKVService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewKVService(opts ...option.RequestOption) (r *KVService) { 24 | r = &KVService{} 25 | r.Options = opts 26 | r.Namespaces = NewNamespaceService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /realtime_kit/realtimekit.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package realtime_kit 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RealtimeKitService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRealtimeKitService] method instead. 15 | type RealtimeKitService struct { 16 | Options []option.RequestOption 17 | } 18 | 19 | // NewRealtimeKitService generates a new service that applies the given options to 20 | // each request. These options are applied after the parent client's options (if 21 | // there is one), and before any request-specific options. 22 | func NewRealtimeKitService(opts ...option.RequestOption) (r *RealtimeKitService) { 23 | r = &RealtimeKitService{} 24 | r.Options = opts 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /rules/rule.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package rules 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RuleService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRuleService] method instead. 15 | type RuleService struct { 16 | Options []option.RequestOption 17 | Lists *ListService 18 | } 19 | 20 | // NewRuleService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewRuleService(opts ...option.RequestOption) (r *RuleService) { 24 | r = &RuleService{} 25 | r.Options = opts 26 | r.Lists = NewListService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /scripts/mock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | if [[ -n "$1" && "$1" != '--'* ]]; then 8 | URL="$1" 9 | shift 10 | else 11 | URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" 12 | fi 13 | 14 | # Check if the URL is empty 15 | if [ -z "$URL" ]; then 16 | echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" 17 | exit 1 18 | fi 19 | 20 | echo "==> Starting mock server with URL ${URL}" 21 | 22 | # Run prism mock on the given spec 23 | if [ "$1" == "--daemon" ]; then 24 | npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & 25 | 26 | # Wait for server to come online 27 | echo -n "Waiting for server" 28 | while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do 29 | echo -n "." 30 | sleep 0.1 31 | done 32 | 33 | if grep -q "✖ fatal" ".prism.log"; then 34 | cat .prism.log 35 | exit 1 36 | fi 37 | 38 | echo 39 | else 40 | npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" 41 | fi 42 | -------------------------------------------------------------------------------- /accounts/log.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package accounts 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // LogService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewLogService] method instead. 15 | type LogService struct { 16 | Options []option.RequestOption 17 | Audit *LogAuditService 18 | } 19 | 20 | // NewLogService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewLogService(opts ...option.RequestOption) (r *LogService) { 24 | r = &LogService{} 25 | r.Options = opts 26 | r.Audit = NewLogAuditService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /pages/page.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package pages 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // PageService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewPageService] method instead. 15 | type PageService struct { 16 | Options []option.RequestOption 17 | Projects *ProjectService 18 | } 19 | 20 | // NewPageService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewPageService(opts ...option.RequestOption) (r *PageService) { 24 | r = &PageService{} 25 | r.Options = opts 26 | r.Projects = NewProjectService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /internal/apijson/tag.go: -------------------------------------------------------------------------------- 1 | package apijson 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | ) 7 | 8 | const jsonStructTag = "json" 9 | const formatStructTag = "format" 10 | 11 | type parsedStructTag struct { 12 | name string 13 | required bool 14 | extras bool 15 | metadata bool 16 | inline bool 17 | } 18 | 19 | func parseJSONStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) { 20 | raw, ok := field.Tag.Lookup(jsonStructTag) 21 | if !ok { 22 | return 23 | } 24 | parts := strings.Split(raw, ",") 25 | if len(parts) == 0 { 26 | return tag, false 27 | } 28 | tag.name = parts[0] 29 | for _, part := range parts[1:] { 30 | switch part { 31 | case "required": 32 | tag.required = true 33 | case "extras": 34 | tag.extras = true 35 | case "metadata": 36 | tag.metadata = true 37 | case "inline": 38 | tag.inline = true 39 | } 40 | } 41 | return 42 | } 43 | 44 | func parseFormatStructTag(field reflect.StructField) (format string, ok bool) { 45 | format, ok = field.Tag.Lookup(formatStructTag) 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /web3/web3.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package web3 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // Web3Service contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewWeb3Service] method instead. 15 | type Web3Service struct { 16 | Options []option.RequestOption 17 | Hostnames *HostnameService 18 | } 19 | 20 | // NewWeb3Service generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewWeb3Service(opts ...option.RequestOption) (r *Web3Service) { 24 | r = &Web3Service{} 25 | r.Options = opts 26 | r.Hostnames = NewHostnameService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /workers/beta.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BetaService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBetaService] method instead. 15 | type BetaService struct { 16 | Options []option.RequestOption 17 | Workers *BetaWorkerService 18 | } 19 | 20 | // NewBetaService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewBetaService(opts ...option.RequestOption) (r *BetaService) { 24 | r = &BetaService{} 25 | r.Options = opts 26 | r.Workers = NewBetaWorkerService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /workers/asset.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AssetService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAssetService] method instead. 15 | type AssetService struct { 16 | Options []option.RequestOption 17 | Upload *AssetUploadService 18 | } 19 | 20 | // NewAssetService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewAssetService(opts ...option.RequestOption) (r *AssetService) { 24 | r = &AssetService{} 25 | r.Options = opts 26 | r.Upload = NewAssetUploadService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /botnet_feed/config.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package botnet_feed 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ConfigService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewConfigService] method instead. 15 | type ConfigService struct { 16 | Options []option.RequestOption 17 | ASN *ConfigASNService 18 | } 19 | 20 | // NewConfigService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewConfigService(opts ...option.RequestOption) (r *ConfigService) { 24 | r = &ConfigService{} 25 | r.Options = opts 26 | r.ASN = NewConfigASNService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /billing/billing.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package billing 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BillingService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBillingService] method instead. 15 | type BillingService struct { 16 | Options []option.RequestOption 17 | Profiles *ProfileService 18 | } 19 | 20 | // NewBillingService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewBillingService(opts ...option.RequestOption) (r *BillingService) { 24 | r = &BillingService{} 25 | r.Options = opts 26 | r.Profiles = NewProfileService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /cloudforce_one/threateventcron.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ThreatEventCronService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewThreatEventCronService] method instead. 15 | type ThreatEventCronService struct { 16 | Options []option.RequestOption 17 | } 18 | 19 | // NewThreatEventCronService generates a new service that applies the given options 20 | // to each request. These options are applied after the parent client's options (if 21 | // there is one), and before any request-specific options. 22 | func NewThreatEventCronService(opts ...option.RequestOption) (r *ThreatEventCronService) { 23 | r = &ThreatEventCronService{} 24 | r.Options = opts 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /hostnames/setting.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package hostnames 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SettingService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSettingService] method instead. 15 | type SettingService struct { 16 | Options []option.RequestOption 17 | TLS *SettingTLSService 18 | } 19 | 20 | // NewSettingService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewSettingService(opts ...option.RequestOption) (r *SettingService) { 24 | r = &SettingService{} 25 | r.Options = opts 26 | r.TLS = NewSettingTLSService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /radar/bgpleak.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BGPLeakService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBGPLeakService] method instead. 15 | type BGPLeakService struct { 16 | Options []option.RequestOption 17 | Events *BGPLeakEventService 18 | } 19 | 20 | // NewBGPLeakService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewBGPLeakService(opts ...option.RequestOption) (r *BGPLeakService) { 24 | r = &BGPLeakService{} 25 | r.Options = opts 26 | r.Events = NewBGPLeakEventService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /hostnames/hostname.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package hostnames 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // HostnameService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewHostnameService] method instead. 15 | type HostnameService struct { 16 | Options []option.RequestOption 17 | Settings *SettingService 18 | } 19 | 20 | // NewHostnameService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { 24 | r = &HostnameService{} 25 | r.Options = opts 26 | r.Settings = NewSettingService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /internal/apiform/tag.go: -------------------------------------------------------------------------------- 1 | package apiform 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | ) 7 | 8 | const jsonStructTag = "json" 9 | const formStructTag = "form" 10 | const formatStructTag = "format" 11 | 12 | type parsedStructTag struct { 13 | name string 14 | required bool 15 | extras bool 16 | metadata bool 17 | } 18 | 19 | func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) { 20 | raw, ok := field.Tag.Lookup(formStructTag) 21 | if !ok { 22 | raw, ok = field.Tag.Lookup(jsonStructTag) 23 | } 24 | if !ok { 25 | return 26 | } 27 | parts := strings.Split(raw, ",") 28 | if len(parts) == 0 { 29 | return tag, false 30 | } 31 | tag.name = parts[0] 32 | for _, part := range parts[1:] { 33 | switch part { 34 | case "required": 35 | tag.required = true 36 | case "extras": 37 | tag.extras = true 38 | case "metadata": 39 | tag.metadata = true 40 | } 41 | } 42 | return 43 | } 44 | 45 | func parseFormatStructTag(field reflect.StructField) (format string, ok bool) { 46 | format, ok = field.Tag.Lookup(formatStructTag) 47 | return 48 | } 49 | -------------------------------------------------------------------------------- /vectorize/vectorize.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package vectorize 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // VectorizeService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewVectorizeService] method instead. 15 | type VectorizeService struct { 16 | Options []option.RequestOption 17 | Indexes *IndexService 18 | } 19 | 20 | // NewVectorizeService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewVectorizeService(opts ...option.RequestOption) (r *VectorizeService) { 24 | r = &VectorizeService{} 25 | r.Options = opts 26 | r.Indexes = NewIndexService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /radar/robotstxt.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RobotsTXTService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRobotsTXTService] method instead. 15 | type RobotsTXTService struct { 16 | Options []option.RequestOption 17 | Top *RobotsTXTTopService 18 | } 19 | 20 | // NewRobotsTXTService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewRobotsTXTService(opts ...option.RequestOption) (r *RobotsTXTService) { 24 | r = &RobotsTXTService{} 25 | r.Options = opts 26 | r.Top = NewRobotsTXTTopService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /registrar/registrar.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package registrar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RegistrarService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRegistrarService] method instead. 15 | type RegistrarService struct { 16 | Options []option.RequestOption 17 | Domains *DomainService 18 | } 19 | 20 | // NewRegistrarService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewRegistrarService(opts ...option.RequestOption) (r *RegistrarService) { 24 | r = &RegistrarService{} 25 | r.Options = opts 26 | r.Domains = NewDomainService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /turnstile/turnstile.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package turnstile 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // TurnstileService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewTurnstileService] method instead. 15 | type TurnstileService struct { 16 | Options []option.RequestOption 17 | Widgets *WidgetService 18 | } 19 | 20 | // NewTurnstileService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewTurnstileService(opts ...option.RequestOption) (r *TurnstileService) { 24 | r = &TurnstileService{} 25 | r.Options = opts 26 | r.Widgets = NewWidgetService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /user/billingprofile_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package user_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | ) 15 | 16 | func TestBillingProfileGet(t *testing.T) { 17 | baseURL := "http://localhost:4010" 18 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 19 | baseURL = envURL 20 | } 21 | if !testutil.CheckTestServer(t, baseURL) { 22 | return 23 | } 24 | client := cloudflare.NewClient( 25 | option.WithBaseURL(baseURL), 26 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 27 | option.WithAPIEmail("user@example.com"), 28 | ) 29 | _, err := client.User.Billing.Profile.Get(context.TODO()) 30 | if err != nil { 31 | var apierr *cloudflare.Error 32 | if errors.As(err, &apierr) { 33 | t.Log(string(apierr.DumpRequest(true))) 34 | } 35 | t.Fatalf("err should be nil: %s", err.Error()) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /calls/call.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package calls 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // CallService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewCallService] method instead. 15 | type CallService struct { 16 | Options []option.RequestOption 17 | SFU *SFUService 18 | TURN *TURNService 19 | } 20 | 21 | // NewCallService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewCallService(opts ...option.RequestOption) (r *CallService) { 25 | r = &CallService{} 26 | r.Options = opts 27 | r.SFU = NewSFUService(opts...) 28 | r.TURN = NewTURNService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /cloudforce_one/threateventinsight.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ThreatEventInsightService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewThreatEventInsightService] method instead. 15 | type ThreatEventInsightService struct { 16 | Options []option.RequestOption 17 | } 18 | 19 | // NewThreatEventInsightService generates a new service that applies the given 20 | // options to each request. These options are applied after the parent client's 21 | // options (if there is one), and before any request-specific options. 22 | func NewThreatEventInsightService(opts ...option.RequestOption) (r *ThreatEventInsightService) { 23 | r = &ThreatEventInsightService{} 24 | r.Options = opts 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /dns/analytics.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dns 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AnalyticsService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAnalyticsService] method instead. 15 | type AnalyticsService struct { 16 | Options []option.RequestOption 17 | Reports *AnalyticsReportService 18 | } 19 | 20 | // NewAnalyticsService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { 24 | r = &AnalyticsService{} 25 | r.Options = opts 26 | r.Reports = NewAnalyticsReportService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /images/image.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package images 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ImageService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewImageService] method instead. 15 | type ImageService struct { 16 | Options []option.RequestOption 17 | V1 *V1Service 18 | V2 *V2Service 19 | } 20 | 21 | // NewImageService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewImageService(opts ...option.RequestOption) (r *ImageService) { 25 | r = &ImageService{} 26 | r.Options = opts 27 | r.V1 = NewV1Service(opts...) 28 | r.V2 = NewV2Service(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /radar/bgphijack.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BGPHijackService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBGPHijackService] method instead. 15 | type BGPHijackService struct { 16 | Options []option.RequestOption 17 | Events *BGPHijackEventService 18 | } 19 | 20 | // NewBGPHijackService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewBGPHijackService(opts ...option.RequestOption) (r *BGPHijackService) { 24 | r = &BGPHijackService{} 25 | r.Options = opts 26 | r.Events = NewBGPHijackEventService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /ssl/universal.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ssl 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // UniversalService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewUniversalService] method instead. 15 | type UniversalService struct { 16 | Options []option.RequestOption 17 | Settings *UniversalSettingService 18 | } 19 | 20 | // NewUniversalService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewUniversalService(opts ...option.RequestOption) (r *UniversalService) { 24 | r = &UniversalService{} 25 | r.Options = opts 26 | r.Settings = NewUniversalSettingService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /intel/indicatorfeeddownload.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // IndicatorFeedDownloadService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewIndicatorFeedDownloadService] method instead. 15 | type IndicatorFeedDownloadService struct { 16 | Options []option.RequestOption 17 | } 18 | 19 | // NewIndicatorFeedDownloadService generates a new service that applies the given 20 | // options to each request. These options are applied after the parent client's 21 | // options (if there is one), and before any request-specific options. 22 | func NewIndicatorFeedDownloadService(opts ...option.RequestOption) (r *IndicatorFeedDownloadService) { 23 | r = &IndicatorFeedDownloadService{} 24 | r.Options = opts 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /logs/controlcmb.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logs 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ControlCmbService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewControlCmbService] method instead. 15 | type ControlCmbService struct { 16 | Options []option.RequestOption 17 | Config *ControlCmbConfigService 18 | } 19 | 20 | // NewControlCmbService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewControlCmbService(opts ...option.RequestOption) (r *ControlCmbService) { 24 | r = &ControlCmbService{} 25 | r.Options = opts 26 | r.Config = NewControlCmbConfigService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /rum/rum.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package rum 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RUMService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRUMService] method instead. 15 | type RUMService struct { 16 | Options []option.RequestOption 17 | SiteInfo *SiteInfoService 18 | Rules *RuleService 19 | } 20 | 21 | // NewRUMService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewRUMService(opts ...option.RequestOption) (r *RUMService) { 25 | r = &RUMService{} 26 | r.Options = opts 27 | r.SiteInfo = NewSiteInfoService(opts...) 28 | r.Rules = NewRuleService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /dns_firewall/analytics.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dns_firewall 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AnalyticsService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAnalyticsService] method instead. 15 | type AnalyticsService struct { 16 | Options []option.RequestOption 17 | Reports *AnalyticsReportService 18 | } 19 | 20 | // NewAnalyticsService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { 24 | r = &AnalyticsService{} 25 | r.Options = opts 26 | r.Reports = NewAnalyticsReportService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /radar/verifiedbot.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // VerifiedBotService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewVerifiedBotService] method instead. 15 | type VerifiedBotService struct { 16 | Options []option.RequestOption 17 | Top *VerifiedBotTopService 18 | } 19 | 20 | // NewVerifiedBotService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewVerifiedBotService(opts ...option.RequestOption) (r *VerifiedBotService) { 24 | r = &VerifiedBotService{} 25 | r.Options = opts 26 | r.Top = NewVerifiedBotTopService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /connectivity/directory.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package connectivity 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DirectoryService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDirectoryService] method instead. 15 | type DirectoryService struct { 16 | Options []option.RequestOption 17 | Services *DirectoryServiceService 18 | } 19 | 20 | // NewDirectoryService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewDirectoryService(opts ...option.RequestOption) (r *DirectoryService) { 24 | r = &DirectoryService{} 25 | r.Options = opts 26 | r.Services = NewDirectoryServiceService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /magic_network_monitoring/vpcflow.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package magic_network_monitoring 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // VPCFlowService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewVPCFlowService] method instead. 15 | type VPCFlowService struct { 16 | Options []option.RequestOption 17 | Tokens *VPCFlowTokenService 18 | } 19 | 20 | // NewVPCFlowService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewVPCFlowService(opts ...option.RequestOption) (r *VPCFlowService) { 24 | r = &VPCFlowService{} 25 | r.Options = opts 26 | r.Tokens = NewVPCFlowTokenService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /workers/scriptasset.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ScriptAssetService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewScriptAssetService] method instead. 15 | type ScriptAssetService struct { 16 | Options []option.RequestOption 17 | Upload *ScriptAssetUploadService 18 | } 19 | 20 | // NewScriptAssetService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewScriptAssetService(opts ...option.RequestOption) (r *ScriptAssetService) { 24 | r = &ScriptAssetService{} 25 | r.Options = opts 26 | r.Upload = NewScriptAssetUploadService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /connectivity/connectivity.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package connectivity 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ConnectivityService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewConnectivityService] method instead. 15 | type ConnectivityService struct { 16 | Options []option.RequestOption 17 | Directory *DirectoryService 18 | } 19 | 20 | // NewConnectivityService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewConnectivityService(opts ...option.RequestOption) (r *ConnectivityService) { 24 | r = &ConnectivityService{} 25 | r.Options = opts 26 | r.Directory = NewDirectoryService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /request_tracers/requesttracer.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package request_tracers 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // RequestTracerService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewRequestTracerService] method instead. 15 | type RequestTracerService struct { 16 | Options []option.RequestOption 17 | Traces *TraceService 18 | } 19 | 20 | // NewRequestTracerService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewRequestTracerService(opts ...option.RequestOption) (r *RequestTracerService) { 24 | r = &RequestTracerService{} 25 | r.Options = opts 26 | r.Traces = NewTraceService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /api_gateway/setting.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package api_gateway 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SettingService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSettingService] method instead. 15 | type SettingService struct { 16 | Options []option.RequestOption 17 | SchemaValidation *SettingSchemaValidationService 18 | } 19 | 20 | // NewSettingService generates a new service that applies the given options to each 21 | // request. These options are applied after the parent client's options (if there 22 | // is one), and before any request-specific options. 23 | func NewSettingService(opts ...option.RequestOption) (r *SettingService) { 24 | r = &SettingService{} 25 | r.Options = opts 26 | r.SchemaValidation = NewSettingSchemaValidationService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /cloud_connector/cloudconnector.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloud_connector 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // CloudConnectorService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewCloudConnectorService] method instead. 15 | type CloudConnectorService struct { 16 | Options []option.RequestOption 17 | Rules *RuleService 18 | } 19 | 20 | // NewCloudConnectorService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewCloudConnectorService(opts ...option.RequestOption) (r *CloudConnectorService) { 24 | r = &CloudConnectorService{} 25 | r.Options = opts 26 | r.Rules = NewRuleService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /internal/apiquery/query.go: -------------------------------------------------------------------------------- 1 | package apiquery 2 | 3 | import ( 4 | "net/url" 5 | "reflect" 6 | "time" 7 | ) 8 | 9 | func MarshalWithSettings(value interface{}, settings QuerySettings) url.Values { 10 | e := encoder{time.RFC3339, true, settings} 11 | kv := url.Values{} 12 | val := reflect.ValueOf(value) 13 | if !val.IsValid() { 14 | return nil 15 | } 16 | typ := val.Type() 17 | for _, pair := range e.typeEncoder(typ)("", val) { 18 | kv.Add(pair.key, pair.value) 19 | } 20 | return kv 21 | } 22 | 23 | func Marshal(value interface{}) url.Values { 24 | return MarshalWithSettings(value, QuerySettings{}) 25 | } 26 | 27 | type Queryer interface { 28 | URLQuery() url.Values 29 | } 30 | 31 | type QuerySettings struct { 32 | NestedFormat NestedQueryFormat 33 | ArrayFormat ArrayQueryFormat 34 | } 35 | 36 | type NestedQueryFormat int 37 | 38 | const ( 39 | NestedQueryFormatBrackets NestedQueryFormat = iota 40 | NestedQueryFormatDots 41 | ) 42 | 43 | type ArrayQueryFormat int 44 | 45 | const ( 46 | ArrayQueryFormatComma ArrayQueryFormat = iota 47 | ArrayQueryFormatRepeat 48 | ArrayQueryFormatIndices 49 | ArrayQueryFormatBrackets 50 | ) 51 | -------------------------------------------------------------------------------- /workers_for_platforms/dispatch.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers_for_platforms 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DispatchService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDispatchService] method instead. 15 | type DispatchService struct { 16 | Options []option.RequestOption 17 | Namespaces *DispatchNamespaceService 18 | } 19 | 20 | // NewDispatchService generates a new service that applies the given options to 21 | // each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewDispatchService(opts ...option.RequestOption) (r *DispatchService) { 24 | r = &DispatchService{} 25 | r.Options = opts 26 | r.Namespaces = NewDispatchNamespaceService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /internal/apijson/registry.go: -------------------------------------------------------------------------------- 1 | package apijson 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/tidwall/gjson" 7 | ) 8 | 9 | type UnionVariant struct { 10 | TypeFilter gjson.Type 11 | DiscriminatorValue interface{} 12 | Type reflect.Type 13 | } 14 | 15 | var unionRegistry = map[reflect.Type]unionEntry{} 16 | var unionVariants = map[reflect.Type]interface{}{} 17 | 18 | type unionEntry struct { 19 | discriminatorKey string 20 | variants []UnionVariant 21 | } 22 | 23 | func RegisterUnion(typ reflect.Type, discriminator string, variants ...UnionVariant) { 24 | unionRegistry[typ] = unionEntry{ 25 | discriminatorKey: discriminator, 26 | variants: variants, 27 | } 28 | for _, variant := range variants { 29 | unionVariants[variant.Type] = typ 30 | } 31 | } 32 | 33 | // Useful to wrap a union type to force it to use [apijson.UnmarshalJSON] since you cannot define an 34 | // UnmarshalJSON function on the interface itself. 35 | type UnionUnmarshaler[T any] struct { 36 | Value T 37 | } 38 | 39 | func (c *UnionUnmarshaler[T]) UnmarshalJSON(buf []byte) error { 40 | return UnmarshalRoot(buf, &c.Value) 41 | } 42 | -------------------------------------------------------------------------------- /cloudforce_one/scan.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ScanService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewScanService] method instead. 15 | type ScanService struct { 16 | Options []option.RequestOption 17 | Results *ScanResultService 18 | Config *ScanConfigService 19 | } 20 | 21 | // NewScanService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewScanService(opts ...option.RequestOption) (r *ScanService) { 25 | r = &ScanService{} 26 | r.Options = opts 27 | r.Results = NewScanResultService(opts...) 28 | r.Config = NewScanConfigService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /cloudforce_one/threateventdatasethealth.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ThreatEventDatasetHealthService contains methods and other services that help 10 | // with interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewThreatEventDatasetHealthService] method instead. 15 | type ThreatEventDatasetHealthService struct { 16 | Options []option.RequestOption 17 | } 18 | 19 | // NewThreatEventDatasetHealthService generates a new service that applies the 20 | // given options to each request. These options are applied after the parent 21 | // client's options (if there is one), and before any request-specific options. 22 | func NewThreatEventDatasetHealthService(opts ...option.RequestOption) (r *ThreatEventDatasetHealthService) { 23 | r = &ThreatEventDatasetHealthService{} 24 | r.Options = opts 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /durable_objects/durableobject.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package durable_objects 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DurableObjectService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDurableObjectService] method instead. 15 | type DurableObjectService struct { 16 | Options []option.RequestOption 17 | Namespaces *NamespaceService 18 | } 19 | 20 | // NewDurableObjectService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewDurableObjectService(opts ...option.RequestOption) (r *DurableObjectService) { 24 | r = &DurableObjectService{} 25 | r.Options = opts 26 | r.Namespaces = NewNamespaceService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /security_center/securitycenter.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package security_center 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SecurityCenterService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSecurityCenterService] method instead. 15 | type SecurityCenterService struct { 16 | Options []option.RequestOption 17 | Insights *InsightService 18 | } 19 | 20 | // NewSecurityCenterService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewSecurityCenterService(opts ...option.RequestOption) (r *SecurityCenterService) { 24 | r = &SecurityCenterService{} 25 | r.Options = opts 26 | r.Insights = NewInsightService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /radar/attack.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AttackService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAttackService] method instead. 15 | type AttackService struct { 16 | Options []option.RequestOption 17 | Layer3 *AttackLayer3Service 18 | Layer7 *AttackLayer7Service 19 | } 20 | 21 | // NewAttackService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewAttackService(opts ...option.RequestOption) (r *AttackService) { 25 | r = &AttackService{} 26 | r.Options = opts 27 | r.Layer3 = NewAttackLayer3Service(opts...) 28 | r.Layer7 = NewAttackLayer7Service(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /radar/quality.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // QualityService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewQualityService] method instead. 15 | type QualityService struct { 16 | Options []option.RequestOption 17 | IQI *QualityIQIService 18 | Speed *QualitySpeedService 19 | } 20 | 21 | // NewQualityService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewQualityService(opts ...option.RequestOption) (r *QualityService) { 25 | r = &QualityService{} 26 | r.Options = opts 27 | r.IQI = NewQualityIQIService(opts...) 28 | r.Speed = NewQualitySpeedService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /dns/setting.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dns 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SettingService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSettingService] method instead. 15 | type SettingService struct { 16 | Options []option.RequestOption 17 | Zone *SettingZoneService 18 | Account *SettingAccountService 19 | } 20 | 21 | // NewSettingService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewSettingService(opts ...option.RequestOption) (r *SettingService) { 25 | r = &SettingService{} 26 | r.Options = opts 27 | r.Zone = NewSettingZoneService(opts...) 28 | r.Account = NewSettingAccountService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /logpush/dataset.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logpush 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DatasetService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDatasetService] method instead. 15 | type DatasetService struct { 16 | Options []option.RequestOption 17 | Fields *DatasetFieldService 18 | Jobs *DatasetJobService 19 | } 20 | 21 | // NewDatasetService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewDatasetService(opts ...option.RequestOption) (r *DatasetService) { 25 | r = &DatasetService{} 26 | r.Options = opts 27 | r.Fields = NewDatasetFieldService(opts...) 28 | r.Jobs = NewDatasetJobService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /workers/observability.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ObservabilityService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewObservabilityService] method instead. 15 | type ObservabilityService struct { 16 | Options []option.RequestOption 17 | Telemetry *ObservabilityTelemetryService 18 | } 19 | 20 | // NewObservabilityService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewObservabilityService(opts ...option.RequestOption) (r *ObservabilityService) { 24 | r = &ObservabilityService{} 25 | r.Options = opts 26 | r.Telemetry = NewObservabilityTelemetryService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /radar/emailsecuritytop.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // EmailSecurityTopService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewEmailSecurityTopService] method instead. 15 | type EmailSecurityTopService struct { 16 | Options []option.RequestOption 17 | Tlds *EmailSecurityTopTldService 18 | } 19 | 20 | // NewEmailSecurityTopService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewEmailSecurityTopService(opts ...option.RequestOption) (r *EmailSecurityTopService) { 24 | r = &EmailSecurityTopService{} 25 | r.Options = opts 26 | r.Tlds = NewEmailSecurityTopTldService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /zero_trust/accessaicontrol.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AccessAIControlService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAccessAIControlService] method instead. 15 | type AccessAIControlService struct { 16 | Options []option.RequestOption 17 | Mcp *AccessAIControlMcpService 18 | } 19 | 20 | // NewAccessAIControlService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewAccessAIControlService(opts ...option.RequestOption) (r *AccessAIControlService) { 24 | r = &AccessAIControlService{} 25 | r.Options = opts 26 | r.Mcp = NewAccessAIControlMcpService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /argo/argo.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package argo 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ArgoService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewArgoService] method instead. 15 | type ArgoService struct { 16 | Options []option.RequestOption 17 | SmartRouting *SmartRoutingService 18 | TieredCaching *TieredCachingService 19 | } 20 | 21 | // NewArgoService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewArgoService(opts ...option.RequestOption) (r *ArgoService) { 25 | r = &ArgoService{} 26 | r.Options = opts 27 | r.SmartRouting = NewSmartRoutingService(opts...) 28 | r.TieredCaching = NewTieredCachingService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /botnet_feed/botnetfeed.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package botnet_feed 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BotnetFeedService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBotnetFeedService] method instead. 15 | type BotnetFeedService struct { 16 | Options []option.RequestOption 17 | ASN *ASNService 18 | Configs *ConfigService 19 | } 20 | 21 | // NewBotnetFeedService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewBotnetFeedService(opts ...option.RequestOption) (r *BotnetFeedService) { 25 | r = &BotnetFeedService{} 26 | r.Options = opts 27 | r.ASN = NewASNService(opts...) 28 | r.Configs = NewConfigService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /logs/control.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logs 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ControlService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewControlService] method instead. 15 | type ControlService struct { 16 | Options []option.RequestOption 17 | Retention *ControlRetentionService 18 | Cmb *ControlCmbService 19 | } 20 | 21 | // NewControlService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewControlService(opts ...option.RequestOption) (r *ControlService) { 25 | r = &ControlService{} 26 | r.Options = opts 27 | r.Retention = NewControlRetentionService(opts...) 28 | r.Cmb = NewControlCmbService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /user/billing.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package user 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BillingService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBillingService] method instead. 15 | type BillingService struct { 16 | Options []option.RequestOption 17 | History *BillingHistoryService 18 | Profile *BillingProfileService 19 | } 20 | 21 | // NewBillingService generates a new service that applies the given options to each 22 | // request. These options are applied after the parent client's options (if there 23 | // is one), and before any request-specific options. 24 | func NewBillingService(opts ...option.RequestOption) (r *BillingService) { 25 | r = &BillingService{} 26 | r.Options = opts 27 | r.History = NewBillingHistoryService(opts...) 28 | r.Profile = NewBillingProfileService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /option/middleware.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package option 4 | 5 | import ( 6 | "log" 7 | "net/http" 8 | "net/http/httputil" 9 | ) 10 | 11 | // WithDebugLog logs the HTTP request and response content. 12 | // If the logger parameter is nil, it uses the default logger. 13 | // 14 | // WithDebugLog is for debugging and development purposes only. 15 | // It should not be used in production code. The behavior and interface 16 | // of WithDebugLog is not guaranteed to be stable. 17 | func WithDebugLog(logger *log.Logger) RequestOption { 18 | return WithMiddleware(func(req *http.Request, nxt MiddlewareNext) (*http.Response, error) { 19 | if logger == nil { 20 | logger = log.Default() 21 | } 22 | 23 | if reqBytes, err := httputil.DumpRequest(req, true); err == nil { 24 | logger.Printf("Request Content:\n%s\n", reqBytes) 25 | } 26 | 27 | resp, err := nxt(req) 28 | if err != nil { 29 | return resp, err 30 | } 31 | 32 | if respBytes, err := httputil.DumpResponse(resp, true); err == nil { 33 | logger.Printf("Response Content:\n%s\n", respBytes) 34 | } 35 | 36 | return resp, err 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /url_scanner/urlscanner.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package url_scanner 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // URLScannerService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewURLScannerService] method instead. 15 | type URLScannerService struct { 16 | Options []option.RequestOption 17 | Responses *ResponseService 18 | Scans *ScanService 19 | } 20 | 21 | // NewURLScannerService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewURLScannerService(opts ...option.RequestOption) (r *URLScannerService) { 25 | r = &URLScannerService{} 26 | r.Options = opts 27 | r.Responses = NewResponseService(opts...) 28 | r.Scans = NewScanService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /logs/log.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logs 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // LogService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewLogService] method instead. 15 | type LogService struct { 16 | Options []option.RequestOption 17 | Control *ControlService 18 | RayID *RayIDService 19 | Received *ReceivedService 20 | } 21 | 22 | // NewLogService generates a new service that applies the given options to each 23 | // request. These options are applied after the parent client's options (if there 24 | // is one), and before any request-specific options. 25 | func NewLogService(opts ...option.RequestOption) (r *LogService) { 26 | r = &LogService{} 27 | r.Options = opts 28 | r.Control = NewControlService(opts...) 29 | r.RayID = NewRayIDService(opts...) 30 | r.Received = NewReceivedService(opts...) 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /secrets_store/secretsstore.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package secrets_store 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SecretsStoreService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSecretsStoreService] method instead. 15 | type SecretsStoreService struct { 16 | Options []option.RequestOption 17 | Stores *StoreService 18 | Quota *QuotaService 19 | } 20 | 21 | // NewSecretsStoreService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewSecretsStoreService(opts ...option.RequestOption) (r *SecretsStoreService) { 25 | r = &SecretsStoreService{} 26 | r.Options = opts 27 | r.Stores = NewStoreService(opts...) 28 | r.Quota = NewQuotaService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /ips/ip_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ips_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/ips" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestIPListWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.IPs.List(context.TODO(), ips.IPListParams{ 31 | Networks: cloudflare.F("networks"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /workers_for_platforms/workersforplatform.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package workers_for_platforms 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // WorkersForPlatformService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewWorkersForPlatformService] method instead. 15 | type WorkersForPlatformService struct { 16 | Options []option.RequestOption 17 | Dispatch *DispatchService 18 | } 19 | 20 | // NewWorkersForPlatformService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewWorkersForPlatformService(opts ...option.RequestOption) (r *WorkersForPlatformService) { 24 | r = &WorkersForPlatformService{} 25 | r.Options = opts 26 | r.Dispatch = NewDispatchService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /spectrum/analyticsaggregate.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package spectrum 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AnalyticsAggregateService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAnalyticsAggregateService] method instead. 15 | type AnalyticsAggregateService struct { 16 | Options []option.RequestOption 17 | Currents *AnalyticsAggregateCurrentService 18 | } 19 | 20 | // NewAnalyticsAggregateService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewAnalyticsAggregateService(opts ...option.RequestOption) (r *AnalyticsAggregateService) { 24 | r = &AnalyticsAggregateService{} 25 | r.Options = opts 26 | r.Currents = NewAnalyticsAggregateCurrentService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /ai/task_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ai_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/ai" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestTaskList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.AI.Tasks.List(context.TODO(), ai.TaskListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /custom_hostnames/certificatepack.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package custom_hostnames 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // CertificatePackService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewCertificatePackService] method instead. 15 | type CertificatePackService struct { 16 | Options []option.RequestOption 17 | Certificates *CertificatePackCertificateService 18 | } 19 | 20 | // NewCertificatePackService generates a new service that applies the given options 21 | // to each request. These options are applied after the parent client's options (if 22 | // there is one), and before any request-specific options. 23 | func NewCertificatePackService(opts ...option.RequestOption) (r *CertificatePackService) { 24 | r = &CertificatePackService{} 25 | r.Options = opts 26 | r.Certificates = NewCertificatePackCertificateService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /ai/author_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ai_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/ai" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestAuthorList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.AI.Authors.List(context.TODO(), ai.AuthorListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spectrum/analytics.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package spectrum 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AnalyticsService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAnalyticsService] method instead. 15 | type AnalyticsService struct { 16 | Options []option.RequestOption 17 | Aggregates *AnalyticsAggregateService 18 | Events *AnalyticsEventService 19 | } 20 | 21 | // NewAnalyticsService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { 25 | r = &AnalyticsService{} 26 | r.Options = opts 27 | r.Aggregates = NewAnalyticsAggregateService(opts...) 28 | r.Events = NewAnalyticsEventService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /internal/apijson/field.go: -------------------------------------------------------------------------------- 1 | package apijson 2 | 3 | import "reflect" 4 | 5 | type status uint8 6 | 7 | const ( 8 | missing status = iota 9 | null 10 | invalid 11 | valid 12 | ) 13 | 14 | type Field struct { 15 | raw string 16 | status status 17 | } 18 | 19 | // Returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing). 20 | // To check if the field's key is present in the JSON with an explicit null value, 21 | // you must check `f.IsNull() && !f.IsMissing()`. 22 | func (j Field) IsNull() bool { return j.status <= null } 23 | func (j Field) IsMissing() bool { return j.status == missing } 24 | func (j Field) IsInvalid() bool { return j.status == invalid } 25 | func (j Field) Raw() string { return j.raw } 26 | 27 | func getSubField(root reflect.Value, index []int, name string) reflect.Value { 28 | strct := root.FieldByIndex(index[:len(index)-1]) 29 | if !strct.IsValid() { 30 | panic("couldn't find encapsulating struct for field " + name) 31 | } 32 | meta := strct.FieldByName("JSON") 33 | if !meta.IsValid() { 34 | return reflect.Value{} 35 | } 36 | field := meta.FieldByName(name) 37 | if !field.IsValid() { 38 | return reflect.Value{} 39 | } 40 | return field 41 | } 42 | -------------------------------------------------------------------------------- /api_gateway/expressiontemplate.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package api_gateway 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ExpressionTemplateService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewExpressionTemplateService] method instead. 15 | type ExpressionTemplateService struct { 16 | Options []option.RequestOption 17 | Fallthrough *ExpressionTemplateFallthroughService 18 | } 19 | 20 | // NewExpressionTemplateService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewExpressionTemplateService(opts ...option.RequestOption) (r *ExpressionTemplateService) { 24 | r = &ExpressionTemplateService{} 25 | r.Options = opts 26 | r.Fallthrough = NewExpressionTemplateFallthroughService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /r2/bucketdomain.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package r2 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // BucketDomainService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewBucketDomainService] method instead. 15 | type BucketDomainService struct { 16 | Options []option.RequestOption 17 | Custom *BucketDomainCustomService 18 | Managed *BucketDomainManagedService 19 | } 20 | 21 | // NewBucketDomainService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewBucketDomainService(opts ...option.RequestOption) (r *BucketDomainService) { 25 | r = &BucketDomainService{} 26 | r.Options = opts 27 | r.Custom = NewBucketDomainCustomService(opts...) 28 | r.Managed = NewBucketDomainManagedService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /zaraz/export_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestExportGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.Export.Get(context.TODO(), zaraz.ExportGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero_trust/accessinfrastructure.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AccessInfrastructureService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAccessInfrastructureService] method instead. 15 | type AccessInfrastructureService struct { 16 | Options []option.RequestOption 17 | Targets *AccessInfrastructureTargetService 18 | } 19 | 20 | // NewAccessInfrastructureService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewAccessInfrastructureService(opts ...option.RequestOption) (r *AccessInfrastructureService) { 24 | r = &AccessInfrastructureService{} 25 | r.Options = opts 26 | r.Targets = NewAccessInfrastructureTargetService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /intel/iplist_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestIPListGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.IPLists.Get(context.TODO(), intel.IPListGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /usage_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudflare_test 4 | 5 | import ( 6 | "context" 7 | "os" 8 | "testing" 9 | 10 | "github.com/cloudflare/cloudflare-go/v6" 11 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 12 | "github.com/cloudflare/cloudflare-go/v6/option" 13 | "github.com/cloudflare/cloudflare-go/v6/zones" 14 | ) 15 | 16 | func TestUsage(t *testing.T) { 17 | baseURL := "http://localhost:4010" 18 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 19 | baseURL = envURL 20 | } 21 | if !testutil.CheckTestServer(t, baseURL) { 22 | return 23 | } 24 | client := cloudflare.NewClient( 25 | option.WithBaseURL(baseURL), 26 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 27 | option.WithAPIEmail("user@example.com"), 28 | ) 29 | zone, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{ 30 | Account: cloudflare.F(zones.ZoneNewParamsAccount{ 31 | ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }), 33 | Name: cloudflare.F("example.com"), 34 | Type: cloudflare.F(zones.TypeFull), 35 | }) 36 | if err != nil { 37 | t.Error(err) 38 | return 39 | } 40 | t.Logf("%+v\n", zone.ID) 41 | } 42 | -------------------------------------------------------------------------------- /zaraz/default_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestDefaultGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.Default.Get(context.TODO(), zaraz.DefaultGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero_trust/dlpemail.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DLPEmailService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDLPEmailService] method instead. 15 | type DLPEmailService struct { 16 | Options []option.RequestOption 17 | AccountMapping *DLPEmailAccountMappingService 18 | Rules *DLPEmailRuleService 19 | } 20 | 21 | // NewDLPEmailService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewDLPEmailService(opts ...option.RequestOption) (r *DLPEmailService) { 25 | r = &DLPEmailService{} 26 | r.Options = opts 27 | r.AccountMapping = NewDLPEmailAccountMappingService(opts...) 28 | r.Rules = NewDLPEmailRuleService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /images/v1stat_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package images_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/images" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestV1StatGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Images.V1.Stats.Get(context.TODO(), images.V1StatGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /paginationauto_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudflare_test 4 | 5 | import ( 6 | "context" 7 | "os" 8 | "testing" 9 | 10 | "github.com/cloudflare/cloudflare-go/v6" 11 | "github.com/cloudflare/cloudflare-go/v6/accounts" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | ) 15 | 16 | func TestAutoPagination(t *testing.T) { 17 | baseURL := "http://localhost:4010" 18 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 19 | baseURL = envURL 20 | } 21 | if !testutil.CheckTestServer(t, baseURL) { 22 | return 23 | } 24 | client := cloudflare.NewClient( 25 | option.WithBaseURL(baseURL), 26 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 27 | option.WithAPIEmail("user@example.com"), 28 | ) 29 | iter := client.Accounts.ListAutoPaging(context.TODO(), accounts.AccountListParams{}) 30 | // Prism mock isn't going to give us real pagination 31 | for i := 0; i < 3 && iter.Next(); i++ { 32 | account := iter.Current() 33 | t.Logf("%+v\n", account.ID) 34 | } 35 | if err := iter.Err(); err != nil { 36 | t.Fatalf("err should be nil: %s", err.Error()) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /zaraz/workflow_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestWorkflowGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.Workflow.Get(context.TODO(), zaraz.WorkflowGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zones/rateplan_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zones_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zones" 15 | ) 16 | 17 | func TestRatePlanGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zones.RatePlans.Get(context.TODO(), zones.RatePlanGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /intel/sinkhole_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestSinkholeList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.Sinkholes.List(context.TODO(), intel.SinkholeListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero_trust/accesslog.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AccessLogService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAccessLogService] method instead. 15 | type AccessLogService struct { 16 | Options []option.RequestOption 17 | AccessRequests *AccessLogAccessRequestService 18 | SCIM *AccessLogSCIMService 19 | } 20 | 21 | // NewAccessLogService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewAccessLogService(opts ...option.RequestOption) (r *AccessLogService) { 25 | r = &AccessLogService{} 26 | r.Options = opts 27 | r.AccessRequests = NewAccessLogAccessRequestService(opts...) 28 | r.SCIM = NewAccessLogSCIMService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /zero_trust/deviceresilience.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DeviceResilienceService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDeviceResilienceService] method instead. 15 | type DeviceResilienceService struct { 16 | Options []option.RequestOption 17 | GlobalWARPOverride *DeviceResilienceGlobalWARPOverrideService 18 | } 19 | 20 | // NewDeviceResilienceService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewDeviceResilienceService(opts ...option.RequestOption) (r *DeviceResilienceService) { 24 | r = &DeviceResilienceService{} 25 | r.Options = opts 26 | r.GlobalWARPOverride = NewDeviceResilienceGlobalWARPOverrideService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /billing/profile_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package billing_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/billing" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestProfileGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Billing.Profiles.Get(context.TODO(), billing.ProfileGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pages/projectdeploymenthistory.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package pages 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // ProjectDeploymentHistoryService contains methods and other services that help 10 | // with interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewProjectDeploymentHistoryService] method instead. 15 | type ProjectDeploymentHistoryService struct { 16 | Options []option.RequestOption 17 | Logs *ProjectDeploymentHistoryLogService 18 | } 19 | 20 | // NewProjectDeploymentHistoryService generates a new service that applies the 21 | // given options to each request. These options are applied after the parent 22 | // client's options (if there is one), and before any request-specific options. 23 | func NewProjectDeploymentHistoryService(opts ...option.RequestOption) (r *ProjectDeploymentHistoryService) { 24 | r = &ProjectDeploymentHistoryService{} 25 | r.Options = opts 26 | r.Logs = NewProjectDeploymentHistoryLogService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /schema_validation/schemavalidation.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package schema_validation 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SchemaValidationService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSchemaValidationService] method instead. 15 | type SchemaValidationService struct { 16 | Options []option.RequestOption 17 | Schemas *SchemaService 18 | Settings *SettingService 19 | } 20 | 21 | // NewSchemaValidationService generates a new service that applies the given 22 | // options to each request. These options are applied after the parent client's 23 | // options (if there is one), and before any request-specific options. 24 | func NewSchemaValidationService(opts ...option.RequestOption) (r *SchemaValidationService) { 25 | r = &SchemaValidationService{} 26 | r.Options = opts 27 | r.Schemas = NewSchemaService(opts...) 28 | r.Settings = NewSettingService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /zero_trust/dlplimit_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestDLPLimitList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.DLP.Limits.List(context.TODO(), zero_trust.DLPLimitListParams{ 31 | AccountID: cloudflare.F("account_id"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /logs/receivedfield_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logs_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/logs" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestReceivedFieldGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Logs.Received.Fields.Get(context.TODO(), logs.ReceivedFieldGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ssl/recommendation_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ssl_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/ssl" 15 | ) 16 | 17 | func TestRecommendationGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.SSL.Recommendations.Get(context.TODO(), ssl.RecommendationGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /speed/availability_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package speed_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/speed" 15 | ) 16 | 17 | func TestAvailabilityList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Speed.Availabilities.List(context.TODO(), speed.AvailabilityListParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /addressing/service_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package addressing_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/addressing" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestServiceList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Addressing.Services.List(context.TODO(), addressing.ServiceListParams{ 31 | AccountID: cloudflare.F("258def64c72dae45f3e4c8516e2111f2"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /intel/asn_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestASNGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.ASN.Get( 31 | context.TODO(), 32 | int64(0), 33 | intel.ASNGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /token_validation/tokenvalidation.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package token_validation 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // TokenValidationService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewTokenValidationService] method instead. 15 | type TokenValidationService struct { 16 | Options []option.RequestOption 17 | Configuration *ConfigurationService 18 | Rules *RuleService 19 | } 20 | 21 | // NewTokenValidationService generates a new service that applies the given options 22 | // to each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewTokenValidationService(opts ...option.RequestOption) (r *TokenValidationService) { 25 | r = &TokenValidationService{} 26 | r.Options = opts 27 | r.Configuration = NewConfigurationService(opts...) 28 | r.Rules = NewRuleService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /api_gateway/discovery_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package api_gateway_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/api_gateway" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDiscoveryGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.APIGateway.Discovery.Get(context.TODO(), api_gateway.DiscoveryGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /secrets_store/quota_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package secrets_store_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/secrets_store" 15 | ) 16 | 17 | func TestQuotaGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.SecretsStore.Quota.Get(context.TODO(), secrets_store.QuotaGetParams{ 31 | AccountID: cloudflare.F("985e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zaraz/zaraz_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestZarazUpdate(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.Update(context.TODO(), zaraz.ZarazUpdateParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Workflow: zaraz.WorkflowRealtime, 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /diagnostics/diagnostic.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package diagnostics 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DiagnosticService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDiagnosticService] method instead. 15 | type DiagnosticService struct { 16 | Options []option.RequestOption 17 | Traceroutes *TracerouteService 18 | EndpointHealthchecks *EndpointHealthcheckService 19 | } 20 | 21 | // NewDiagnosticService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewDiagnosticService(opts ...option.RequestOption) (r *DiagnosticService) { 25 | r = &DiagnosticService{} 26 | r.Options = opts 27 | r.Traceroutes = NewTracerouteService(opts...) 28 | r.EndpointHealthchecks = NewEndpointHealthcheckService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /ai/modelschema_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ai_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/ai" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestModelSchemaGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.AI.Models.Schema.Get(context.TODO(), ai.ModelSchemaGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Model: cloudflare.F("model"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /certificate_authorities/certificateauthority.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package certificate_authorities 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // CertificateAuthorityService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewCertificateAuthorityService] method instead. 15 | type CertificateAuthorityService struct { 16 | Options []option.RequestOption 17 | HostnameAssociations *HostnameAssociationService 18 | } 19 | 20 | // NewCertificateAuthorityService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewCertificateAuthorityService(opts ...option.RequestOption) (r *CertificateAuthorityService) { 24 | r = &CertificateAuthorityService{} 25 | r.Options = opts 26 | r.HostnameAssociations = NewHostnameAssociationService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /r2/r2.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package r2 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // R2Service contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewR2Service] method instead. 15 | type R2Service struct { 16 | Options []option.RequestOption 17 | Buckets *BucketService 18 | TemporaryCredentials *TemporaryCredentialService 19 | SuperSlurper *SuperSlurperService 20 | } 21 | 22 | // NewR2Service generates a new service that applies the given options to each 23 | // request. These options are applied after the parent client's options (if there 24 | // is one), and before any request-specific options. 25 | func NewR2Service(opts ...option.RequestOption) (r *R2Service) { 26 | r = &R2Service{} 27 | r.Options = opts 28 | r.Buckets = NewBucketService(opts...) 29 | r.TemporaryCredentials = NewTemporaryCredentialService(opts...) 30 | r.SuperSlurper = NewSuperSlurperService(opts...) 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /radar/aiinferencetimeseriesgroup.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AIInferenceTimeseriesGroupService contains methods and other services that help 10 | // with interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAIInferenceTimeseriesGroupService] method instead. 15 | type AIInferenceTimeseriesGroupService struct { 16 | Options []option.RequestOption 17 | Summary *AIInferenceTimeseriesGroupSummaryService 18 | } 19 | 20 | // NewAIInferenceTimeseriesGroupService generates a new service that applies the 21 | // given options to each request. These options are applied after the parent 22 | // client's options (if there is one), and before any request-specific options. 23 | func NewAIInferenceTimeseriesGroupService(opts ...option.RequestOption) (r *AIInferenceTimeseriesGroupService) { 24 | r = &AIInferenceTimeseriesGroupService{} 25 | r.Options = opts 26 | r.Summary = NewAIInferenceTimeseriesGroupSummaryService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /ssl/certificatepackquota_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ssl_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/ssl" 15 | ) 16 | 17 | func TestCertificatePackQuotaGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.SSL.CertificatePacks.Quota.Get(context.TODO(), ssl.CertificatePackQuotaGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero_trust/dextraceroutetestresult.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DEXTracerouteTestResultService contains methods and other services that help 10 | // with interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDEXTracerouteTestResultService] method instead. 15 | type DEXTracerouteTestResultService struct { 16 | Options []option.RequestOption 17 | NetworkPath *DEXTracerouteTestResultNetworkPathService 18 | } 19 | 20 | // NewDEXTracerouteTestResultService generates a new service that applies the given 21 | // options to each request. These options are applied after the parent client's 22 | // options (if there is one), and before any request-specific options. 23 | func NewDEXTracerouteTestResultService(opts ...option.RequestOption) (r *DEXTracerouteTestResultService) { 24 | r = &DEXTracerouteTestResultService{} 25 | r.Options = opts 26 | r.NetworkPath = NewDEXTracerouteTestResultNetworkPathService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /zones/activationcheck_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zones_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zones" 15 | ) 16 | 17 | func TestActivationCheckTrigger(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zones.ActivationCheck.Trigger(context.TODO(), zones.ActivationCheckTriggerParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /alerting/availablealert_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package alerting_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/alerting" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestAvailableAlertList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Alerting.AvailableAlerts.List(context.TODO(), alerting.AvailableAlertListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /radar/entity_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/radar" 15 | ) 16 | 17 | func TestEntityGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Radar.Entities.Get(context.TODO(), radar.EntityGetParams{ 31 | IP: cloudflare.F("8.8.8.8"), 32 | Format: cloudflare.F(radar.EntityGetParamsFormatJson), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zero_trust/riskscoringsummary_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestRiskScoringSummaryGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.RiskScoring.Summary.Get(context.TODO(), zero_trust.RiskScoringSummaryGetParams{ 31 | AccountID: cloudflare.F("account_id"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.github/workflows/detect-breaking-changes.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | - next 7 | 8 | jobs: 9 | detect_breaking_changes: 10 | runs-on: 'ubuntu-latest' 11 | name: detect-breaking-changes 12 | if: github.repository == 'cloudflare/cloudflare-go' 13 | steps: 14 | - name: Calculate fetch-depth 15 | run: | 16 | echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV 17 | 18 | - uses: actions/checkout@v4 19 | with: 20 | # Ensure we can check out the pull request base in the script below. 21 | fetch-depth: ${{ env.FETCH_DEPTH }} 22 | 23 | - name: Setup go 24 | uses: actions/setup-go@v5 25 | with: 26 | go-version-file: ./go.mod 27 | 28 | - name: Detect breaking changes 29 | run: | 30 | # Try to check out previous versions of the breaking change detection script. This ensures that 31 | # we still detect breaking changes when entire files and their tests are removed. 32 | git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true 33 | ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }} -------------------------------------------------------------------------------- /content_scanning/setting_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package content_scanning_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/content_scanning" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestSettingGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ContentScanning.Settings.Get(context.TODO(), content_scanning.SettingGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /dcv_delegation/dcvdelegation_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dcv_delegation_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/dcv_delegation" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDCVDelegationGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.DCVDelegation.Get(context.TODO(), dcv_delegation.DCVDelegationGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /intel/asnsubnet_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestASNSubnetGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.ASN.Subnets.Get( 31 | context.TODO(), 32 | int64(0), 33 | intel.ASNSubnetGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /intel/whois_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestWhoisGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.Whois.Get(context.TODO(), intel.WhoisGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Domain: cloudflare.F("domain"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /web3/hostnameipfsuniversalpath.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package web3 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // HostnameIPFSUniversalPathService contains methods and other services that help 10 | // with interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewHostnameIPFSUniversalPathService] method instead. 15 | type HostnameIPFSUniversalPathService struct { 16 | Options []option.RequestOption 17 | ContentLists *HostnameIPFSUniversalPathContentListService 18 | } 19 | 20 | // NewHostnameIPFSUniversalPathService generates a new service that applies the 21 | // given options to each request. These options are applied after the parent 22 | // client's options (if there is one), and before any request-specific options. 23 | func NewHostnameIPFSUniversalPathService(opts ...option.RequestOption) (r *HostnameIPFSUniversalPathService) { 24 | r = &HostnameIPFSUniversalPathService{} 25 | r.Options = opts 26 | r.ContentLists = NewHostnameIPFSUniversalPathContentListService(opts...) 27 | return 28 | } 29 | -------------------------------------------------------------------------------- /intel/domain_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDomainGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.Domains.Get(context.TODO(), intel.DomainGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Domain: cloudflare.F("domain"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /url_scanner/response_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package url_scanner_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/url_scanner" 15 | ) 16 | 17 | func TestResponseGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.URLScanner.Responses.Get( 31 | context.TODO(), 32 | "response_id", 33 | url_scanner.ResponseGetParams{ 34 | AccountID: cloudflare.F("account_id"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zero_trust/dexcommandquota_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestDEXCommandQuotaGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.DEX.Commands.Quota.Get(context.TODO(), zero_trust.DEXCommandQuotaGetParams{ 31 | AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /zero_trust/gatewayapptype_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestGatewayAppTypeList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.Gateway.AppTypes.List(context.TODO(), zero_trust.GatewayAppTypeListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /alerting/destinationeligible_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package alerting_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/alerting" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDestinationEligibleGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Alerting.Destinations.Eligible.Get(context.TODO(), alerting.DestinationEligibleGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /r2/superslurper.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package r2 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // SuperSlurperService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewSuperSlurperService] method instead. 15 | type SuperSlurperService struct { 16 | Options []option.RequestOption 17 | Jobs *SuperSlurperJobService 18 | ConnectivityPrecheck *SuperSlurperConnectivityPrecheckService 19 | } 20 | 21 | // NewSuperSlurperService generates a new service that applies the given options to 22 | // each request. These options are applied after the parent client's options (if 23 | // there is one), and before any request-specific options. 24 | func NewSuperSlurperService(opts ...option.RequestOption) (r *SuperSlurperService) { 25 | r = &SuperSlurperService{} 26 | r.Options = opts 27 | r.Jobs = NewSuperSlurperJobService(opts...) 28 | r.ConnectivityPrecheck = NewSuperSlurperConnectivityPrecheckService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /stream/embed_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package stream_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/stream" 15 | ) 16 | 17 | func TestEmbedGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Stream.Embed.Get( 31 | context.TODO(), 32 | "ea95132c15732412d22c1476fa83f27a", 33 | stream.EmbedGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zero_trust/gatewaycategory_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestGatewayCategoryList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.Gateway.Categories.List(context.TODO(), zero_trust.GatewayCategoryListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /dns/zonetransferoutgoingstatus_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dns_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/dns" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestZoneTransferOutgoingStatusGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.DNS.ZoneTransfers.Outgoing.Status.Get(context.TODO(), dns.ZoneTransferOutgoingStatusGetParams{ 31 | ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /r2/bucketmetric_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package r2_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/r2" 15 | ) 16 | 17 | func TestBucketMetricList(t *testing.T) { 18 | t.Skip("TODO: investigate auth errors on test suite") 19 | baseURL := "http://localhost:4010" 20 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 21 | baseURL = envURL 22 | } 23 | if !testutil.CheckTestServer(t, baseURL) { 24 | return 25 | } 26 | client := cloudflare.NewClient( 27 | option.WithBaseURL(baseURL), 28 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 29 | option.WithAPIEmail("user@example.com"), 30 | ) 31 | _, err := client.R2.Buckets.Metrics.List(context.TODO(), r2.BucketMetricListParams{ 32 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /stream/caption_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package stream_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/stream" 15 | ) 16 | 17 | func TestCaptionGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Stream.Captions.Get( 31 | context.TODO(), 32 | "ea95132c15732412d22c1476fa83f27a", 33 | stream.CaptionGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zaraz/historyconfig_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestHistoryConfigGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.History.Configs.Get(context.TODO(), zaraz.HistoryConfigGetParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | IDs: cloudflare.F([]int64{int64(0)}), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /zaraz/publish_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zaraz_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zaraz" 15 | ) 16 | 17 | func TestPublishNewWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Zaraz.Publish.New(context.TODO(), zaraz.PublishNewParams{ 31 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Body: "Config with enabled ecommerce tracking", 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ai_gateway/url_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ai_gateway_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/ai_gateway" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestURLGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.AIGateway.URLs.Get( 31 | context.TODO(), 32 | "my-gateway", 33 | "workers-ai", 34 | ai_gateway.URLGetParams{ 35 | AccountID: cloudflare.F("0d37909e38d3e99c29fa2cd343ac421a"), 36 | }, 37 | ) 38 | if err != nil { 39 | var apierr *cloudflare.Error 40 | if errors.As(err, &apierr) { 41 | t.Log(string(apierr.DumpRequest(true))) 42 | } 43 | t.Fatalf("err should be nil: %s", err.Error()) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /intel/ip_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestIPGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.IPs.Get(context.TODO(), intel.IPGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | IPV4: cloudflare.F("ipv4"), 33 | IPV6: cloudflare.F("ipv6"), 34 | }) 35 | if err != nil { 36 | var apierr *cloudflare.Error 37 | if errors.As(err, &apierr) { 38 | t.Log(string(apierr.DumpRequest(true))) 39 | } 40 | t.Fatalf("err should be nil: %s", err.Error()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /zero_trust/accessaicontrolmcp.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AccessAIControlMcpService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAccessAIControlMcpService] method instead. 15 | type AccessAIControlMcpService struct { 16 | Options []option.RequestOption 17 | Portals *AccessAIControlMcpPortalService 18 | Servers *AccessAIControlMcpServerService 19 | } 20 | 21 | // NewAccessAIControlMcpService generates a new service that applies the given 22 | // options to each request. These options are applied after the parent client's 23 | // options (if there is one), and before any request-specific options. 24 | func NewAccessAIControlMcpService(opts ...option.RequestOption) (r *AccessAIControlMcpService) { 25 | r = &AccessAIControlMcpService{} 26 | r.Options = opts 27 | r.Portals = NewAccessAIControlMcpPortalService(opts...) 28 | r.Servers = NewAccessAIControlMcpServerService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /cloudforce_one/scanresult_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/cloudforce_one" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestScanResultGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.CloudforceOne.Scans.Results.Get( 31 | context.TODO(), 32 | "config_id", 33 | cloudforce_one.ScanResultGetParams{ 34 | AccountID: cloudflare.F("account_id"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /intel/domainbulk_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDomainBulkGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.Domains.Bulks.Get(context.TODO(), intel.DomainBulkGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Domain: cloudflare.F([]string{"string"}), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dns/zonetransferforceaxfr_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package dns_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/dns" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestZoneTransferForceAXFRNew(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.DNS.ZoneTransfers.ForceAXFR.New(context.TODO(), dns.ZoneTransferForceAXFRNewParams{ 31 | ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), 32 | Body: map[string]interface{}{}, 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /intel/attacksurfacereportissuetype_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestAttackSurfaceReportIssueTypeGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.AttackSurfaceReport.IssueTypes.Get(context.TODO(), intel.AttackSurfaceReportIssueTypeGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /intel/domainhistory_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/intel" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestDomainHistoryGetWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Intel.DomainHistory.Get(context.TODO(), intel.DomainHistoryGetParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Domain: cloudflare.F("example.com"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /addressing/regionalhostnameregion_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package addressing_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/addressing" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestRegionalHostnameRegionList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Addressing.RegionalHostnames.Regions.List(context.TODO(), addressing.RegionalHostnameRegionListParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /email_security/emailsecurity.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package email_security 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // EmailSecurityService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewEmailSecurityService] method instead. 15 | type EmailSecurityService struct { 16 | Options []option.RequestOption 17 | Investigate *InvestigateService 18 | Settings *SettingService 19 | Submissions *SubmissionService 20 | } 21 | 22 | // NewEmailSecurityService generates a new service that applies the given options 23 | // to each request. These options are applied after the parent client's options (if 24 | // there is one), and before any request-specific options. 25 | func NewEmailSecurityService(opts ...option.RequestOption) (r *EmailSecurityService) { 26 | r = &EmailSecurityService{} 27 | r.Options = opts 28 | r.Investigate = NewInvestigateService(opts...) 29 | r.Settings = NewSettingService(opts...) 30 | r.Submissions = NewSubmissionService(opts...) 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /zero_trust/identityproviderscim.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // IdentityProviderSCIMService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewIdentityProviderSCIMService] method instead. 15 | type IdentityProviderSCIMService struct { 16 | Options []option.RequestOption 17 | Groups *IdentityProviderSCIMGroupService 18 | Users *IdentityProviderSCIMUserService 19 | } 20 | 21 | // NewIdentityProviderSCIMService generates a new service that applies the given 22 | // options to each request. These options are applied after the parent client's 23 | // options (if there is one), and before any request-specific options. 24 | func NewIdentityProviderSCIMService(opts ...option.RequestOption) (r *IdentityProviderSCIMService) { 25 | r = &IdentityProviderSCIMService{} 26 | r.Options = opts 27 | r.Groups = NewIdentityProviderSCIMGroupService(opts...) 28 | r.Users = NewIdentityProviderSCIMUserService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /intel/attacksurfacereport.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package intel 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AttackSurfaceReportService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAttackSurfaceReportService] method instead. 15 | type AttackSurfaceReportService struct { 16 | Options []option.RequestOption 17 | IssueTypes *AttackSurfaceReportIssueTypeService 18 | Issues *AttackSurfaceReportIssueService 19 | } 20 | 21 | // NewAttackSurfaceReportService generates a new service that applies the given 22 | // options to each request. These options are applied after the parent client's 23 | // options (if there is one), and before any request-specific options. 24 | func NewAttackSurfaceReportService(opts ...option.RequestOption) (r *AttackSurfaceReportService) { 25 | r = &AttackSurfaceReportService{} 26 | r.Options = opts 27 | r.IssueTypes = NewAttackSurfaceReportIssueTypeService(opts...) 28 | r.Issues = NewAttackSurfaceReportIssueService(opts...) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /stream/video_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package stream_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/stream" 15 | ) 16 | 17 | func TestVideoStorageUsageWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Stream.Videos.StorageUsage(context.TODO(), stream.VideoStorageUsageParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Creator: cloudflare.F("creator-id_abcde12345"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /user/tokenvalue_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package user_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/user" 15 | ) 16 | 17 | func TestTokenValueUpdate(t *testing.T) { 18 | t.Skip("TODO: investigate broken test") 19 | baseURL := "http://localhost:4010" 20 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 21 | baseURL = envURL 22 | } 23 | if !testutil.CheckTestServer(t, baseURL) { 24 | return 25 | } 26 | client := cloudflare.NewClient( 27 | option.WithBaseURL(baseURL), 28 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 29 | option.WithAPIEmail("user@example.com"), 30 | ) 31 | _, err := client.User.Tokens.Value.Update( 32 | context.TODO(), 33 | "ed17574386854bf78a67040be0a770b0", 34 | user.TokenValueUpdateParams{ 35 | Body: map[string]interface{}{}, 36 | }, 37 | ) 38 | if err != nil { 39 | var apierr *cloudflare.Error 40 | if errors.As(err, &apierr) { 41 | t.Log(string(apierr.DumpRequest(true))) 42 | } 43 | t.Fatalf("err should be nil: %s", err.Error()) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /waiting_rooms/status_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package waiting_rooms_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/waiting_rooms" 15 | ) 16 | 17 | func TestStatusGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.WaitingRooms.Statuses.Get( 31 | context.TODO(), 32 | "699d98642c564d2e855e9661899b7252", 33 | waiting_rooms.StatusGetParams{ 34 | ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /magic_network_monitoring/configfull_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package magic_network_monitoring_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/magic_network_monitoring" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestConfigFullGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.MagicNetworkMonitoring.Configs.Full.Get(context.TODO(), magic_network_monitoring.ConfigFullGetParams{ 31 | AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /alerting/destination.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package alerting 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // DestinationService contains methods and other services that help with 10 | // interacting with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewDestinationService] method instead. 15 | type DestinationService struct { 16 | Options []option.RequestOption 17 | Eligible *DestinationEligibleService 18 | Pagerduty *DestinationPagerdutyService 19 | Webhooks *DestinationWebhookService 20 | } 21 | 22 | // NewDestinationService generates a new service that applies the given options to 23 | // each request. These options are applied after the parent client's options (if 24 | // there is one), and before any request-specific options. 25 | func NewDestinationService(opts ...option.RequestOption) (r *DestinationService) { 26 | r = &DestinationService{} 27 | r.Options = opts 28 | r.Eligible = NewDestinationEligibleService(opts...) 29 | r.Pagerduty = NewDestinationPagerdutyService(opts...) 30 | r.Webhooks = NewDestinationWebhookService(opts...) 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /cloudforce_one/threateventcountry_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/cloudforce_one" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestThreatEventCountryList(t *testing.T) { 18 | t.Skip("TODO: HTTP 401 from prism") 19 | baseURL := "http://localhost:4010" 20 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 21 | baseURL = envURL 22 | } 23 | if !testutil.CheckTestServer(t, baseURL) { 24 | return 25 | } 26 | client := cloudflare.NewClient( 27 | option.WithBaseURL(baseURL), 28 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 29 | option.WithAPIEmail("user@example.com"), 30 | ) 31 | _, err := client.CloudforceOne.ThreatEvents.Countries.List(context.TODO(), cloudforce_one.ThreatEventCountryListParams{ 32 | AccountID: cloudflare.F("account_id"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /iam/iam.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package iam 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // IAMService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewIAMService] method instead. 15 | type IAMService struct { 16 | Options []option.RequestOption 17 | PermissionGroups *PermissionGroupService 18 | ResourceGroups *ResourceGroupService 19 | UserGroups *UserGroupService 20 | SSO *SSOService 21 | } 22 | 23 | // NewIAMService generates a new service that applies the given options to each 24 | // request. These options are applied after the parent client's options (if there 25 | // is one), and before any request-specific options. 26 | func NewIAMService(opts ...option.RequestOption) (r *IAMService) { 27 | r = &IAMService{} 28 | r.Options = opts 29 | r.PermissionGroups = NewPermissionGroupService(opts...) 30 | r.ResourceGroups = NewResourceGroupService(opts...) 31 | r.UserGroups = NewUserGroupService(opts...) 32 | r.SSO = NewSSOService(opts...) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /kv/namespacemetadata_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package kv_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/kv" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestNamespaceMetadataGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.KV.Namespaces.Metadata.Get( 31 | context.TODO(), 32 | "0f2ac74b498b48028cb68387c421e279", 33 | "My-Key", 34 | kv.NamespaceMetadataGetParams{ 35 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 36 | }, 37 | ) 38 | if err != nil { 39 | var apierr *cloudflare.Error 40 | if errors.As(err, &apierr) { 41 | t.Log(string(apierr.DumpRequest(true))) 42 | } 43 | t.Fatalf("err should be nil: %s", err.Error()) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /load_balancers/preview_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package load_balancers_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/load_balancers" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestPreviewGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.LoadBalancers.Previews.Get( 31 | context.TODO(), 32 | "p1aba936b94213e5b8dca0c0dbf1f9cc", 33 | load_balancers.PreviewGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /radar/ai.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package radar 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // AIService contains methods and other services that help with interacting with 10 | // the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewAIService] method instead. 15 | type AIService struct { 16 | Options []option.RequestOption 17 | ToMarkdown *AIToMarkdownService 18 | Inference *AIInferenceService 19 | Bots *AIBotService 20 | TimeseriesGroups *AITimeseriesGroupService 21 | } 22 | 23 | // NewAIService generates a new service that applies the given options to each 24 | // request. These options are applied after the parent client's options (if there 25 | // is one), and before any request-specific options. 26 | func NewAIService(opts ...option.RequestOption) (r *AIService) { 27 | r = &AIService{} 28 | r.Options = opts 29 | r.ToMarkdown = NewAIToMarkdownService(opts...) 30 | r.Inference = NewAIInferenceService(opts...) 31 | r.Bots = NewAIBotService(opts...) 32 | r.TimeseriesGroups = NewAITimeseriesGroupService(opts...) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /rules/listbulkoperation_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package rules_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/rules" 15 | ) 16 | 17 | func TestListBulkOperationGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Rules.Lists.BulkOperations.Get( 31 | context.TODO(), 32 | "4da8780eeb215e6cb7f48dd981c4ea02", 33 | rules.ListBulkOperationGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zero_trust/devicerevoke_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestDeviceRevokeNew(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.Devices.Revoke.New(context.TODO(), zero_trust.DeviceRevokeNewParams{ 31 | AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), 32 | Body: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}, 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /magic_network_monitoring/vpcflowtoken_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package magic_network_monitoring_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/magic_network_monitoring" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestVPCFlowTokenNew(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.MagicNetworkMonitoring.VPCFlows.Tokens.New(context.TODO(), magic_network_monitoring.VPCFlowTokenNewParams{ 31 | AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), 32 | }) 33 | if err != nil { 34 | var apierr *cloudflare.Error 35 | if errors.As(err, &apierr) { 36 | t.Log(string(apierr.DumpRequest(true))) 37 | } 38 | t.Fatalf("err should be nil: %s", err.Error()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ai/ai_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package ai_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/ai" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestAIRunWithOptionalParams(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.AI.Run( 31 | context.TODO(), 32 | "model_name", 33 | ai.AIRunParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | Body: ai.AIRunParamsBodyTextClassification{ 36 | Text: cloudflare.F("x"), 37 | }, 38 | }, 39 | ) 40 | if err != nil { 41 | var apierr *cloudflare.Error 42 | if errors.As(err, &apierr) { 43 | t.Log(string(apierr.DumpRequest(true))) 44 | } 45 | t.Fatalf("err should be nil: %s", err.Error()) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /email_security/investigateraw_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package email_security_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/email_security" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestInvestigateRawGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.EmailSecurity.Investigate.Raw.Get( 31 | context.TODO(), 32 | "4Njp3P0STMz2c02Q", 33 | email_security.InvestigateRawGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /zero_trust/deviceunrevoke_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestDeviceUnrevokeNew(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.Devices.Unrevoke.New(context.TODO(), zero_trust.DeviceUnrevokeNewParams{ 31 | AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), 32 | Body: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}, 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /email_security/investigatetrace_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package email_security_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/email_security" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestInvestigateTraceGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.EmailSecurity.Investigate.Trace.Get( 31 | context.TODO(), 32 | "4Njp3P0STMz2c02Q", 33 | email_security.InvestigateTraceGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /stream/captionlanguagevtt_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package stream_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/stream" 15 | ) 16 | 17 | func TestCaptionLanguageVttGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Stream.Captions.Language.Vtt.Get( 31 | context.TODO(), 32 | "ea95132c15732412d22c1476fa83f27a", 33 | "tr", 34 | stream.CaptionLanguageVttGetParams{ 35 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 36 | }, 37 | ) 38 | if err != nil { 39 | var apierr *cloudflare.Error 40 | if errors.As(err, &apierr) { 41 | t.Log(string(apierr.DumpRequest(true))) 42 | } 43 | t.Fatalf("err should be nil: %s", err.Error()) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /zero_trust/gatewaylistitem_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package zero_trust_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/option" 14 | "github.com/cloudflare/cloudflare-go/v6/zero_trust" 15 | ) 16 | 17 | func TestGatewayListItemList(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.ZeroTrust.Gateway.Lists.Items.List( 31 | context.TODO(), 32 | "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", 33 | zero_trust.GatewayListItemListParams{ 34 | AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /accounts/accountorganization_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package accounts_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/accounts" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestAccountOrganizationNew(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.Accounts.AccountOrganizations.New(context.TODO(), accounts.AccountOrganizationNewParams{ 31 | AccountID: cloudflare.F("account_id"), 32 | DestinationOrganizationID: cloudflare.F("destination_organization_id"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cloudforce_one/threateventindicatortype_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package cloudforce_one_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/cloudforce_one" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestThreatEventIndicatorTypeList(t *testing.T) { 18 | t.Skip("TODO: HTTP 401 from prism") 19 | baseURL := "http://localhost:4010" 20 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 21 | baseURL = envURL 22 | } 23 | if !testutil.CheckTestServer(t, baseURL) { 24 | return 25 | } 26 | client := cloudflare.NewClient( 27 | option.WithBaseURL(baseURL), 28 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 29 | option.WithAPIEmail("user@example.com"), 30 | ) 31 | _, err := client.CloudforceOne.ThreatEvents.IndicatorTypes.List(context.TODO(), cloudforce_one.ThreatEventIndicatorTypeListParams{ 32 | AccountID: cloudflare.F("account_id"), 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /email_security/investigaterelease_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package email_security_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/email_security" 13 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestInvestigateReleaseBulk(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.EmailSecurity.Investigate.Release.Bulk(context.TODO(), email_security.InvestigateReleaseBulkParams{ 31 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 32 | Body: []string{"4Njp3P0STMz2c02Q"}, 33 | }) 34 | if err != nil { 35 | var apierr *cloudflare.Error 36 | if errors.As(err, &apierr) { 37 | t.Log(string(apierr.DumpRequest(true))) 38 | } 39 | t.Fatalf("err should be nil: %s", err.Error()) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /load_balancers/poolreference_test.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package load_balancers_test 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "os" 9 | "testing" 10 | 11 | "github.com/cloudflare/cloudflare-go/v6" 12 | "github.com/cloudflare/cloudflare-go/v6/internal/testutil" 13 | "github.com/cloudflare/cloudflare-go/v6/load_balancers" 14 | "github.com/cloudflare/cloudflare-go/v6/option" 15 | ) 16 | 17 | func TestPoolReferenceGet(t *testing.T) { 18 | baseURL := "http://localhost:4010" 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 20 | baseURL = envURL 21 | } 22 | if !testutil.CheckTestServer(t, baseURL) { 23 | return 24 | } 25 | client := cloudflare.NewClient( 26 | option.WithBaseURL(baseURL), 27 | option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), 28 | option.WithAPIEmail("user@example.com"), 29 | ) 30 | _, err := client.LoadBalancers.Pools.References.Get( 31 | context.TODO(), 32 | "17b5962d775c646f3f9725cbc7a53df4", 33 | load_balancers.PoolReferenceGetParams{ 34 | AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), 35 | }, 36 | ) 37 | if err != nil { 38 | var apierr *cloudflare.Error 39 | if errors.As(err, &apierr) { 40 | t.Log(string(apierr.DumpRequest(true))) 41 | } 42 | t.Fatalf("err should be nil: %s", err.Error()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /logpush/logpush.go: -------------------------------------------------------------------------------- 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | package logpush 4 | 5 | import ( 6 | "github.com/cloudflare/cloudflare-go/v6/option" 7 | ) 8 | 9 | // LogpushService contains methods and other services that help with interacting 10 | // with the cloudflare API. 11 | // 12 | // Note, unlike clients, this service does not read variables from the environment 13 | // automatically. You should not instantiate this service directly, and instead use 14 | // the [NewLogpushService] method instead. 15 | type LogpushService struct { 16 | Options []option.RequestOption 17 | Datasets *DatasetService 18 | Edge *EdgeService 19 | Jobs *JobService 20 | Ownership *OwnershipService 21 | Validate *ValidateService 22 | } 23 | 24 | // NewLogpushService generates a new service that applies the given options to each 25 | // request. These options are applied after the parent client's options (if there 26 | // is one), and before any request-specific options. 27 | func NewLogpushService(opts ...option.RequestOption) (r *LogpushService) { 28 | r = &LogpushService{} 29 | r.Options = opts 30 | r.Datasets = NewDatasetService(opts...) 31 | r.Edge = NewEdgeService(opts...) 32 | r.Jobs = NewJobService(opts...) 33 | r.Ownership = NewOwnershipService(opts...) 34 | r.Validate = NewValidateService(opts...) 35 | return 36 | } 37 | --------------------------------------------------------------------------------