cloudflare

package module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2019 License: BSD-3-Clause Imports: 17 Imported by: 1,195

README

cloudflare-go

GoDoc Build Status Go Report Card

Note: This library is under active development as we expand it to cover our (expanding!) API. Consider the public API of this package a little unstable as we work towards a v1.0.

A Go library for interacting with Cloudflare's API v4. This library allows you to:

  • Manage and automate changes to your DNS records within Cloudflare
  • Manage and automate changes to your zones (domains) on Cloudflare, including adding new zones to your account
  • List and modify the status of WAF (Web Application Firewall) rules for your zones
  • Fetch Cloudflare's IP ranges for automating your firewall whitelisting

A command-line client, flarectl, is also available as part of this project.

Features

The current feature list includes:

  • Cache purging
  • Cloudflare IPs
  • Custom hostnames
  • DNS Records
  • Firewall (partial)
  • Keyless SSL
  • Load Balancing
  • Logpush Jobs
  • Organization Administration
  • Origin CA
  • Railgun administration
  • Rate Limiting
  • User Administration (partial)
  • Virtual DNS Management
  • Web Application Firewall (WAF)
  • Zone Lockdown and User-Agent Block rules
  • Zones

Pull Requests are welcome, but please open an issue (or comment in an existing issue) to discuss any non-trivial changes before submitting code.

Installation

You need a working Go environment.

go get github.com/cloudflare/cloudflare-go

Getting Started

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/cloudflare/cloudflare-go"
)

func main() {
	// Construct a new API object
	api, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))
	if err != nil {
		log.Fatal(err)
	}

	// Fetch user details on the account
	u, err := api.UserDetails()
	if err != nil {
		log.Fatal(err)
	}
	// Print user details
	fmt.Println(u)

	// Fetch the zone ID
	id, err := api.ZoneIDByName("example.com") // Assuming example.com exists in your Cloudflare account already
	if err != nil {
		log.Fatal(err)
	}

	// Fetch zone details
	zone, err := api.ZoneDetails(id)
	if err != nil {
		log.Fatal(err)
	}
	// Print zone details
	fmt.Println(zone)
}

Also refer to the API documentation for how to use this package in-depth.

License

BSD licensed. See the LICENSE file for details.

Documentation

Overview

Package cloudflare implements the Cloudflare v4 API.

Example
package main

import (
	"fmt"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

const (
	user   = "cloudflare@example.org"
	domain = "example.com"
	apiKey = "deadbeef"
)

func main() {
	api, err := cloudflare.New("deadbeef", "cloudflare@example.org")
	if err != nil {
		fmt.Println(err)
		return
	}

	// Fetch the zone ID for zone example.org
	zoneID, err := api.ZoneIDByName("example.org")
	if err != nil {
		fmt.Println(err)
		return
	}

	// Fetch all DNS records for example.org
	records, err := api.DNSRecords(zoneID, cloudflare.DNSRecord{})
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, r := range records {
		fmt.Printf("%s: %s\n", r.Name, r.Content)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// AuthKeyEmail specifies that we should authenticate with API key and email address
	AuthKeyEmail = 1 << iota
	// AuthUserService specifies that we should authenticate with a User-Service key
	AuthUserService
	// AuthToken specifies that we should authenticate with an API Token
	AuthToken
)

Variables

View Source
var PageRuleActions = map[string]string{
	"always_online":               "Always Online",
	"always_use_https":            "Always Use HTTPS",
	"automatic_https_rewrites":    "Automatic HTTPS Rewrites",
	"browser_cache_ttl":           "Browser Cache TTL",
	"browser_check":               "Browser Integrity Check",
	"bypass_cache_on_cookie":      "Bypass Cache on Cookie",
	"cache_by_device_type":        "Cache By Device Type",
	"cache_deception_armor":       "Cache Deception Armor",
	"cache_level":                 "Cache Level",
	"cache_on_cookie":             "Cache On Cookie",
	"disable_apps":                "Disable Apps",
	"disable_performance":         "Disable Performance",
	"disable_railgun":             "Disable Railgun",
	"disable_security":            "Disable Security",
	"edge_cache_ttl":              "Edge Cache TTL",
	"email_obfuscation":           "Email Obfuscation",
	"explicit_cache_control":      "Origin Cache Control",
	"forwarding_url":              "Forwarding URL",
	"host_header_override":        "Host Header Override",
	"ip_geolocation":              "IP Geolocation Header",
	"minify":                      "Minify",
	"mirage":                      "Mirage",
	"opportunistic_encryption":    "Opportunistic Encryption",
	"origin_error_page_pass_thru": "Origin Error Page Pass-thru",
	"polish":                      "Polish",
	"resolve_override":            "Resolve Override",
	"respect_strong_etag":         "Respect Strong ETags",
	"response_buffering":          "Response Buffering",
	"rocket_loader":               "Rocker Loader",
	"security_level":              "Security Level",
	"server_side_exclude":         "Server Side Excludes",
	"sort_query_string_for_cache": "Query String Sort",
	"ssl":                         "SSL",
	"true_client_ip_header":       "True Client IP Header",
	"waf":                         "Web Application Firewall",
}

PageRuleActions maps API action IDs to human-readable strings.

Functions

This section is empty.

Types

type API added in v0.7.2

type API struct {
	APIKey            string
	APIEmail          string
	APIUserServiceKey string
	APIToken          string
	BaseURL           string
	AccountID         string
	UserAgent         string
	// contains filtered or unexported fields
}

API holds the configuration for the current API client. A client should not be modified concurrently.

func New added in v0.7.2

func New(key, email string, opts ...Option) (*API, error)

New creates a new Cloudflare v4 API client.

func NewWithAPIToken added in v0.9.3

func NewWithAPIToken(token string, opts ...Option) (*API, error)

NewWithAPIToken creates a new Cloudflare v4 API client using API Tokens

func NewWithUserServiceKey added in v0.9.0

func NewWithUserServiceKey(key string, opts ...Option) (*API, error)

NewWithUserServiceKey creates a new Cloudflare v4 API client using service key authentication.

func (*API) AccessApplication added in v0.9.0

func (api *API) AccessApplication(zoneID, applicationID string) (AccessApplication, error)

AccessApplication returns a single application based on the application ID.

API reference: https://api.cloudflare.com/#access-applications-access-applications-details

func (*API) AccessApplications added in v0.9.0

func (api *API) AccessApplications(zoneID string, pageOpts PaginationOptions) ([]AccessApplication, ResultInfo, error)

AccessApplications returns all applications within a zone.

API reference: https://api.cloudflare.com/#access-applications-list-access-applications

func (*API) AccessPolicies added in v0.9.0

func (api *API) AccessPolicies(zoneID, applicationID string, pageOpts PaginationOptions) ([]AccessPolicy, ResultInfo, error)

AccessPolicies returns all access policies for an access application.

API reference: https://api.cloudflare.com/#access-policy-list-access-policies

func (*API) AccessPolicy added in v0.9.0

func (api *API) AccessPolicy(zoneID, applicationID, policyID string) (AccessPolicy, error)

AccessPolicy returns a single policy based on the policy ID.

API reference: https://api.cloudflare.com/#access-policy-access-policy-details

func (*API) Account added in v0.9.0

func (api *API) Account(accountID string) (Account, ResultInfo, error)

Account returns a single account based on the ID.

API reference: https://api.cloudflare.com/#accounts-account-details

func (*API) AccountAccessRule added in v0.10.0

func (api *API) AccountAccessRule(accountID string, accessRuleID string) (*AccessRuleResponse, error)

AccountAccessRule returns the details of an account's access rule.

API reference: https://api.cloudflare.com/#account-level-firewall-access-rule-access-rule-details

func (*API) AccountMember added in v0.9.0

func (api *API) AccountMember(accountID string, memberID string) (AccountMember, error)

AccountMember returns details of a single account member.

API reference: https://api.cloudflare.com/#account-members-member-details

func (*API) AccountMembers added in v0.9.0

func (api *API) AccountMembers(accountID string, pageOpts PaginationOptions) ([]AccountMember, ResultInfo, error)

AccountMembers returns all members of an account.

API reference: https://api.cloudflare.com/#accounts-list-accounts

func (*API) AccountRole added in v0.9.0

func (api *API) AccountRole(accountID string, roleID string) (AccountRole, error)

AccountRole returns the details of a single account role.

API reference: https://api.cloudflare.com/#account-roles-role-details

func (*API) AccountRoles added in v0.9.0

func (api *API) AccountRoles(accountID string) ([]AccountRole, error)

AccountRoles returns all roles of an account.

API reference: https://api.cloudflare.com/#account-roles-list-roles

func (*API) Accounts added in v0.9.0

func (api *API) Accounts(pageOpts PaginationOptions) ([]Account, ResultInfo, error)

Accounts returns all accounts the logged in user has access to.

API reference: https://api.cloudflare.com/#accounts-list-accounts

func (*API) ArgoSmartRouting added in v0.9.0

func (api *API) ArgoSmartRouting(zoneID string) (ArgoFeatureSetting, error)

ArgoSmartRouting returns the current settings for smart routing.

API reference: https://api.cloudflare.com/#argo-smart-routing-get-argo-smart-routing-setting

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	smartRoutingSettings, err := api.ArgoSmartRouting("01a7362d577a6c3019a474fd6f485823")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("smart routing is %s", smartRoutingSettings.Value)
}
Output:

func (*API) ArgoTieredCaching added in v0.9.0

func (api *API) ArgoTieredCaching(zoneID string) (ArgoFeatureSetting, error)

ArgoTieredCaching returns the current settings for tiered caching.

API reference: TBA

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	tieredCachingSettings, err := api.ArgoTieredCaching("01a7362d577a6c3019a474fd6f485823")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("tiered caching is %s", tieredCachingSettings.Value)
}
Output:

func (*API) AvailableZonePlans added in v0.7.2

func (api *API) AvailableZonePlans(zoneID string) ([]ZonePlan, error)

AvailableZonePlans returns information about all plans available to the specified zone.

API reference: https://api.cloudflare.com/#zone-rate-plan-list-available-plans

func (*API) AvailableZoneRatePlans added in v0.7.4

func (api *API) AvailableZoneRatePlans(zoneID string) ([]ZoneRatePlan, error)

AvailableZoneRatePlans returns information about all plans available to the specified zone.

API reference: https://api.cloudflare.com/#zone-plan-available-plans

func (*API) CancelRegistrarDomainTransfer added in v0.9.0

func (api *API) CancelRegistrarDomainTransfer(accountID, domainName string) ([]RegistrarDomain, error)

CancelRegistrarDomainTransfer cancels a pending domain transfer.

API reference: https://api.cloudflare.com/#registrar-domains-cancel-transfer

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

domains, err := api.CancelRegistrarDomainTransfer("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")

fmt.Printf("%+v\n", domains)
Output:

func (*API) ChangePageRule added in v0.7.2

func (api *API) ChangePageRule(zoneID, ruleID string, rule PageRule) error

ChangePageRule lets you change individual settings for a Page Rule. This is in contrast to UpdatePageRule which replaces the entire Page Rule.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-change-a-page-rule

func (*API) CheckLogpushDestinationExists added in v0.9.0

func (api *API) CheckLogpushDestinationExists(zoneID, destinationConf string) (bool, error)

CheckLogpushDestinationExists returns destination exists check result.

API reference: https://api.cloudflare.com/#logpush-jobs-check-destination-exists

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

exists, err := api.CheckLogpushDestinationExists(zoneID, "destination_conf")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", exists)
Output:

func (*API) ConnectZoneRailgun added in v0.7.2

func (api *API) ConnectZoneRailgun(zoneID, railgunID string) (ZoneRailgun, error)

ConnectZoneRailgun connects a Railgun for a given zone.

API reference: https://api.cloudflare.com/#railguns-for-a-zone-connect-or-disconnect-a-railgun

func (*API) CreateAccessApplication added in v0.9.0

func (api *API) CreateAccessApplication(zoneID string, accessApplication AccessApplication) (AccessApplication, error)

CreateAccessApplication creates a new access application.

API reference: https://api.cloudflare.com/#access-applications-create-access-application

func (*API) CreateAccessPolicy added in v0.9.0

func (api *API) CreateAccessPolicy(zoneID, applicationID string, accessPolicy AccessPolicy) (AccessPolicy, error)

CreateAccessPolicy creates a new access policy.

API reference: https://api.cloudflare.com/#access-policy-create-access-policy

func (*API) CreateAccountAccessRule added in v0.10.0

func (api *API) CreateAccountAccessRule(accountID string, accessRule AccessRule) (*AccessRuleResponse, error)

CreateAccountAccessRule creates a firewall access rule for the given account identifier.

API reference: https://api.cloudflare.com/#account-level-firewall-access-rule-create-access-rule

func (*API) CreateAccountMember added in v0.9.0

func (api *API) CreateAccountMember(accountID string, emailAddress string, roles []string) (AccountMember, error)

CreateAccountMember invites a new member to join an account.

API reference: https://api.cloudflare.com/#account-members-add-member

func (*API) CreateCustomHostname added in v0.7.4

func (api *API) CreateCustomHostname(zoneID string, ch CustomHostname) (*CustomHostnameResponse, error)

CreateCustomHostname creates a new custom hostname and requests that an SSL certificate be issued for it.

API reference: https://api.cloudflare.com/#custom-hostname-for-a-zone-create-custom-hostname

func (*API) CreateDNSRecord added in v0.7.2

func (api *API) CreateDNSRecord(zoneID string, rr DNSRecord) (*DNSRecordResponse, error)

CreateDNSRecord creates a DNS record for the zone identifier.

API reference: https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record

func (*API) CreateFilters added in v0.9.0

func (api *API) CreateFilters(zoneID string, filters []Filter) ([]Filter, error)

CreateFilters creates new filters.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/post/

func (*API) CreateFirewallRules added in v0.9.0

func (api *API) CreateFirewallRules(zoneID string, firewallRules []FirewallRule) ([]FirewallRule, error)

CreateFirewallRules creates new firewall rules.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/post/

func (*API) CreateKeyless added in v0.7.2

func (api *API) CreateKeyless()

CreateKeyless creates a new Keyless SSL configuration for the zone.

API reference: https://api.cloudflare.com/#keyless-ssl-for-a-zone-create-a-keyless-ssl-configuration

func (*API) CreateLoadBalancer added in v0.8.0

func (api *API) CreateLoadBalancer(zoneID string, lb LoadBalancer) (LoadBalancer, error)

CreateLoadBalancer creates a new load balancer.

API reference: https://api.cloudflare.com/#load-balancers-create-a-load-balancer

func (*API) CreateLoadBalancerMonitor added in v0.8.0

func (api *API) CreateLoadBalancerMonitor(monitor LoadBalancerMonitor) (LoadBalancerMonitor, error)

CreateLoadBalancerMonitor creates a new load balancer monitor.

API reference: https://api.cloudflare.com/#load-balancer-monitors-create-a-monitor

func (*API) CreateLoadBalancerPool added in v0.8.0

func (api *API) CreateLoadBalancerPool(pool LoadBalancerPool) (LoadBalancerPool, error)

CreateLoadBalancerPool creates a new load balancer pool.

API reference: https://api.cloudflare.com/#load-balancer-pools-create-a-pool

func (*API) CreateLogpushJob added in v0.9.0

func (api *API) CreateLogpushJob(zoneID string, job LogpushJob) (*LogpushJob, error)

CreateLogpushJob creates a new LogpushJob for a zone.

API reference: https://api.cloudflare.com/#logpush-jobs-create-logpush-job

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

job, err := api.CreateLogpushJob(zoneID, exampleNewLogpushJob)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", job)
Output:

func (*API) CreateOriginCertificate added in v0.7.4

func (api *API) CreateOriginCertificate(certificate OriginCACertificate) (*OriginCACertificate, error)

CreateOriginCertificate creates a Cloudflare-signed certificate.

This function requires api.APIUserServiceKey be set to your Certificates API key.

API reference: https://api.cloudflare.com/#cloudflare-ca-create-certificate

func (*API) CreatePageRule added in v0.7.2

func (api *API) CreatePageRule(zoneID string, rule PageRule) (*PageRule, error)

CreatePageRule creates a new Page Rule for a zone.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-create-a-page-rule

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

pageRule, err := api.CreatePageRule(zoneID, exampleNewPageRule)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", pageRule)
Output:

func (*API) CreateRailgun added in v0.7.2

func (api *API) CreateRailgun(name string) (Railgun, error)

CreateRailgun creates a new Railgun.

API reference: https://api.cloudflare.com/#railgun-create-railgun

func (*API) CreateRateLimit added in v0.8.5

func (api *API) CreateRateLimit(zoneID string, limit RateLimit) (RateLimit, error)

CreateRateLimit creates a new rate limit for a zone.

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-create-a-ratelimit

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

rateLimit, err := api.CreateRateLimit(zoneID, exampleNewRateLimit)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", rateLimit)
Output:

func (*API) CreateSSL added in v0.7.2

func (api *API) CreateSSL(zoneID string, options ZoneCustomSSLOptions) (ZoneCustomSSL, error)

CreateSSL allows you to add a custom SSL certificate to the given zone.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-create-ssl-configuration

func (*API) CreateSpectrumApplication added in v0.9.0

func (api *API) CreateSpectrumApplication(zoneID string, appDetails SpectrumApplication) (SpectrumApplication, error)

CreateSpectrumApplication creates a new Spectrum application.

API reference: https://developers.cloudflare.com/spectrum/api-reference/#create-a-spectrum-application

func (*API) CreateUserAccessRule added in v0.8.1

func (api *API) CreateUserAccessRule(accessRule AccessRule) (*AccessRuleResponse, error)

CreateUserAccessRule creates a firewall access rule for the logged-in user.

API reference: https://api.cloudflare.com/#user-level-firewall-access-rule-create-access-rule

func (*API) CreateUserAgentRule added in v0.8.0

func (api *API) CreateUserAgentRule(zoneID string, ld UserAgentRule) (*UserAgentRuleResponse, error)

CreateUserAgentRule creates a User-Agent Block rule for the given zone ID.

API reference: https://api.cloudflare.com/#user-agent-blocking-rules-create-a-useragent-rule

func (*API) CreateVirtualDNS added in v0.7.2

func (api *API) CreateVirtualDNS(v *VirtualDNS) (*VirtualDNS, error)

CreateVirtualDNS creates a new Virtual DNS cluster.

API reference: https://api.cloudflare.com/#virtual-dns-users--create-a-virtual-dns-cluster

func (*API) CreateWorkerRoute added in v0.9.0

func (api *API) CreateWorkerRoute(zoneID string, route WorkerRoute) (WorkerRouteResponse, error)

CreateWorkerRoute creates worker route for a zone

API reference: https://api.cloudflare.com/#worker-filters-create-filter

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}
route := cloudflare.WorkerRoute{Pattern: "app1.example.com/*", Enabled: true}
res, err := api.CreateWorkerRoute(zoneID, route)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)
Output:

func (*API) CreateWorkersKVNamespace added in v0.9.0

func (api *API) CreateWorkersKVNamespace(ctx context.Context, req *WorkersKVNamespaceRequest) (WorkersKVNamespaceResponse, error)

CreateWorkersKVNamespace creates a namespace under the given title. A 400 is returned if the account already owns a namespace with this title. A namespace must be explicitly deleted to be replaced.

API reference: https://api.cloudflare.com/#workers-kv-namespace-create-a-namespace

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

req := &cloudflare.WorkersKVNamespaceRequest{Title: "test_namespace2"}
response, err := api.CreateWorkersKVNamespace(context.Background(), req)
if err != nil {
	log.Fatal(err)
}

fmt.Println(response)
Output:

func (*API) CreateZone added in v0.7.2

func (api *API) CreateZone(name string, jumpstart bool, account Account, zoneType string) (Zone, error)

CreateZone creates a zone on an account.

Setting jumpstart to true will attempt to automatically scan for existing DNS records. Setting this to false will create the zone with no DNS records.

If account is non-empty, it must have at least the ID field populated. This will add the new zone to the specified multi-user account.

API reference: https://api.cloudflare.com/#zone-create-a-zone

func (*API) CreateZoneAccessRule added in v0.8.1

func (api *API) CreateZoneAccessRule(zoneID string, accessRule AccessRule) (*AccessRuleResponse, error)

CreateZoneAccessRule creates a firewall access rule for the given zone identifier.

API reference: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-create-access-rule

func (*API) CreateZoneLockdown added in v0.8.0

func (api *API) CreateZoneLockdown(zoneID string, ld ZoneLockdown) (*ZoneLockdownResponse, error)

CreateZoneLockdown creates a Zone ZoneLockdown rule for the given zone ID.

API reference: https://api.cloudflare.com/#zone-ZoneLockdown-create-a-ZoneLockdown-rule

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.org")
	if err != nil {
		log.Fatal(err)
	}

	newZoneLockdown := cloudflare.ZoneLockdown{
		Description: "Test Zone Lockdown Rule",
		URLs: []string{
			"*.example.org/test",
		},
		Configurations: []cloudflare.ZoneLockdownConfig{
			cloudflare.ZoneLockdownConfig{
				Target: "ip",
				Value:  "127.0.0.1",
			},
		},
		Paused:   false,
		Priority: 1,
	}

	response, err := api.CreateZoneLockdown(zoneID, newZoneLockdown)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Response: ", response)
}
Output:

func (*API) CustomHostname added in v0.7.4

func (api *API) CustomHostname(zoneID string, customHostnameID string) (CustomHostname, error)

CustomHostname inspects the given custom hostname in the given zone.

API reference: https://api.cloudflare.com/#custom-hostname-for-a-zone-custom-hostname-configuration-details

func (*API) CustomHostnameIDByName added in v0.7.4

func (api *API) CustomHostnameIDByName(zoneID string, hostname string) (string, error)

CustomHostnameIDByName retrieves the ID for the given hostname in the given zone.

func (*API) CustomHostnames added in v0.7.4

func (api *API) CustomHostnames(zoneID string, page int, filter CustomHostname) ([]CustomHostname, ResultInfo, error)

CustomHostnames fetches custom hostnames for the given zone, by applying filter.Hostname if not empty and scoping the result to page'th 50 items.

The returned ResultInfo can be used to implement pagination.

API reference: https://api.cloudflare.com/#custom-hostname-for-a-zone-list-custom-hostnames

func (*API) CustomPage added in v0.9.0

func (api *API) CustomPage(options *CustomPageOptions, customPageID string) (CustomPage, error)

CustomPage lists a single custom page based on the ID.

Zone API reference: https://api.cloudflare.com/#custom-pages-for-a-zone-custom-page-details Account API reference: https://api.cloudflare.com/#custom-pages-account--custom-page-details

func (*API) CustomPages added in v0.9.0

func (api *API) CustomPages(options *CustomPageOptions) ([]CustomPage, error)

CustomPages lists custom pages for a zone or account.

Zone API reference: https://api.cloudflare.com/#custom-pages-for-a-zone-list-available-custom-pages Account API reference: https://api.cloudflare.com/#custom-pages-account--list-custom-pages

func (*API) DNSRecord added in v0.7.2

func (api *API) DNSRecord(zoneID, recordID string) (DNSRecord, error)

DNSRecord returns a single DNS record for the given zone & record identifiers.

API reference: https://api.cloudflare.com/#dns-records-for-a-zone-dns-record-details

func (*API) DNSRecords added in v0.7.2

func (api *API) DNSRecords(zoneID string, rr DNSRecord) ([]DNSRecord, error)

DNSRecords returns a slice of DNS records for the given zone identifier.

This takes a DNSRecord to allow filtering of the results returned.

API reference: https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records

Example (All)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch all records for a zone
	recs, err := api.DNSRecords(zoneID, cloudflare.DNSRecord{})
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range recs {
		fmt.Printf("%s: %s\n", r.Name, r.Content)
	}
}
Output:

Example (FilterByContent)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch only records whose content is 127.0.0.1
	localhost := cloudflare.DNSRecord{Content: "127.0.0.1"}
	recs, err := api.DNSRecords(zoneID, localhost)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range recs {
		fmt.Printf("%s: %s\n", r.Name, r.Content)
	}
}
Output:

Example (FilterByName)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch records of any type with name "foo.example.com"
	// The name must be fully-qualified
	foo := cloudflare.DNSRecord{Name: "foo.example.com"}
	recs, err := api.DNSRecords(zoneID, foo)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range recs {
		fmt.Printf("%s: %s\n", r.Name, r.Content)
	}
}
Output:

Example (FilterByType)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch only AAAA type records
	aaaa := cloudflare.DNSRecord{Type: "AAAA"}
	recs, err := api.DNSRecords(zoneID, aaaa)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range recs {
		fmt.Printf("%s: %s\n", r.Name, r.Content)
	}
}
Output:

func (*API) DeleteAccessApplication added in v0.9.0

func (api *API) DeleteAccessApplication(zoneID, applicationID string) error

DeleteAccessApplication deletes an access application.

API reference: https://api.cloudflare.com/#access-applications-delete-access-application

func (*API) DeleteAccessPolicy added in v0.9.0

func (api *API) DeleteAccessPolicy(zoneID, applicationID, accessPolicyID string) error

DeleteAccessPolicy deletes an access policy.

API reference: https://api.cloudflare.com/#access-policy-update-access-policy

func (*API) DeleteAccountAccessRule added in v0.10.0

func (api *API) DeleteAccountAccessRule(accountID, accessRuleID string) (*AccessRuleResponse, error)

DeleteAccountAccessRule deletes a single access rule for the given account and access rule identifiers.

API reference: https://api.cloudflare.com/#account-level-firewall-access-rule-delete-access-rule

func (*API) DeleteAccountMember added in v0.9.0

func (api *API) DeleteAccountMember(accountID string, userID string) error

DeleteAccountMember removes a member from an account.

API reference: https://api.cloudflare.com/#account-members-remove-member

func (*API) DeleteCustomHostname added in v0.7.4

func (api *API) DeleteCustomHostname(zoneID string, customHostnameID string) error

DeleteCustomHostname deletes a custom hostname (and any issued SSL certificates).

API reference: https://api.cloudflare.com/#custom-hostname-for-a-zone-delete-a-custom-hostname-and-any-issued-ssl-certificates-

func (*API) DeleteDNSRecord added in v0.7.2

func (api *API) DeleteDNSRecord(zoneID, recordID string) error

DeleteDNSRecord deletes a single DNS record for the given zone & record identifiers.

API reference: https://api.cloudflare.com/#dns-records-for-a-zone-delete-dns-record

func (*API) DeleteFilter added in v0.9.0

func (api *API) DeleteFilter(zoneID, filterID string) error

DeleteFilter deletes a single filter.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/delete/#delete-a-single-filter

func (*API) DeleteFilters added in v0.9.0

func (api *API) DeleteFilters(zoneID string, filterIDs []string) error

DeleteFilters deletes multiple filters.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/delete/#delete-multiple-filters

func (*API) DeleteFirewallRule added in v0.9.0

func (api *API) DeleteFirewallRule(zoneID, firewallRuleID string) error

DeleteFirewallRule updates a single firewall rule.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/delete/#delete-a-single-rule

func (*API) DeleteFirewallRules added in v0.9.0

func (api *API) DeleteFirewallRules(zoneID string, firewallRuleIDs []string) error

DeleteFirewallRules updates a single firewall rule.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/delete/#delete-multiple-rules

func (*API) DeleteKeyless added in v0.7.2

func (api *API) DeleteKeyless()

DeleteKeyless deletes an existing Keyless SSL configuration.

API reference: https://api.cloudflare.com/#keyless-ssl-for-a-zone-delete-keyless-configuration

func (*API) DeleteLoadBalancer added in v0.8.0

func (api *API) DeleteLoadBalancer(zoneID, lbID string) error

DeleteLoadBalancer disables and deletes a load balancer.

API reference: https://api.cloudflare.com/#load-balancers-delete-a-load-balancer

func (*API) DeleteLoadBalancerMonitor added in v0.8.0

func (api *API) DeleteLoadBalancerMonitor(monitorID string) error

DeleteLoadBalancerMonitor disables and deletes a load balancer monitor.

API reference: https://api.cloudflare.com/#load-balancer-monitors-delete-a-monitor

func (*API) DeleteLoadBalancerPool added in v0.8.0

func (api *API) DeleteLoadBalancerPool(poolID string) error

DeleteLoadBalancerPool disables and deletes a load balancer pool.

API reference: https://api.cloudflare.com/#load-balancer-pools-delete-a-pool

func (*API) DeleteLogpushJob added in v0.9.0

func (api *API) DeleteLogpushJob(zoneID string, jobID int) error

DeleteLogpushJob deletes a Logpush Job for a zone.

API reference: https://api.cloudflare.com/#logpush-jobs-delete-logpush-job

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

err = api.DeleteLogpushJob(zoneID, 1)
if err != nil {
	log.Fatal(err)
}
Output:

func (*API) DeletePageRule added in v0.7.2

func (api *API) DeletePageRule(zoneID, ruleID string) error

DeletePageRule deletes a Page Rule for a zone.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-delete-a-page-rule

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

err = api.DeletePageRule(zoneID, "my_page_rule_id")
if err != nil {
	log.Fatal(err)
}
Output:

func (*API) DeleteRailgun added in v0.7.2

func (api *API) DeleteRailgun(railgunID string) error

DeleteRailgun disables and deletes a Railgun.

API reference: https://api.cloudflare.com/#railgun-delete-railgun

func (*API) DeleteRateLimit added in v0.8.5

func (api *API) DeleteRateLimit(zoneID, limitID string) error

DeleteRateLimit deletes a Rate Limit for a zone.

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-delete-rate-limit

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

err = api.DeleteRateLimit(zoneID, "my_rate_limit_id")
if err != nil {
	log.Fatal(err)
}
Output:

func (*API) DeleteSSL added in v0.7.2

func (api *API) DeleteSSL(zoneID, certificateID string) error

DeleteSSL deletes a custom SSL certificate from the given zone.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-delete-an-ssl-certificate

func (*API) DeleteSpectrumApplication added in v0.9.0

func (api *API) DeleteSpectrumApplication(zoneID string, applicationID string) error

DeleteSpectrumApplication removes a Spectrum application based on the ID.

API reference: https://developers.cloudflare.com/spectrum/api-reference/#delete-a-spectrum-application

func (*API) DeleteUserAccessRule added in v0.8.1

func (api *API) DeleteUserAccessRule(accessRuleID string) (*AccessRuleResponse, error)

DeleteUserAccessRule deletes a single access rule for the logged-in user and access rule identifiers.

API reference: https://api.cloudflare.com/#user-level-firewall-access-rule-update-access-rule

func (*API) DeleteUserAgentRule added in v0.8.0

func (api *API) DeleteUserAgentRule(zoneID string, id string) (*UserAgentRuleResponse, error)

DeleteUserAgentRule deletes a User-Agent Block rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#user-agent-blocking-rules-delete-useragent-rule

func (*API) DeleteVirtualDNS added in v0.7.2

func (api *API) DeleteVirtualDNS(virtualDNSID string) error

DeleteVirtualDNS deletes a Virtual DNS cluster. Note that this cannot be undone, and will stop all traffic to that cluster.

API reference: https://api.cloudflare.com/#virtual-dns-users--delete-a-virtual-dns-cluster

func (*API) DeleteWorker added in v0.9.0

func (api *API) DeleteWorker(requestParams *WorkerRequestParams) (WorkerScriptResponse, error)

DeleteWorker deletes worker for a zone.

API reference: https://api.cloudflare.com/#worker-script-delete-worker

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}
res, err := api.DeleteWorker(&cloudflare.WorkerRequestParams{ZoneID: zoneID})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)

DeleteWorkerWithName()
Output:

func (*API) DeleteWorkerRoute added in v0.9.0

func (api *API) DeleteWorkerRoute(zoneID string, routeID string) (WorkerRouteResponse, error)

DeleteWorkerRoute deletes worker route for a zone

API reference: https://api.cloudflare.com/#worker-filters-delete-filter

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}
// pull from existing list of routes to perform delete on
routesResponse, err := api.ListWorkerRoutes(zoneID)
if err != nil {
	log.Fatal(err)
}
// delete first route retrieved from the listWorkerRoutes call
res, err := api.DeleteWorkerRoute(zoneID, routesResponse.Routes[0].ID)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)
Output:

func (API) DeleteWorkersKV added in v0.9.0

func (api API) DeleteWorkersKV(ctx context.Context, namespaceID, key string) (Response, error)

DeleteWorkersKV deletes a key and value for a provided storage namespace

API reference: https://api.cloudflare.com/#workers-kv-namespace-delete-key-value-pair

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

key := "test_key"
resp, err := api.DeleteWorkersKV(context.Background(), namespace, key)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", resp)
Output:

func (*API) DeleteWorkersKVNamespace added in v0.9.0

func (api *API) DeleteWorkersKVNamespace(ctx context.Context, namespaceID string) (Response, error)

DeleteWorkersKVNamespace deletes the namespace corresponding to the given ID

API reference: https://api.cloudflare.com/#workers-kv-namespace-remove-a-namespace

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

response, err := api.DeleteWorkersKVNamespace(context.Background(), namespace)
if err != nil {
	log.Fatal(err)
}

fmt.Println(response)
Output:

func (*API) DeleteZone added in v0.7.2

func (api *API) DeleteZone(zoneID string) (ZoneID, error)

DeleteZone deletes the given zone.

API reference: https://api.cloudflare.com/#zone-delete-a-zone

func (*API) DeleteZoneAccessRule added in v0.8.1

func (api *API) DeleteZoneAccessRule(zoneID, accessRuleID string) (*AccessRuleResponse, error)

DeleteZoneAccessRule deletes a single access rule for the given zone and access rule identifiers.

API reference: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-delete-access-rule

func (*API) DeleteZoneLockdown added in v0.8.0

func (api *API) DeleteZoneLockdown(zoneID string, id string) (*ZoneLockdownResponse, error)

DeleteZoneLockdown deletes a Zone ZoneLockdown rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#zone-ZoneLockdown-delete-ZoneLockdown-rule

func (*API) DisableRailgun added in v0.7.2

func (api *API) DisableRailgun(railgunID string) (Railgun, error)

DisableRailgun enables a Railgun for all zones connected to it.

API reference: https://api.cloudflare.com/#railgun-enable-or-disable-a-railgun

func (*API) DisconnectZoneRailgun added in v0.7.2

func (api *API) DisconnectZoneRailgun(zoneID, railgunID string) (ZoneRailgun, error)

DisconnectZoneRailgun disconnects a Railgun for a given zone.

API reference: https://api.cloudflare.com/#railguns-for-a-zone-connect-or-disconnect-a-railgun

func (*API) DownloadWorker added in v0.9.0

func (api *API) DownloadWorker(requestParams *WorkerRequestParams) (WorkerScriptResponse, error)

DownloadWorker fetch raw script content for your worker returns []byte containing worker code js

API reference: https://api.cloudflare.com/#worker-script-download-worker

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

res, err := api.DownloadWorker(&cloudflare.WorkerRequestParams{ZoneID: zoneID})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)

DownloadWorkerWithName()
Output:

func (*API) EditUniversalSSLSetting added in v0.9.0

func (api *API) EditUniversalSSLSetting(zoneID string, setting UniversalSSLSetting) (UniversalSSLSetting, error)

EditUniversalSSLSetting edits the uniersal ssl setting for a zone

API reference: https://api.cloudflare.com/#universal-ssl-settings-for-a-zone-edit-universal-ssl-settings

func (*API) EditZone added in v0.7.2

func (api *API) EditZone(zoneID string, zoneOpts ZoneOptions) (Zone, error)

EditZone edits the given zone.

This is usually called by ZoneSetPaused, ZoneSetVanityNS or ZoneSetPlan.

API reference: https://api.cloudflare.com/#zone-edit-zone-properties

func (*API) EnableRailgun added in v0.7.2

func (api *API) EnableRailgun(railgunID string) (Railgun, error)

EnableRailgun enables a Railgun for all zones connected to it.

API reference: https://api.cloudflare.com/#railgun-enable-or-disable-a-railgun

func (*API) Filter added in v0.9.0

func (api *API) Filter(zoneID, filterID string) (Filter, error)

Filter returns a single filter in a zone based on the filter ID.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/get/#get-by-filter-id

func (*API) Filters added in v0.9.0

func (api *API) Filters(zoneID string, pageOpts PaginationOptions) ([]Filter, error)

Filters returns all filters for a zone.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/get/#get-all-filters

func (*API) FirewallRule added in v0.9.0

func (api *API) FirewallRule(zoneID, firewallRuleID string) (FirewallRule, error)

FirewallRule returns a single firewall rule based on the ID.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/get/#get-by-rule-id

func (*API) FirewallRules added in v0.9.0

func (api *API) FirewallRules(zoneID string, pageOpts PaginationOptions) ([]FirewallRule, error)

FirewallRules returns all firewall rules.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/get/#get-all-rules

func (*API) GetLogpushOwnershipChallenge added in v0.9.0

func (api *API) GetLogpushOwnershipChallenge(zoneID, destinationConf string) (*LogpushGetOwnershipChallenge, error)

GetLogpushOwnershipChallenge returns ownership challenge.

API reference: https://api.cloudflare.com/#logpush-jobs-get-ownership-challenge

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

ownershipChallenge, err := api.GetLogpushOwnershipChallenge(zoneID, "destination_conf")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", ownershipChallenge)
Output:

func (*API) GetOrganizationAuditLogs added in v0.9.0

func (api *API) GetOrganizationAuditLogs(organizationID string, a AuditLogFilter) (AuditLogResponse, error)

GetOrganizationAuditLogs will return the audit logs of a specific organization, based on the ID passed in. The audit logs can be filtered based on any argument in the AuditLogFilter

API Reference: https://api.cloudflare.com/#audit-logs-list-organization-audit-logs

func (*API) GetUserAuditLogs added in v0.9.0

func (api *API) GetUserAuditLogs(a AuditLogFilter) (AuditLogResponse, error)

GetUserAuditLogs will return your user's audit logs. The audit logs can be filtered based on any argument in the AuditLogFilter

API Reference: https://api.cloudflare.com/#audit-logs-list-user-audit-logs

func (*API) Keyless added in v0.7.2

func (api *API) Keyless()

Keyless provides the configuration for a given Keyless SSL identifier.

API reference: https://api.cloudflare.com/#keyless-ssl-for-a-zone-keyless-ssl-details

func (*API) ListAccountAccessRules added in v0.10.0

func (api *API) ListAccountAccessRules(accountID string, accessRule AccessRule, page int) (*AccessRuleListResponse, error)

ListAccountAccessRules returns a slice of access rules for the given account identifier.

This takes an AccessRule to allow filtering of the results returned.

API reference: https://api.cloudflare.com/#account-level-firewall-access-rule-list-access-rules

func (*API) ListAllRateLimits added in v0.8.5

func (api *API) ListAllRateLimits(zoneID string) ([]RateLimit, error)

ListAllRateLimits returns all Rate Limits for a zone.

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-list-rate-limits

func (*API) ListKeyless added in v0.7.2

func (api *API) ListKeyless()

ListKeyless lists Keyless SSL configurations for a zone.

API reference: https://api.cloudflare.com/#keyless-ssl-for-a-zone-list-keyless-ssls

func (*API) ListLoadBalancerMonitors added in v0.8.0

func (api *API) ListLoadBalancerMonitors() ([]LoadBalancerMonitor, error)

ListLoadBalancerMonitors lists load balancer monitors connected to an account.

API reference: https://api.cloudflare.com/#load-balancer-monitors-list-monitors

func (*API) ListLoadBalancerPools added in v0.8.0

func (api *API) ListLoadBalancerPools() ([]LoadBalancerPool, error)

ListLoadBalancerPools lists load balancer pools connected to an account.

API reference: https://api.cloudflare.com/#load-balancer-pools-list-pools

func (*API) ListLoadBalancers added in v0.8.0

func (api *API) ListLoadBalancers(zoneID string) ([]LoadBalancer, error)

ListLoadBalancers lists load balancers configured on a zone.

API reference: https://api.cloudflare.com/#load-balancers-list-load-balancers

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	// Construct a new API object.
	api, err := cloudflare.New("deadbeef", "test@example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch the zone ID.
	id, err := api.ZoneIDByName("example.com") // Assuming example.com exists in your Cloudflare account
	if err != nil {
		log.Fatal(err)
	}

	// List LBs configured in zone.
	lbList, err := api.ListLoadBalancers(id)
	if err != nil {
		log.Fatal(err)
	}

	for _, lb := range lbList {
		fmt.Println(lb)
	}
}
Output:

func (*API) ListPageRules added in v0.7.2

func (api *API) ListPageRules(zoneID string) ([]PageRule, error)

ListPageRules returns all Page Rules for a zone.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-list-page-rules

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

pageRules, err := api.ListPageRules(zoneID)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", pageRules)
for _, r := range pageRules {
	fmt.Printf("%+v\n", r)
}
Output:

func (*API) ListRailguns added in v0.7.2

func (api *API) ListRailguns(options RailgunListOptions) ([]Railgun, error)

ListRailguns lists Railguns connected to an account.

API reference: https://api.cloudflare.com/#railgun-list-railguns

func (*API) ListRateLimits added in v0.8.5

func (api *API) ListRateLimits(zoneID string, pageOpts PaginationOptions) ([]RateLimit, ResultInfo, error)

ListRateLimits returns Rate Limits for a zone, paginated according to the provided options

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-list-rate-limits

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

pageOpts := cloudflare.PaginationOptions{
	PerPage: 5,
	Page:    1,
}
rateLimits, _, err := api.ListRateLimits(zoneID, pageOpts)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", rateLimits)
for _, r := range rateLimits {
	fmt.Printf("%+v\n", r)
}
Output:

func (*API) ListSSL added in v0.7.2

func (api *API) ListSSL(zoneID string) ([]ZoneCustomSSL, error)

ListSSL lists the custom certificates for the given zone.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-list-ssl-configurations

func (*API) ListUserAccessRules added in v0.8.1

func (api *API) ListUserAccessRules(accessRule AccessRule, page int) (*AccessRuleListResponse, error)

ListUserAccessRules returns a slice of access rules for the logged-in user.

This takes an AccessRule to allow filtering of the results returned.

API reference: https://api.cloudflare.com/#user-level-firewall-access-rule-list-access-rules

func (*API) ListUserAgentRules added in v0.8.0

func (api *API) ListUserAgentRules(zoneID string, page int) (*UserAgentRuleListResponse, error)

ListUserAgentRules retrieves a list of User-Agent Block rules for a given zone ID by page number.

API reference: https://api.cloudflare.com/#user-agent-blocking-rules-list-useragent-rules

Example (All)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch all Zone Lockdown rules for a zone, by page.
	rules, err := api.ListUserAgentRules(zoneID, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range rules.Result {
		fmt.Printf("%s: %s\n", r.Configuration.Target, r.Configuration.Value)
	}
}
Output:

func (*API) ListVirtualDNS added in v0.7.2

func (api *API) ListVirtualDNS() ([]*VirtualDNS, error)

ListVirtualDNS lists the virtual DNS clusters associated with an account.

API reference: https://api.cloudflare.com/#virtual-dns-users--get-virtual-dns-clusters

func (*API) ListWAFGroups added in v0.10.0

func (api *API) ListWAFGroups(zoneID, packageID string) ([]WAFGroup, error)

ListWAFGroups returns a slice of the WAF groups for the given WAF package.

API Reference: https://api.cloudflare.com/#waf-rule-groups-list-rule-groups

func (*API) ListWAFPackages added in v0.7.2

func (api *API) ListWAFPackages(zoneID string) ([]WAFPackage, error)

ListWAFPackages returns a slice of the WAF packages for the given zone.

API Reference: https://api.cloudflare.com/#waf-rule-packages-list-firewall-packages

func (*API) ListWAFRules added in v0.7.2

func (api *API) ListWAFRules(zoneID, packageID string) ([]WAFRule, error)

ListWAFRules returns a slice of the WAF rules for the given WAF package.

API Reference: https://api.cloudflare.com/#waf-rules-list-rules

func (*API) ListWorkerRoutes added in v0.9.0

func (api *API) ListWorkerRoutes(zoneID string) (WorkerRoutesResponse, error)

ListWorkerRoutes returns list of worker routes

API reference: https://api.cloudflare.com/#worker-filters-list-filters

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}
res, err := api.ListWorkerRoutes(zoneID)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)
Output:

func (*API) ListWorkerScripts added in v0.9.0

func (api *API) ListWorkerScripts() (WorkerListResponse, error)

ListWorkerScripts returns list of worker scripts for given account.

This is an enterprise only feature https://developers.cloudflare.com/workers/api/config-api-for-enterprise

API reference: https://developers.cloudflare.com/workers/api/config-api-for-enterprise/

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount("foo"))
if err != nil {
	log.Fatal(err)
}

res, err := api.ListWorkerScripts()
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res.WorkerList)
Output:

func (*API) ListWorkersKVNamespaces added in v0.9.0

func (api *API) ListWorkersKVNamespaces(ctx context.Context) (ListWorkersKVNamespacesResponse, error)

ListWorkersKVNamespaces lists storage namespaces

API reference: https://api.cloudflare.com/#workers-kv-namespace-list-namespaces

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

lsr, err := api.ListWorkersKVNamespaces(context.Background())
if err != nil {
	log.Fatal(err)
}

fmt.Println(lsr)
Output:

func (API) ListWorkersKVs added in v0.9.0

func (api API) ListWorkersKVs(ctx context.Context, namespaceID string) (ListStorageKeysResponse, error)

ListWorkersKVs lists a namespace's keys

API Reference: https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

resp, err := api.ListWorkersKVs(context.Background(), namespace)
if err != nil {
	log.Fatal(err)
}

fmt.Println(resp)
Output:

func (*API) ListZoneAccessRules added in v0.8.1

func (api *API) ListZoneAccessRules(zoneID string, accessRule AccessRule, page int) (*AccessRuleListResponse, error)

ListZoneAccessRules returns a slice of access rules for the given zone identifier.

This takes an AccessRule to allow filtering of the results returned.

API reference: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-list-access-rules

Example (All)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch all access rules for a zone
	response, err := api.ListZoneAccessRules(zoneID, cloudflare.AccessRule{}, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range response.Result {
		fmt.Printf("%s: %s\n", r.Configuration.Value, r.Mode)
	}
}
Output:

Example (FilterByIP)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch only access rules whose target is 127.0.0.1
	localhost := cloudflare.AccessRule{
		Configuration: cloudflare.AccessRuleConfiguration{Target: "127.0.0.1"},
	}
	response, err := api.ListZoneAccessRules(zoneID, localhost, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range response.Result {
		fmt.Printf("%s: %s\n", r.Configuration.Value, r.Mode)
	}
}
Output:

Example (FilterByMode)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch access rules with an action of "block"
	foo := cloudflare.AccessRule{
		Mode: "block",
	}
	response, err := api.ListZoneAccessRules(zoneID, foo, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range response.Result {
		fmt.Printf("%s: %s\n", r.Configuration.Value, r.Mode)
	}
}
Output:

Example (FilterByNote)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch only access rules with notes containing "example"
	foo := cloudflare.AccessRule{
		Notes: "example",
	}
	response, err := api.ListZoneAccessRules(zoneID, foo, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range response.Result {
		fmt.Printf("%s: %s\n", r.Configuration.Value, r.Mode)
	}
}
Output:

func (*API) ListZoneLockdowns added in v0.8.0

func (api *API) ListZoneLockdowns(zoneID string, page int) (*ZoneLockdownListResponse, error)

ListZoneLockdowns retrieves a list of Zone ZoneLockdown rules for a given zone ID by page number.

API reference: https://api.cloudflare.com/#zone-ZoneLockdown-list-ZoneLockdown-rules

Example (All)
package main

import (
	"fmt"
	"log"
	"strings"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	zoneID, err := api.ZoneIDByName("example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch all Zone Lockdown rules for a zone, by page.
	rules, err := api.ListZoneLockdowns(zoneID, 1)
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range rules.Result {
		fmt.Printf("%s: %s\n", strings.Join(r.URLs, ", "), r.Configurations)
	}
}
Output:

func (*API) ListZones added in v0.7.2

func (api *API) ListZones(z ...string) ([]Zone, error)

ListZones lists zones on an account. Optionally takes a list of zone names to filter against.

API reference: https://api.cloudflare.com/#zone-list-zones

Example (All)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch all zones available to this user.
	zones, err := api.ListZones()
	if err != nil {
		log.Fatal(err)
	}

	for _, z := range zones {
		fmt.Println(z.Name)
	}
}
Output:

Example (Filter)
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch a slice of zones example.org and example.net.
	zones, err := api.ListZones("example.org", "example.net")
	if err != nil {
		log.Fatal(err)
	}

	for _, z := range zones {
		fmt.Println(z.Name)
	}
}
Output:

func (*API) ListZonesContext added in v0.9.0

func (api *API) ListZonesContext(ctx context.Context, opts ...ReqOption) (r ZonesResponse, err error)

ListZonesContext lists zones on an account. Optionally takes a list of ReqOptions.

func (*API) LoadBalancerDetails added in v0.8.0

func (api *API) LoadBalancerDetails(zoneID, lbID string) (LoadBalancer, error)

LoadBalancerDetails returns the details for a load balancer.

API reference: https://api.cloudflare.com/#load-balancers-load-balancer-details

func (*API) LoadBalancerMonitorDetails added in v0.8.0

func (api *API) LoadBalancerMonitorDetails(monitorID string) (LoadBalancerMonitor, error)

LoadBalancerMonitorDetails returns the details for a load balancer monitor.

API reference: https://api.cloudflare.com/#load-balancer-monitors-monitor-details

func (*API) LoadBalancerPoolDetails added in v0.8.0

func (api *API) LoadBalancerPoolDetails(poolID string) (LoadBalancerPool, error)

LoadBalancerPoolDetails returns the details for a load balancer pool.

API reference: https://api.cloudflare.com/#load-balancer-pools-pool-details

func (*API) LogpushJob added in v0.9.0

func (api *API) LogpushJob(zoneID string, jobID int) (LogpushJob, error)

LogpushJob fetches detail about one Logpush Job for a zone.

API reference: https://api.cloudflare.com/#logpush-jobs-logpush-job-details

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

job, err := api.LogpushJob(zoneID, 1)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", job)
Output:

func (*API) LogpushJobs added in v0.9.0

func (api *API) LogpushJobs(zoneID string) ([]LogpushJob, error)

LogpushJobs returns all Logpush Jobs for a zone.

API reference: https://api.cloudflare.com/#logpush-jobs-list-logpush-jobs

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

jobs, err := api.LogpushJobs(zoneID)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", jobs)
for _, r := range jobs {
	fmt.Printf("%+v\n", r)
}
Output:

func (*API) ModifyLoadBalancer added in v0.8.0

func (api *API) ModifyLoadBalancer(zoneID string, lb LoadBalancer) (LoadBalancer, error)

ModifyLoadBalancer modifies a configured load balancer.

API reference: https://api.cloudflare.com/#load-balancers-modify-a-load-balancer

func (*API) ModifyLoadBalancerMonitor added in v0.8.0

func (api *API) ModifyLoadBalancerMonitor(monitor LoadBalancerMonitor) (LoadBalancerMonitor, error)

ModifyLoadBalancerMonitor modifies a configured load balancer monitor.

API reference: https://api.cloudflare.com/#load-balancer-monitors-modify-a-monitor

func (*API) ModifyLoadBalancerPool added in v0.8.0

func (api *API) ModifyLoadBalancerPool(pool LoadBalancerPool) (LoadBalancerPool, error)

ModifyLoadBalancerPool modifies a configured load balancer pool.

API reference: https://api.cloudflare.com/#load-balancer-pools-modify-a-pool

func (*API) OriginCertificate added in v0.7.4

func (api *API) OriginCertificate(certificateID string) (*OriginCACertificate, error)

OriginCertificate returns the details for a Cloudflare-issued certificate.

This function requires api.APIUserServiceKey be set to your Certificates API key.

API reference: https://api.cloudflare.com/#cloudflare-ca-certificate-details

func (*API) OriginCertificates added in v0.7.4

func (api *API) OriginCertificates(options OriginCACertificateListOptions) ([]OriginCACertificate, error)

OriginCertificates lists all Cloudflare-issued certificates.

This function requires api.APIUserServiceKey be set to your Certificates API key.

API reference: https://api.cloudflare.com/#cloudflare-ca-list-certificates

func (*API) PageRule added in v0.7.2

func (api *API) PageRule(zoneID, ruleID string) (PageRule, error)

PageRule fetches detail about one Page Rule for a zone.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-page-rule-details

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

pageRules, err := api.PageRule(zoneID, "my_page_rule_id")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", pageRules)
Output:

func (*API) PoolHealthDetails added in v0.9.0

func (api *API) PoolHealthDetails(poolID string) (LoadBalancerPoolHealth, error)

PoolHealthDetails fetches the latest healtcheck details for a single pool.

API reference: https://api.cloudflare.com/#load-balancer-pools-pool-health-details

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	// Construct a new API object.
	api, err := cloudflare.New("deadbeef", "test@example.com")
	if err != nil {
		log.Fatal(err)
	}

	// Fetch pool health details.
	healthInfo, err := api.PoolHealthDetails("example-pool-id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(healthInfo)
}
Output:

func (*API) PurgeCache added in v0.7.2

func (api *API) PurgeCache(zoneID string, pcr PurgeCacheRequest) (PurgeCacheResponse, error)

PurgeCache purges the cache using the given PurgeCacheRequest (zone/url/tag).

API reference: https://api.cloudflare.com/#zone-purge-individual-files-by-url-and-cache-tags

func (*API) PurgeEverything added in v0.7.2

func (api *API) PurgeEverything(zoneID string) (PurgeCacheResponse, error)

PurgeEverything purges the cache for the given zone.

Note: this will substantially increase load on the origin server for that zone if there is a high cached vs. uncached request ratio.

API reference: https://api.cloudflare.com/#zone-purge-all-files

func (*API) RailgunDetails added in v0.7.2

func (api *API) RailgunDetails(railgunID string) (Railgun, error)

RailgunDetails returns the details for a Railgun.

API reference: https://api.cloudflare.com/#railgun-railgun-details

func (*API) RailgunZones added in v0.7.2

func (api *API) RailgunZones(railgunID string) ([]Zone, error)

RailgunZones returns the zones that are currently using a Railgun.

API reference: https://api.cloudflare.com/#railgun-get-zones-connected-to-a-railgun

func (*API) RateLimit added in v0.8.5

func (api *API) RateLimit(zoneID, limitID string) (RateLimit, error)

RateLimit fetches detail about one Rate Limit for a zone.

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-rate-limit-details

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

rateLimits, err := api.RateLimit(zoneID, "my_rate_limit_id")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", rateLimits)
Output:

func (*API) Raw added in v0.8.0

func (api *API) Raw(method, endpoint string, data interface{}) (json.RawMessage, error)

Raw makes a HTTP request with user provided params and returns the result as untouched JSON.

func (API) ReadWorkersKV added in v0.9.0

func (api API) ReadWorkersKV(ctx context.Context, namespaceID, key string) ([]byte, error)

ReadWorkersKV returns the value associated with the given key in the given namespace

API reference: https://api.cloudflare.com/#workers-kv-namespace-read-key-value-pair

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

key := "test_key"
resp, err := api.ReadWorkersKV(context.Background(), namespace, key)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%s\n", resp)
Output:

func (*API) RegistrarDomain added in v0.9.0

func (api *API) RegistrarDomain(accountID, domainName string) (RegistrarDomain, error)

RegistrarDomain returns a single domain based on the account ID and domain name.

API reference: https://api.cloudflare.com/#registrar-domains-get-domain

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

domain, err := api.RegistrarDomain("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")

fmt.Printf("%+v\n", domain)
Output:

func (*API) RegistrarDomains added in v0.9.0

func (api *API) RegistrarDomains(accountID string) ([]RegistrarDomain, error)

RegistrarDomains returns all registrar domains based on the account ID.

API reference: https://api.cloudflare.com/#registrar-domains-list-domains

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

domains, err := api.RegistrarDomains("01a7362d577a6c3019a474fd6f485823")

fmt.Printf("%+v\n", domains)
Output:

func (*API) ReprioritizeSSL added in v0.7.2

func (api *API) ReprioritizeSSL(zoneID string, p []ZoneCustomSSLPriority) ([]ZoneCustomSSL, error)

ReprioritizeSSL allows you to change the priority (which is served for a given request) of custom SSL certificates associated with the given zone.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-re-prioritize-ssl-certificates

func (*API) RevokeAccessApplicationTokens added in v0.9.0

func (api *API) RevokeAccessApplicationTokens(zoneID, applicationID string) error

RevokeAccessApplicationTokens revokes tokens associated with an access application.

API reference: https://api.cloudflare.com/#access-applications-revoke-access-tokens

func (*API) RevokeOriginCertificate added in v0.7.4

func (api *API) RevokeOriginCertificate(certificateID string) (*OriginCACertificateID, error)

RevokeOriginCertificate revokes a created certificate for a zone.

This function requires api.APIUserServiceKey be set to your Certificates API key.

API reference: https://api.cloudflare.com/#cloudflare-ca-revoke-certificate

func (*API) SSLDetails added in v0.7.2

func (api *API) SSLDetails(zoneID, certificateID string) (ZoneCustomSSL, error)

SSLDetails returns the configuration details for a custom SSL certificate.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-ssl-configuration-details

func (*API) SetAuthType added in v0.7.4

func (api *API) SetAuthType(authType int)

SetAuthType sets the authentication method (AuthKeyEmail, AuthToken, or AuthUserService).

func (*API) SpectrumApplication added in v0.9.0

func (api *API) SpectrumApplication(zoneID string, applicationID string) (SpectrumApplication, error)

SpectrumApplication fetches a single Spectrum application based on the ID.

API reference: https://developers.cloudflare.com/spectrum/api-reference/#list-spectrum-applications

func (*API) SpectrumApplications added in v0.9.0

func (api *API) SpectrumApplications(zoneID string) ([]SpectrumApplication, error)

SpectrumApplications fetches all of the Spectrum applications for a zone.

API reference: https://developers.cloudflare.com/spectrum/api-reference/#list-spectrum-applications

func (*API) TestRailgunConnection added in v0.7.2

func (api *API) TestRailgunConnection(zoneID, railgunID string) (RailgunDiagnosis, error)

TestRailgunConnection tests a Railgun connection for a given zone.

API reference: https://api.cloudflare.com/#railgun-connections-for-a-zone-test-railgun-connection

func (*API) TransferRegistrarDomain added in v0.9.0

func (api *API) TransferRegistrarDomain(accountID, domainName string) ([]RegistrarDomain, error)

TransferRegistrarDomain initiates the transfer from another registrar to Cloudflare Registrar.

API reference: https://api.cloudflare.com/#registrar-domains-transfer-domain

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

domain, err := api.TransferRegistrarDomain("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")

fmt.Printf("%+v\n", domain)
Output:

func (*API) UniversalSSLSettingDetails added in v0.9.0

func (api *API) UniversalSSLSettingDetails(zoneID string) (UniversalSSLSetting, error)

UniversalSSLSettingDetails returns the details for a universal ssl setting

API reference: https://api.cloudflare.com/#universal-ssl-settings-for-a-zone-universal-ssl-settings-details

func (*API) UniversalSSLVerificationDetails added in v0.10.0

func (api *API) UniversalSSLVerificationDetails(zoneID string) ([]UniversalSSLVerificationDetails, error)

UniversalSSLVerificationDetails returns the details for a universal ssl verifcation

API reference: https://api.cloudflare.com/#ssl-verification-ssl-verification-details

func (*API) UpdateAccessApplication added in v0.9.0

func (api *API) UpdateAccessApplication(zoneID string, accessApplication AccessApplication) (AccessApplication, error)

UpdateAccessApplication updates an existing access application.

API reference: https://api.cloudflare.com/#access-applications-update-access-application

func (*API) UpdateAccessPolicy added in v0.9.0

func (api *API) UpdateAccessPolicy(zoneID, applicationID string, accessPolicy AccessPolicy) (AccessPolicy, error)

UpdateAccessPolicy updates an existing access policy.

API reference: https://api.cloudflare.com/#access-policy-update-access-policy

func (*API) UpdateAccount added in v0.9.0

func (api *API) UpdateAccount(accountID string, account Account) (Account, error)

UpdateAccount allows management of an account using the account ID.

API reference: https://api.cloudflare.com/#accounts-update-account

func (*API) UpdateAccountAccessRule added in v0.10.0

func (api *API) UpdateAccountAccessRule(accountID, accessRuleID string, accessRule AccessRule) (*AccessRuleResponse, error)

UpdateAccountAccessRule updates a single access rule for the given account & access rule identifiers.

API reference: https://api.cloudflare.com/#account-level-firewall-access-rule-update-access-rule

func (*API) UpdateAccountMember added in v0.9.0

func (api *API) UpdateAccountMember(accountID string, userID string, member AccountMember) (AccountMember, error)

UpdateAccountMember modifies an existing account member.

API reference: https://api.cloudflare.com/#account-members-update-member

func (*API) UpdateArgoSmartRouting added in v0.9.0

func (api *API) UpdateArgoSmartRouting(zoneID, settingValue string) (ArgoFeatureSetting, error)

UpdateArgoSmartRouting updates the setting for smart routing.

API reference: https://api.cloudflare.com/#argo-smart-routing-patch-argo-smart-routing-setting

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	smartRoutingSettings, err := api.UpdateArgoSmartRouting("01a7362d577a6c3019a474fd6f485823", "on")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("smart routing is %s", smartRoutingSettings.Value)
}
Output:

func (*API) UpdateArgoTieredCaching added in v0.9.0

func (api *API) UpdateArgoTieredCaching(zoneID, settingValue string) (ArgoFeatureSetting, error)

UpdateArgoTieredCaching updates the setting for tiered caching.

API reference: TBA

Example
package main

import (
	"fmt"
	"log"

	cloudflare "github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.New("deadbeef", "test@example.org")
	if err != nil {
		log.Fatal(err)
	}

	tieredCachingSettings, err := api.UpdateArgoTieredCaching("01a7362d577a6c3019a474fd6f485823", "on")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("tiered caching is %s", tieredCachingSettings.Value)
}
Output:

func (*API) UpdateCustomHostnameSSL added in v0.7.4

func (api *API) UpdateCustomHostnameSSL(zoneID string, customHostnameID string, ssl CustomHostnameSSL) (CustomHostname, error)

UpdateCustomHostnameSSL modifies SSL configuration for the given custom hostname in the given zone.

API reference: https://api.cloudflare.com/#custom-hostname-for-a-zone-update-custom-hostname-configuration

func (*API) UpdateCustomPage added in v0.9.0

func (api *API) UpdateCustomPage(options *CustomPageOptions, customPageID string, pageParameters CustomPageParameters) (CustomPage, error)

UpdateCustomPage updates a single custom page setting.

Zone API reference: https://api.cloudflare.com/#custom-pages-for-a-zone-update-custom-page-url Account API reference: https://api.cloudflare.com/#custom-pages-account--update-custom-page

func (*API) UpdateDNSRecord added in v0.7.2

func (api *API) UpdateDNSRecord(zoneID, recordID string, rr DNSRecord) error

UpdateDNSRecord updates a single DNS record for the given zone & record identifiers.

API reference: https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record

func (*API) UpdateFilter added in v0.9.0

func (api *API) UpdateFilter(zoneID string, filter Filter) (Filter, error)

UpdateFilter updates a single filter.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/put/#update-a-single-filter

func (*API) UpdateFilters added in v0.9.0

func (api *API) UpdateFilters(zoneID string, filters []Filter) ([]Filter, error)

UpdateFilters updates many filters at once.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/put/#update-multiple-filters

func (*API) UpdateFirewallRule added in v0.9.0

func (api *API) UpdateFirewallRule(zoneID string, firewallRule FirewallRule) (FirewallRule, error)

UpdateFirewallRule updates a single firewall rule.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/put/#update-a-single-rule

func (*API) UpdateFirewallRules added in v0.9.0

func (api *API) UpdateFirewallRules(zoneID string, firewallRules []FirewallRule) ([]FirewallRule, error)

UpdateFirewallRules updates a single firewall rule.

API reference: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/put/#update-multiple-rules

func (*API) UpdateKeyless added in v0.7.2

func (api *API) UpdateKeyless()

UpdateKeyless updates an existing Keyless SSL configuration.

API reference: https://api.cloudflare.com/#keyless-ssl-for-a-zone-update-keyless-configuration

func (*API) UpdateLogpushJob added in v0.9.0

func (api *API) UpdateLogpushJob(zoneID string, jobID int, job LogpushJob) error

UpdateLogpushJob lets you update a Logpush Job.

API reference: https://api.cloudflare.com/#logpush-jobs-update-logpush-job

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

err = api.UpdateLogpushJob(zoneID, 1, exampleUpdatedLogpushJob)
if err != nil {
	log.Fatal(err)
}
Output:

func (*API) UpdatePageRule added in v0.7.2

func (api *API) UpdatePageRule(zoneID, ruleID string, rule PageRule) error

UpdatePageRule lets you replace a Page Rule. This is in contrast to ChangePageRule which lets you change individual settings.

API reference: https://api.cloudflare.com/#page-rules-for-a-zone-update-a-page-rule

func (*API) UpdateRateLimit added in v0.8.5

func (api *API) UpdateRateLimit(zoneID, limitID string, limit RateLimit) (RateLimit, error)

UpdateRateLimit lets you replace a Rate Limit for a zone.

API reference: https://api.cloudflare.com/#rate-limits-for-a-zone-update-rate-limit

func (*API) UpdateRegistrarDomain added in v0.9.0

func (api *API) UpdateRegistrarDomain(accountID, domainName string, domainConfiguration RegistrarDomainConfiguration) (RegistrarDomain, error)

UpdateRegistrarDomain updates an existing Registrar Domain configuration.

API reference: https://api.cloudflare.com/#registrar-domains-update-domain

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

domain, err := api.UpdateRegistrarDomain(
	"01a7362d577a6c3019a474fd6f485823",
	"cloudflare.com",
	cloudflare.RegistrarDomainConfiguration{
		NameServers: []string{"ns1.cloudflare.com", "ns2.cloudflare.com"},
		Locked:      false,
	},
)

fmt.Printf("%+v\n", domain)
Output:

func (*API) UpdateSSL added in v0.7.2

func (api *API) UpdateSSL(zoneID, certificateID string, options ZoneCustomSSLOptions) (ZoneCustomSSL, error)

UpdateSSL updates (replaces) a custom SSL certificate.

API reference: https://api.cloudflare.com/#custom-ssl-for-a-zone-update-ssl-configuration

func (*API) UpdateSpectrumApplication added in v0.9.0

func (api *API) UpdateSpectrumApplication(zoneID, appID string, appDetails SpectrumApplication) (SpectrumApplication, error)

UpdateSpectrumApplication updates an existing Spectrum application.

API reference: https://developers.cloudflare.com/spectrum/api-reference/#update-a-spectrum-application

func (*API) UpdateUser added in v0.7.2

func (api *API) UpdateUser(user *User) (User, error)

UpdateUser updates the properties of the given user.

API reference: https://api.cloudflare.com/#user-update-user

func (*API) UpdateUserAccessRule added in v0.8.1

func (api *API) UpdateUserAccessRule(accessRuleID string, accessRule AccessRule) (*AccessRuleResponse, error)

UpdateUserAccessRule updates a single access rule for the logged-in user & given access rule identifier.

API reference: https://api.cloudflare.com/#user-level-firewall-access-rule-update-access-rule

func (*API) UpdateUserAgentRule added in v0.8.0

func (api *API) UpdateUserAgentRule(zoneID string, id string, ld UserAgentRule) (*UserAgentRuleResponse, error)

UpdateUserAgentRule updates a User-Agent Block rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#user-agent-blocking-rules-update-useragent-rule

func (*API) UpdateVirtualDNS added in v0.7.2

func (api *API) UpdateVirtualDNS(virtualDNSID string, vv VirtualDNS) error

UpdateVirtualDNS updates a Virtual DNS cluster.

API reference: https://api.cloudflare.com/#virtual-dns-users--modify-a-virtual-dns-cluster

func (*API) UpdateWAFPackage added in v0.10.0

func (api *API) UpdateWAFPackage(zoneID, packageID string, opts WAFPackageOptions) (WAFPackage, error)

UpdateWAFPackage lets you update the a WAF Package.

API Reference: https://api.cloudflare.com/#waf-rule-packages-edit-firewall-package

func (*API) UpdateWAFRule added in v0.9.0

func (api *API) UpdateWAFRule(zoneID, packageID, ruleID, mode string) (WAFRule, error)

UpdateWAFRule lets you update the mode of a WAF Rule.

API Reference: https://api.cloudflare.com/#waf-rules-edit-rule

func (*API) UpdateWorkerRoute added in v0.9.0

func (api *API) UpdateWorkerRoute(zoneID string, routeID string, route WorkerRoute) (WorkerRouteResponse, error)

UpdateWorkerRoute updates worker route for a zone.

API reference: https://api.cloudflare.com/#worker-filters-update-filter

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}
// pull from existing list of routes to perform update on
routesResponse, err := api.ListWorkerRoutes(zoneID)
if err != nil {
	log.Fatal(err)
}
route := cloudflare.WorkerRoute{Pattern: "app2.example.com/*", Enabled: true}
// update first route retrieved from the listWorkerRoutes call with details above
res, err := api.UpdateWorkerRoute(zoneID, routesResponse.Routes[0].ID, route)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)
Output:

func (*API) UpdateWorkersKVNamespace added in v0.9.0

func (api *API) UpdateWorkersKVNamespace(ctx context.Context, namespaceID string, req *WorkersKVNamespaceRequest) (Response, error)

UpdateWorkersKVNamespace modifies a namespace's title

API reference: https://api.cloudflare.com/#workers-kv-namespace-rename-a-namespace

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

resp, err := api.UpdateWorkersKVNamespace(context.Background(), namespace, &cloudflare.WorkersKVNamespaceRequest{Title: "test_title"})
if err != nil {
	log.Fatal(err)
}

fmt.Println(resp)
Output:

func (*API) UpdateZoneAccessRule added in v0.8.1

func (api *API) UpdateZoneAccessRule(zoneID, accessRuleID string, accessRule AccessRule) (*AccessRuleResponse, error)

UpdateZoneAccessRule updates a single access rule for the given zone & access rule identifiers.

API reference: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-update-access-rule

func (*API) UpdateZoneLockdown added in v0.8.0

func (api *API) UpdateZoneLockdown(zoneID string, id string, ld ZoneLockdown) (*ZoneLockdownResponse, error)

UpdateZoneLockdown updates a Zone ZoneLockdown rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#zone-ZoneLockdown-update-ZoneLockdown-rule

func (*API) UpdateZoneSettings added in v0.8.5

func (api *API) UpdateZoneSettings(zoneID string, settings []ZoneSetting) (*ZoneSettingResponse, error)

UpdateZoneSettings updates the settings for a given zone.

API reference: https://api.cloudflare.com/#zone-settings-edit-zone-settings-info

func (*API) UploadWorker added in v0.9.0

func (api *API) UploadWorker(requestParams *WorkerRequestParams, data string) (WorkerScriptResponse, error)

UploadWorker push raw script content for your worker.

API reference: https://api.cloudflare.com/#worker-script-upload-worker

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

res, err := api.UploadWorker(&cloudflare.WorkerRequestParams{ZoneID: zoneID}, workerScript)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%+v", res)

UploadWorkerWithName()
Output:

func (*API) UserAccessRule added in v0.9.0

func (api *API) UserAccessRule(accessRuleID string) (*AccessRuleResponse, error)

UserAccessRule returns the details of a user's account access rule.

API reference: https://api.cloudflare.com/#user-level-firewall-access-rule-list-access-rules

func (*API) UserAgentRule added in v0.8.0

func (api *API) UserAgentRule(zoneID string, id string) (*UserAgentRuleResponse, error)

UserAgentRule retrieves a User-Agent Block rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#user-agent-blocking-rules-useragent-rule-details

func (*API) UserBillingProfile added in v0.7.3

func (api *API) UserBillingProfile() (UserBillingProfile, error)

UserBillingProfile returns the billing profile of the user.

API reference: https://api.cloudflare.com/#user-billing-profile

func (*API) UserDetails added in v0.7.2

func (api *API) UserDetails() (User, error)

UserDetails provides information about the logged-in user.

API reference: https://api.cloudflare.com/#user-user-details

func (*API) ValidateFilterExpression added in v0.9.0

func (api *API) ValidateFilterExpression(expression string) error

ValidateFilterExpression checks correctness of a filter expression.

API reference: https://developers.cloudflare.com/firewall/api/cf-filters/validation/

func (*API) ValidateLogpushOwnershipChallenge added in v0.9.0

func (api *API) ValidateLogpushOwnershipChallenge(zoneID, destinationConf, ownershipChallenge string) (bool, error)

ValidateLogpushOwnershipChallenge returns ownership challenge validation result.

API reference: https://api.cloudflare.com/#logpush-jobs-validate-ownership-challenge

Example
api, err := cloudflare.New(apiKey, user)
if err != nil {
	log.Fatal(err)
}

zoneID, err := api.ZoneIDByName(domain)
if err != nil {
	log.Fatal(err)
}

isValid, err := api.ValidateLogpushOwnershipChallenge(zoneID, "destination_conf", "ownership_challenge")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%+v\n", isValid)
Output:

func (*API) VirtualDNS added in v0.7.2

func (api *API) VirtualDNS(virtualDNSID string) (*VirtualDNS, error)

VirtualDNS fetches a single virtual DNS cluster.

API reference: https://api.cloudflare.com/#virtual-dns-users--get-a-virtual-dns-cluster

func (*API) VirtualDNSUserAnalytics added in v0.9.0

func (api *API) VirtualDNSUserAnalytics(virtualDNSID string, o VirtualDNSUserAnalyticsOptions) (VirtualDNSAnalytics, error)

VirtualDNSUserAnalytics retrieves analytics report for a specified dimension and time range

func (*API) WAFPackage added in v0.10.0

func (api *API) WAFPackage(zoneID, packageID string) (WAFPackage, error)

WAFPackage returns a WAF package for the given zone.

API Reference: https://api.cloudflare.com/#waf-rule-packages-firewall-package-details

func (*API) WAFRule added in v0.9.0

func (api *API) WAFRule(zoneID, packageID, ruleID string) (WAFRule, error)

WAFRule returns a WAF rule from the given WAF package.

API Reference: https://api.cloudflare.com/#waf-rules-rule-details

func (*API) WriteWorkersKV added in v0.9.0

func (api *API) WriteWorkersKV(ctx context.Context, namespaceID, key string, value []byte) (Response, error)

WriteWorkersKV writes a value identified by a key.

API reference: https://api.cloudflare.com/#workers-kv-namespace-write-key-value-pair

Example
api, err := cloudflare.New(apiKey, user, cloudflare.UsingAccount(accountID))
if err != nil {
	log.Fatal(err)
}

payload := []byte("test payload")
key := "test_key"

resp, err := api.WriteWorkersKV(context.Background(), namespace, key, payload)
if err != nil {
	log.Fatal(err)
}

fmt.Println(resp)
Output:

func (*API) ZoneAccessRule added in v0.9.0

func (api *API) ZoneAccessRule(zoneID string, accessRuleID string) (*AccessRuleResponse, error)

ZoneAccessRule returns the details of a zone's access rule.

API reference: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-list-access-rules

func (*API) ZoneActivationCheck added in v0.7.2

func (api *API) ZoneActivationCheck(zoneID string) (Response, error)

ZoneActivationCheck initiates another zone activation check for newly-created zones.

API reference: https://api.cloudflare.com/#zone-initiate-another-zone-activation-check

func (*API) ZoneAnalyticsByColocation added in v0.7.2

func (api *API) ZoneAnalyticsByColocation(zoneID string, options ZoneAnalyticsOptions) ([]ZoneAnalyticsColocation, error)

ZoneAnalyticsByColocation returns zone analytics information by datacenter.

API reference: https://api.cloudflare.com/#zone-analytics-analytics-by-co-locations

func (*API) ZoneAnalyticsDashboard added in v0.7.2

func (api *API) ZoneAnalyticsDashboard(zoneID string, options ZoneAnalyticsOptions) (ZoneAnalyticsData, error)

ZoneAnalyticsDashboard returns zone analytics information.

API reference: https://api.cloudflare.com/#zone-analytics-dashboard

func (*API) ZoneDetails added in v0.7.2

func (api *API) ZoneDetails(zoneID string) (Zone, error)

ZoneDetails fetches information about a zone.

API reference: https://api.cloudflare.com/#zone-zone-details

func (*API) ZoneIDByName added in v0.7.2

func (api *API) ZoneIDByName(zoneName string) (string, error)

ZoneIDByName retrieves a zone's ID from the name.

func (*API) ZoneLockdown added in v0.8.0

func (api *API) ZoneLockdown(zoneID string, id string) (*ZoneLockdownResponse, error)

ZoneLockdown retrieves a Zone ZoneLockdown rule (based on the ID) for the given zone ID.

API reference: https://api.cloudflare.com/#zone-ZoneLockdown-ZoneLockdown-rule-details

func (*API) ZoneRailgunDetails added in v0.7.2

func (api *API) ZoneRailgunDetails(zoneID, railgunID string) (ZoneRailgun, error)

ZoneRailgunDetails returns the configuration for a given Railgun.

API reference: https://api.cloudflare.com/#railguns-for-a-zone-get-railgun-details

func (*API) ZoneRailguns added in v0.7.2

func (api *API) ZoneRailguns(zoneID string) ([]ZoneRailgun, error)

ZoneRailguns returns the available Railguns for a zone.

API reference: https://api.cloudflare.com/#railguns-for-a-zone-get-available-railguns

func (*API) ZoneSSLSettings added in v0.7.4

func (api *API) ZoneSSLSettings(zoneID string) (ZoneSSLSetting, error)

ZoneSSLSettings returns information about SSL setting to the specified zone.

API reference: https://api.cloudflare.com/#zone-settings-get-ssl-setting

func (*API) ZoneSetPaused added in v0.7.2

func (api *API) ZoneSetPaused(zoneID string, paused bool) (Zone, error)

ZoneSetPaused pauses Cloudflare service for the entire zone, sending all traffic direct to the origin.

func (*API) ZoneSetPlan added in v0.7.2

func (api *API) ZoneSetPlan(zoneID string, plan ZonePlan) (Zone, error)

ZoneSetPlan changes the zone plan.

func (*API) ZoneSetVanityNS added in v0.7.2

func (api *API) ZoneSetVanityNS(zoneID string, ns []string) (Zone, error)

ZoneSetVanityNS sets custom nameservers for the zone. These names must be within the same zone.

func (*API) ZoneSettings added in v0.8.5

func (api *API) ZoneSettings(zoneID string) (*ZoneSettingResponse, error)

ZoneSettings returns all of the settings for a given zone.

API reference: https://api.cloudflare.com/#zone-settings-get-all-zone-settings

type AccessApplication added in v0.9.0

type AccessApplication struct {
	ID              string     `json:"id,omitempty"`
	CreatedAt       *time.Time `json:"created_at,omitempty"`
	UpdatedAt       *time.Time `json:"updated_at,omitempty"`
	AUD             string     `json:"aud,omitempty"`
	Name            string     `json:"name"`
	Domain          string     `json:"domain"`
	SessionDuration string     `json:"session_duration,omitempty"`
}

AccessApplication represents an Access application.

type AccessApplicationDetailResponse added in v0.9.0

type AccessApplicationDetailResponse struct {
	Success  bool              `json:"success"`
	Errors   []string          `json:"errors"`
	Messages []string          `json:"messages"`
	Result   AccessApplication `json:"result"`
}

AccessApplicationDetailResponse is the API response, containing a single access application.

type AccessApplicationListResponse added in v0.9.0

type AccessApplicationListResponse struct {
	Result []AccessApplication `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccessApplicationListResponse represents the response from the list access applications endpoint.

type AccessPolicy added in v0.9.0

type AccessPolicy struct {
	ID         string     `json:"id,omitempty"`
	Precedence int        `json:"precedence"`
	Decision   string     `json:"decision"`
	CreatedAt  *time.Time `json:"created_at"`
	UpdatedAt  *time.Time `json:"updated_at"`
	Name       string     `json:"name"`

	// The include policy works like an OR logical operator. The user must
	// satisfy one of the rules.
	Include []interface{} `json:"include"`

	// The exclude policy works like a NOT logical operator. The user must
	// not satisfy all of the rules in exclude.
	Exclude []interface{} `json:"exclude"`

	// The require policy works like a AND logical operator. The user must
	// satisfy all of the rules in require.
	Require []interface{} `json:"require"`
}

AccessPolicy defines a policy for allowing or disallowing access to one or more Access applications.

type AccessPolicyAccessGroup added in v0.9.0

type AccessPolicyAccessGroup struct {
	Group struct {
		ID string `json:"id"`
	} `json:"group"`
}

AccessPolicyAccessGroup is used for managing access based on an access group.

type AccessPolicyDetailResponse added in v0.9.0

type AccessPolicyDetailResponse struct {
	Success  bool         `json:"success"`
	Errors   []string     `json:"errors"`
	Messages []string     `json:"messages"`
	Result   AccessPolicy `json:"result"`
}

AccessPolicyDetailResponse is the API response, containing a single access policy.

type AccessPolicyEmail added in v0.9.0

type AccessPolicyEmail struct {
	Email struct {
		Email string `json:"email"`
	} `json:"email"`
}

AccessPolicyEmail is used for managing access based on the email. For example, restrict access to users with the email addresses `test@example.com` or `someone@example.com`.

type AccessPolicyEmailDomain added in v0.9.0

type AccessPolicyEmailDomain struct {
	EmailDomain struct {
		Domain string `json:"domain"`
	} `json:"email_domain"`
}

AccessPolicyEmailDomain is used for managing access based on an email domain domain such as `example.com` instead of individual addresses.

type AccessPolicyEveryone added in v0.9.0

type AccessPolicyEveryone struct {
	Everyone struct{} `json:"everyone"`
}

AccessPolicyEveryone is used for managing access to everyone.

type AccessPolicyIP added in v0.9.0

type AccessPolicyIP struct {
	IP struct {
		IP string `json:"ip"`
	} `json:"ip"`
}

AccessPolicyIP is used for managing access based in the IP. It accepts individual IPs or CIDRs.

type AccessPolicyListResponse added in v0.9.0

type AccessPolicyListResponse struct {
	Result []AccessPolicy `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccessPolicyListResponse represents the response from the list access polciies endpoint.

type AccessRule added in v0.8.1

type AccessRule struct {
	ID            string                  `json:"id,omitempty"`
	Notes         string                  `json:"notes,omitempty"`
	AllowedModes  []string                `json:"allowed_modes,omitempty"`
	Mode          string                  `json:"mode,omitempty"`
	Configuration AccessRuleConfiguration `json:"configuration,omitempty"`
	Scope         AccessRuleScope         `json:"scope,omitempty"`
	CreatedOn     time.Time               `json:"created_on,omitempty"`
	ModifiedOn    time.Time               `json:"modified_on,omitempty"`
}

AccessRule represents a firewall access rule.

type AccessRuleConfiguration added in v0.8.1

type AccessRuleConfiguration struct {
	Target string `json:"target,omitempty"`
	Value  string `json:"value,omitempty"`
}

AccessRuleConfiguration represents the configuration of a firewall access rule.

type AccessRuleListResponse added in v0.8.1

type AccessRuleListResponse struct {
	Result []AccessRule `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccessRuleListResponse represents the response from the list access rules endpoint.

type AccessRuleResponse added in v0.8.1

type AccessRuleResponse struct {
	Result AccessRule `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccessRuleResponse represents the response from the firewall access rule endpoint.

type AccessRuleScope added in v0.8.1

type AccessRuleScope struct {
	ID    string `json:"id,omitempty"`
	Email string `json:"email,omitempty"`
	Name  string `json:"name,omitempty"`
	Type  string `json:"type,omitempty"`
}

AccessRuleScope represents the scope of a firewall access rule.

type Account

type Account struct {
	ID       string           `json:"id,omitempty"`
	Name     string           `json:"name,omitempty"`
	Settings *AccountSettings `json:"settings"`
}

Account represents the root object that owns resources.

type AccountDetailResponse added in v0.9.0

type AccountDetailResponse struct {
	Success  bool     `json:"success"`
	Errors   []string `json:"errors"`
	Messages []string `json:"messages"`
	Result   Account  `json:"result"`
}

AccountDetailResponse is the API response, containing a single Account.

type AccountListResponse

type AccountListResponse struct {
	Result []Account `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccountListResponse represents the response from the list accounts endpoint.

type AccountMember

type AccountMember struct {
	ID     string                   `json:"id"`
	Code   string                   `json:"code"`
	User   AccountMemberUserDetails `json:"user"`
	Status string                   `json:"status"`
	Roles  []AccountRole            `json:"roles"`
}

AccountMember is the definition of a member of an account.

type AccountMemberDetailResponse added in v0.9.0

type AccountMemberDetailResponse struct {
	Success  bool          `json:"success"`
	Errors   []string      `json:"errors"`
	Messages []string      `json:"messages"`
	Result   AccountMember `json:"result"`
}

AccountMemberDetailResponse is the API response, containing a single account member.

type AccountMemberInvitation added in v0.9.0

type AccountMemberInvitation struct {
	Email string   `json:"email"`
	Roles []string `json:"roles"`
}

AccountMemberInvitation represents the invitation for a new member to the account.

type AccountMemberUserDetails added in v0.9.0

type AccountMemberUserDetails struct {
	ID                             string `json:"id"`
	FirstName                      string `json:"first_name"`
	LastName                       string `json:"last_name"`
	Email                          string `json:"email"`
	TwoFactorAuthenticationEnabled bool
}

AccountMemberUserDetails outlines all the personal information about a member.

type AccountMembersListResponse added in v0.9.0

type AccountMembersListResponse struct {
	Result []AccountMember `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccountMembersListResponse represents the response from the list account members endpoint.

type AccountResponse added in v0.9.0

type AccountResponse struct {
	Result Account `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccountResponse represents the response from the accounts endpoint for a single account ID.

type AccountRole added in v0.9.0

type AccountRole struct {
	ID          string                           `json:"id"`
	Name        string                           `json:"name"`
	Description string                           `json:"description"`
	Permissions map[string]AccountRolePermission `json:"permissions"`
}

AccountRole defines the roles that a member can have attached.

type AccountRoleDetailResponse added in v0.9.0

type AccountRoleDetailResponse struct {
	Success  bool        `json:"success"`
	Errors   []string    `json:"errors"`
	Messages []string    `json:"messages"`
	Result   AccountRole `json:"result"`
}

AccountRoleDetailResponse is the API response, containing a single account role.

type AccountRolePermission added in v0.9.0

type AccountRolePermission struct {
	Read bool `json:"read"`
	Edit bool `json:"edit"`
}

AccountRolePermission is the shared structure for all permissions that can be assigned to a member.

type AccountRolesListResponse added in v0.9.0

type AccountRolesListResponse struct {
	Result []AccountRole `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

AccountRolesListResponse represents the list response from the account roles.

type AccountSettings

type AccountSettings struct {
	EnforceTwoFactor bool `json:"enforce_twofactor"`
}

AccountSettings outlines the available options for an account.

type ArgoDetailsResponse added in v0.9.0

type ArgoDetailsResponse struct {
	Result ArgoFeatureSetting `json:"result"`
	Response
}

ArgoDetailsResponse is the API response for the argo smart routing and tiered caching response.

type ArgoFeatureSetting added in v0.9.0

type ArgoFeatureSetting struct {
	Editable   bool      `json:"editable,omitempty"`
	ID         string    `json:"id,omitempty"`
	ModifiedOn time.Time `json:"modified_on,omitempty"`
	Value      string    `json:"value"`
}

ArgoFeatureSetting is the structure of the API object for the argo smart routing and tiered caching settings.

type AuditLog added in v0.9.0

type AuditLog struct {
	Action   AuditLogAction         `json:"action"`
	Actor    AuditLogActor          `json:"actor"`
	ID       string                 `json:"id"`
	Metadata map[string]interface{} `json:"metadata"`
	NewValue string                 `json:"newValue"`
	OldValue string                 `json:"oldValue"`
	Owner    AuditLogOwner          `json:"owner"`
	Resource AuditLogResource       `json:"resource"`
	When     time.Time              `json:"when"`
}

AuditLog is an resource that represents an update in the cloudflare dash

type AuditLogAction added in v0.9.0

type AuditLogAction struct {
	Result bool   `json:"result"`
	Type   string `json:"type"`
}

AuditLogAction is a member of AuditLog, the action that was taken.

type AuditLogActor added in v0.9.0

type AuditLogActor struct {
	Email string `json:"email"`
	ID    string `json:"id"`
	IP    string `json:"ip"`
	Type  string `json:"type"`
}

AuditLogActor is a member of AuditLog, who performed the action.

type AuditLogFilter added in v0.9.0

type AuditLogFilter struct {
	ID         string
	ActorIP    string
	ActorEmail string
	Direction  string
	ZoneName   string
	Since      string
	Before     string
	PerPage    int
	Page       int
}

AuditLogFilter is an object for filtering the audit log response from the api.

func (AuditLogFilter) String added in v0.9.0

func (a AuditLogFilter) String() string

String turns an audit log filter in to an HTTP Query Param list. It will not inclue empty members of the struct in the query parameters.

type AuditLogOwner added in v0.9.0

type AuditLogOwner struct {
	ID string `json:"id"`
}

AuditLogOwner is a member of AuditLog, who owns this audit log.

type AuditLogResource added in v0.9.0

type AuditLogResource struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

AuditLogResource is a member of AuditLog, what was the action performed on.

type AuditLogResponse added in v0.9.0

type AuditLogResponse struct {
	Response   Response
	Result     []AuditLog `json:"result"`
	ResultInfo `json:"result_info"`
}

AuditLogResponse is the response returned from the cloudflare v4 api

type AvailableZonePlansResponse added in v0.7.2

type AvailableZonePlansResponse struct {
	Response
	Result []ZonePlan `json:"result"`
	ResultInfo
}

AvailableZonePlansResponse represents the response from the Available Plans endpoint.

type AvailableZoneRatePlansResponse added in v0.7.4

type AvailableZoneRatePlansResponse struct {
	Response
	Result     []ZoneRatePlan `json:"result"`
	ResultInfo `json:"result_info"`
}

AvailableZoneRatePlansResponse represents the response from the Available Rate Plans endpoint.

type CustomHostname added in v0.7.4

type CustomHostname struct {
	ID             string            `json:"id,omitempty"`
	Hostname       string            `json:"hostname,omitempty"`
	SSL            CustomHostnameSSL `json:"ssl,omitempty"`
	CustomMetadata CustomMetadata    `json:"custom_metadata,omitempty"`
}

CustomHostname represents a custom hostname in a zone.

type CustomHostnameListResponse

type CustomHostnameListResponse struct {
	Result []CustomHostname `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

CustomHostnameListResponse represents a response from the Custom Hostnames endpoints.

type CustomHostnameResponse added in v0.7.4

type CustomHostnameResponse struct {
	Result CustomHostname `json:"result"`
	Response
}

CustomHostnameResponse represents a response from the Custom Hostnames endpoints.

type CustomHostnameSSL added in v0.7.4

type CustomHostnameSSL struct {
	Status      string                    `json:"status,omitempty"`
	Method      string                    `json:"method,omitempty"`
	Type        string                    `json:"type,omitempty"`
	CnameTarget string                    `json:"cname_target,omitempty"`
	CnameName   string                    `json:"cname,omitempty"`
	Settings    CustomHostnameSSLSettings `json:"settings,omitempty"`
}

CustomHostnameSSL represents the SSL section in a given custom hostname.

type CustomHostnameSSLSettings added in v0.9.0

type CustomHostnameSSLSettings struct {
	HTTP2         string   `json:"http2,omitempty"`
	TLS13         string   `json:"tls_1_3,omitempty"`
	MinTLSVersion string   `json:"min_tls_version,omitempty"`
	Ciphers       []string `json:"ciphers,omitempty"`
}

CustomHostnameSSLSettings represents the SSL settings for a custom hostname.

type CustomMetadata added in v0.7.4

type CustomMetadata map[string]interface{}

CustomMetadata defines custom metadata for the hostname. This requires logic to be implemented by Cloudflare to act on the data provided.

type CustomPage added in v0.7.2

type CustomPage struct {
	CreatedOn      time.Time   `json:"created_on"`
	ModifiedOn     time.Time   `json:"modified_on"`
	URL            interface{} `json:"url"`
	State          string      `json:"state"`
	RequiredTokens []string    `json:"required_tokens"`
	PreviewTarget  string      `json:"preview_target"`
	Description    string      `json:"description"`
	ID             string      `json:"id"`
}

CustomPage represents a custom page configuration.

type CustomPageDetailResponse added in v0.9.0

type CustomPageDetailResponse struct {
	Response
	Result CustomPage `json:"result"`
}

CustomPageDetailResponse represents the response from the custom page endpoint.

type CustomPageOptions added in v0.9.0

type CustomPageOptions struct {
	AccountID string
	ZoneID    string
}

CustomPageOptions is used to determine whether or not the operation should take place on an account or zone level based on which is provided to the function.

A non-empty value denotes desired use.

type CustomPageParameters added in v0.9.0

type CustomPageParameters struct {
	URL   interface{} `json:"url"`
	State string      `json:"state"`
}

CustomPageParameters is used to update a particular custom page with the values provided.

type CustomPageResponse added in v0.7.2

type CustomPageResponse struct {
	Response
	Result []CustomPage `json:"result"`
}

CustomPageResponse represents the response from the custom pages endpoint.

type DNSListResponse added in v0.7.2

type DNSListResponse struct {
	Result []DNSRecord `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

DNSListResponse represents the response from the list DNS records endpoint.

type DNSRecord added in v0.7.2

type DNSRecord struct {
	ID         string      `json:"id,omitempty"`
	Type       string      `json:"type,omitempty"`
	Name       string      `json:"name,omitempty"`
	Content    string      `json:"content,omitempty"`
	Proxiable  bool        `json:"proxiable,omitempty"`
	Proxied    bool        `json:"proxied"`
	TTL        int         `json:"ttl,omitempty"`
	Locked     bool        `json:"locked,omitempty"`
	ZoneID     string      `json:"zone_id,omitempty"`
	ZoneName   string      `json:"zone_name,omitempty"`
	CreatedOn  time.Time   `json:"created_on,omitempty"`
	ModifiedOn time.Time   `json:"modified_on,omitempty"`
	Data       interface{} `json:"data,omitempty"` // data returned by: SRV, LOC
	Meta       interface{} `json:"meta,omitempty"`
	Priority   int         `json:"priority"`
}

DNSRecord represents a DNS record in a zone.

type DNSRecordResponse added in v0.7.2

type DNSRecordResponse struct {
	Result DNSRecord `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

DNSRecordResponse represents the response from the DNS endpoint.

type Duration added in v0.9.0

type Duration struct {
	time.Duration
}

Duration implements json.Marshaler and json.Unmarshaler for time.Duration using the fmt.Stringer interface of time.Duration and time.ParseDuration.

Example
d := Duration{1 * time.Second}
fmt.Println(d)

buf, err := json.Marshal(d)
fmt.Println(string(buf), err)

err = json.Unmarshal([]byte(`"5s"`), &d)
fmt.Println(d, err)

d.Duration += time.Second
fmt.Println(d, err)
Output:

1s
"1s" <nil>
5s <nil>
6s <nil>

func (Duration) MarshalJSON added in v0.9.0

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON encodes a Duration as a JSON string formatted using String.

func (*Duration) UnmarshalJSON added in v0.9.0

func (d *Duration) UnmarshalJSON(buf []byte) error

UnmarshalJSON decodes a Duration from a JSON string parsed using time.ParseDuration.

type Error

type Error interface {
	error
	// Raised when user credentials or configuration is invalid.
	User() bool
	// Raised when a parsing error (e.g. JSON) occurs.
	Parse() bool
	// Raised when a network error occurs.
	Network() bool
}

Error represents an error returned from this library.

type Filter added in v0.9.0

type Filter struct {
	ID          string `json:"id,omitempty"`
	Expression  string `json:"expression"`
	Paused      bool   `json:"paused"`
	Description string `json:"description"`

	// Property is mentioned in documentation however isn't populated in
	// any of the API requests. For now, let's just omit it unless it's
	// provided.
	Ref string `json:"ref,omitempty"`
}

Filter holds the structure of the filter type.

type FilterDetailResponse added in v0.9.0

type FilterDetailResponse struct {
	Result     Filter `json:"result"`
	ResultInfo `json:"result_info"`
	Response
}

FilterDetailResponse is the API response that is returned for requesting a single filter on a zone.

type FilterValidateExpression added in v0.9.0

type FilterValidateExpression struct {
	Expression string `json:"expression"`
}

FilterValidateExpression represents the JSON payload for checking an expression.

type FilterValidateExpressionResponse added in v0.9.0

type FilterValidateExpressionResponse struct {
	Success bool                                `json:"success"`
	Errors  []FilterValidationExpressionMessage `json:"errors"`
}

FilterValidateExpressionResponse represents the API response for checking the expression. It conforms to the JSON API approach however we don't need all of the fields exposed.

type FilterValidationExpressionMessage added in v0.9.0

type FilterValidationExpressionMessage struct {
	Message string `json:"message"`
}

FilterValidationExpressionMessage represents the API error message.

type FiltersDetailResponse added in v0.9.0

type FiltersDetailResponse struct {
	Result     []Filter `json:"result"`
	ResultInfo `json:"result_info"`
	Response
}

FiltersDetailResponse is the API response that is returned for requesting all filters on a zone.

type FirewallRule added in v0.9.0

type FirewallRule struct {
	ID          string      `json:"id,omitempty"`
	Paused      bool        `json:"paused"`
	Description string      `json:"description"`
	Action      string      `json:"action"`
	Priority    interface{} `json:"priority"`
	Filter      Filter      `json:"filter"`
	CreatedOn   time.Time   `json:"created_on,omitempty"`
	ModifiedOn  time.Time   `json:"modified_on,omitempty"`
}

FirewallRule is the struct of the firewall rule.

type FirewallRuleResponse added in v0.9.0

type FirewallRuleResponse struct {
	Result     FirewallRule `json:"result"`
	ResultInfo `json:"result_info"`
	Response
}

FirewallRuleResponse is the API response that is returned for requesting a single firewall rule on a zone.

type FirewallRulesDetailResponse added in v0.9.0

type FirewallRulesDetailResponse struct {
	Result     []FirewallRule `json:"result"`
	ResultInfo `json:"result_info"`
	Response
}

FirewallRulesDetailResponse is the API response for the firewall rules.

type IPRanges added in v0.7.2

type IPRanges struct {
	IPv4CIDRs []string `json:"ipv4_cidrs"`
	IPv6CIDRs []string `json:"ipv6_cidrs"`
}

IPRanges contains lists of IPv4 and IPv6 CIDRs.

func IPs

func IPs() (IPRanges, error)

IPs gets a list of Cloudflare's IP ranges.

This does not require logging in to the API.

API reference: https://api.cloudflare.com/#cloudflare-ips

type IPsResponse added in v0.7.2

type IPsResponse struct {
	Response
	Result IPRanges `json:"result"`
}

IPsResponse is the API response containing a list of IPs.

type KeylessSSL added in v0.7.2

type KeylessSSL struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Host        string    `json:"host"`
	Port        int       `json:"port"`
	Status      string    `json:"success"`
	Enabled     bool      `json:"enabled"`
	Permissions []string  `json:"permissions"`
	CreatedOn   time.Time `json:"created_on"`
	ModifiedOn  time.Time `json:"modifed_on"`
}

KeylessSSL represents Keyless SSL configuration.

type KeylessSSLResponse added in v0.7.2

type KeylessSSLResponse struct {
	Response
	Result []KeylessSSL `json:"result"`
}

KeylessSSLResponse represents the response from the Keyless SSL endpoint.

type ListStorageKeysResponse added in v0.9.0

type ListStorageKeysResponse struct {
	Response
	Result     []StorageKey `json:"result"`
	ResultInfo `json:"result_info"`
}

ListStorageKeysResponse contains a slice of keys belonging to a storage namespace, pagination information, and an embedded response struct

type ListWorkersKVNamespacesResponse added in v0.9.0

type ListWorkersKVNamespacesResponse struct {
	Response
	Result     []WorkersKVNamespace `json:"result"`
	ResultInfo `json:"result_info"`
}

ListWorkersKVNamespacesResponse contains a slice of storage namespaces associated with an account, pagination information, and an embedded response struct

type LoadBalancer

type LoadBalancer struct {
	ID             string              `json:"id,omitempty"`
	CreatedOn      *time.Time          `json:"created_on,omitempty"`
	ModifiedOn     *time.Time          `json:"modified_on,omitempty"`
	Description    string              `json:"description"`
	Name           string              `json:"name"`
	TTL            int                 `json:"ttl,omitempty"`
	FallbackPool   string              `json:"fallback_pool"`
	DefaultPools   []string            `json:"default_pools"`
	RegionPools    map[string][]string `json:"region_pools"`
	PopPools       map[string][]string `json:"pop_pools"`
	Proxied        bool                `json:"proxied"`
	Enabled        *bool               `json:"enabled,omitempty"`
	Persistence    string              `json:"session_affinity,omitempty"`
	PersistenceTTL int                 `json:"session_affinity_ttl,omitempty"`

	// SteeringPolicy controls pool selection logic.
	// "off" select pools in DefaultPools order
	// "geo" select pools based on RegionPools/PopPools
	// "dynamic_latency" select pools based on RTT (requires health checks)
	// "random" selects pools in a random order
	// "" maps to "geo" if RegionPools or PopPools have entries otherwise "off"
	SteeringPolicy string `json:"steering_policy,omitempty"`
}

LoadBalancer represents a load balancer's properties.

type LoadBalancerMonitor added in v0.8.0

type LoadBalancerMonitor struct {
	ID              string              `json:"id,omitempty"`
	CreatedOn       *time.Time          `json:"created_on,omitempty"`
	ModifiedOn      *time.Time          `json:"modified_on,omitempty"`
	Type            string              `json:"type"`
	Description     string              `json:"description"`
	Method          string              `json:"method"`
	Path            string              `json:"path"`
	Header          map[string][]string `json:"header"`
	Timeout         int                 `json:"timeout"`
	Retries         int                 `json:"retries"`
	Interval        int                 `json:"interval"`
	Port            uint16              `json:"port,omitempty"`
	ExpectedBody    string              `json:"expected_body"`
	ExpectedCodes   string              `json:"expected_codes"`
	FollowRedirects bool                `json:"follow_redirects"`
	AllowInsecure   bool                `json:"allow_insecure"`
	ProbeZone       string              `json:"probe_zone"`
}

LoadBalancerMonitor represents a load balancer monitor's properties.

type LoadBalancerOrigin added in v0.8.0

type LoadBalancerOrigin struct {
	Name    string  `json:"name"`
	Address string  `json:"address"`
	Enabled bool    `json:"enabled"`
	Weight  float64 `json:"weight"`
}

LoadBalancerOrigin represents a Load Balancer origin's properties.

type LoadBalancerOriginHealth added in v0.9.0

type LoadBalancerOriginHealth struct {
	Healthy       bool     `json:"healthy,omitempty"`
	RTT           Duration `json:"rtt,omitempty"`
	FailureReason string   `json:"failure_reason,omitempty"`
	ResponseCode  int      `json:"response_code,omitempty"`
}

LoadBalancerOriginHealth represents the health of the origin.

type LoadBalancerPool added in v0.8.0

type LoadBalancerPool struct {
	ID                string               `json:"id,omitempty"`
	CreatedOn         *time.Time           `json:"created_on,omitempty"`
	ModifiedOn        *time.Time           `json:"modified_on,omitempty"`
	Description       string               `json:"description"`
	Name              string               `json:"name"`
	Enabled           bool                 `json:"enabled"`
	MinimumOrigins    int                  `json:"minimum_origins,omitempty"`
	Monitor           string               `json:"monitor,omitempty"`
	Origins           []LoadBalancerOrigin `json:"origins"`
	NotificationEmail string               `json:"notification_email,omitempty"`

	// CheckRegions defines the geographic region(s) from where to run health-checks from - e.g. "WNAM", "WEU", "SAF", "SAM".
	// Providing a null/empty value means "all regions", which may not be available to all plan types.
	CheckRegions []string `json:"check_regions"`
}

LoadBalancerPool represents a load balancer pool's properties.

type LoadBalancerPoolHealth added in v0.9.0

type LoadBalancerPoolHealth struct {
	ID        string                               `json:"pool_id,omitempty"`
	PopHealth map[string]LoadBalancerPoolPopHealth `json:"pop_health,omitempty"`
}

LoadBalancerPoolHealth represents the healthchecks from different PoPs for a pool.

type LoadBalancerPoolPopHealth added in v0.9.0

type LoadBalancerPoolPopHealth struct {
	Healthy bool                                  `json:"healthy,omitempty"`
	Origins []map[string]LoadBalancerOriginHealth `json:"origins,omitempty"`
}

LoadBalancerPoolPopHealth represents the health of the pool for given PoP.

type Logger added in v0.8.5

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger defines the interface this library needs to use logging This is a subset of the methods implemented in the log package

type LogpushDestinationExistsRequest added in v0.9.0

type LogpushDestinationExistsRequest struct {
	DestinationConf string `json:"destination_conf"`
}

LogpushDestinationExistsRequest is the API request for check destination exists.

type LogpushDestinationExistsResponse added in v0.9.0

type LogpushDestinationExistsResponse struct {
	Response
	Result struct {
		Exists bool `json:"exists"`
	}
}

LogpushDestinationExistsResponse is the API response, containing a destination exists check result.

type LogpushGetOwnershipChallenge added in v0.9.0

type LogpushGetOwnershipChallenge struct {
	Filename string `json:"filename"`
	Valid    bool   `json:"valid"`
	Message  string `json:"message"`
}

LogpushGetOwnershipChallenge describes a ownership validation.

type LogpushGetOwnershipChallengeRequest added in v0.9.0

type LogpushGetOwnershipChallengeRequest struct {
	DestinationConf string `json:"destination_conf"`
}

LogpushGetOwnershipChallengeRequest is the API request for get ownership challenge.

type LogpushGetOwnershipChallengeResponse added in v0.9.0

type LogpushGetOwnershipChallengeResponse struct {
	Response
	Result LogpushGetOwnershipChallenge `json:"result"`
}

LogpushGetOwnershipChallengeResponse is the API response, containing a ownership challenge.

type LogpushJob added in v0.9.0

type LogpushJob struct {
	ID                 int        `json:"id,omitempty"`
	Enabled            bool       `json:"enabled"`
	Name               string     `json:"name"`
	LogpullOptions     string     `json:"logpull_options"`
	DestinationConf    string     `json:"destination_conf"`
	OwnershipChallenge string     `json:"ownership_challenge,omitempty"`
	LastComplete       *time.Time `json:"last_complete,omitempty"`
	LastError          *time.Time `json:"last_error,omitempty"`
	ErrorMessage       string     `json:"error_message,omitempty"`
}

LogpushJob describes a Logpush job.

type LogpushJobDetailsResponse added in v0.9.0

type LogpushJobDetailsResponse struct {
	Response
	Result LogpushJob `json:"result"`
}

LogpushJobDetailsResponse is the API response, containing a single Logpush Job.

type LogpushJobsResponse added in v0.9.0

type LogpushJobsResponse struct {
	Response
	Result []LogpushJob `json:"result"`
}

LogpushJobsResponse is the API response, containing an array of Logpush Jobs.

type LogpushOwnershipChallangeValidationResponse added in v0.9.0

type LogpushOwnershipChallangeValidationResponse struct {
	Response
	Result struct {
		Valid bool `json:"valid"`
	}
}

LogpushOwnershipChallangeValidationResponse is the API response, containing a ownership challenge validation result.

type LogpushValidateOwnershipChallengeRequest added in v0.9.0

type LogpushValidateOwnershipChallengeRequest struct {
	DestinationConf    string `json:"destination_conf"`
	OwnershipChallenge string `json:"ownership_challenge"`
}

LogpushValidateOwnershipChallengeRequest is the API request for validate ownership challenge.

type Option added in v0.7.2

type Option func(*API) error

Option is a functional option for configuring the API client.

func HTTPClient added in v0.7.2

func HTTPClient(client *http.Client) Option

HTTPClient accepts a custom *http.Client for making API calls.

func Headers added in v0.7.2

func Headers(headers http.Header) Option

Headers allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging).

func UserAgent added in v0.9.0

func UserAgent(userAgent string) Option

UserAgent can be set if you want to send a software name and version for HTTP access logs. It is recommended to set it in order to help future Customer Support diagnostics and prevent collateral damage by sharing generic User-Agent string with abusive users. E.g. "my-software/1.2.3". By default generic Go User-Agent is used.

func UsingAccount added in v0.10.0

func UsingAccount(accountID string) Option

UsingAccount allows you to apply account-level changes (Load Balancing, Railguns) to an account instead.

func UsingLogger added in v0.8.5

func UsingLogger(logger Logger) Option

UsingLogger can be set if you want to get log output from this API instance By default no log output is emitted

func UsingRateLimit added in v0.8.5

func UsingRateLimit(rps float64) Option

UsingRateLimit applies a non-default rate limit to client API requests If not specified the default of 4rps will be applied

func UsingRetryPolicy added in v0.8.5

func UsingRetryPolicy(maxRetries int, minRetryDelaySecs int, maxRetryDelaySecs int) Option

UsingRetryPolicy applies a non-default number of retries and min/max retry delays This will be used when the client exponentially backs off after errored requests

type OriginCACertificate

type OriginCACertificate struct {
	ID              string    `json:"id"`
	Certificate     string    `json:"certificate"`
	Hostnames       []string  `json:"hostnames"`
	ExpiresOn       time.Time `json:"expires_on"`
	RequestType     string    `json:"request_type"`
	RequestValidity int       `json:"requested_validity"`
	CSR             string    `json:"csr"`
}

OriginCACertificate represents a Cloudflare-issued certificate.

API reference: https://api.cloudflare.com/#cloudflare-ca

type OriginCACertificateID added in v0.7.4

type OriginCACertificateID struct {
	ID string `json:"id"`
}

OriginCACertificateID represents the ID of the revoked certificate from the Revoke Certificate endpoint.

type OriginCACertificateListOptions added in v0.7.4

type OriginCACertificateListOptions struct {
	ZoneID string
}

OriginCACertificateListOptions represents the parameters used to list Cloudflare-issued certificates.

type Owner added in v0.7.2

type Owner struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	OwnerType string `json:"type"`
}

Owner describes the resource owner.

type PageRule added in v0.7.2

type PageRule struct {
	ID         string           `json:"id,omitempty"`
	Targets    []PageRuleTarget `json:"targets"`
	Actions    []PageRuleAction `json:"actions"`
	Priority   int              `json:"priority"`
	Status     string           `json:"status"` // can be: active, paused
	ModifiedOn time.Time        `json:"modified_on,omitempty"`
	CreatedOn  time.Time        `json:"created_on,omitempty"`
}

PageRule describes a Page Rule.

type PageRuleAction added in v0.7.2

type PageRuleAction struct {
	ID    string      `json:"id"`
	Value interface{} `json:"value"`
}

PageRuleAction is the action to take when the target is matched.

Valid IDs are:

always_online
always_use_https
automatic_https_rewrites
browser_cache_ttl
browser_check
bypass_cache_on_cookie
cache_by_device_type
cache_deception_armor
cache_level
cache_on_cookie
disable_apps
disable_performance
disable_railgun
disable_security
edge_cache_ttl
email_obfuscation
explicit_cache_control
forwarding_url
host_header_override
ip_geolocation
minify
mirage
opportunistic_encryption
origin_error_page_pass_thru
polish
resolve_override
respect_strong_etag
response_buffering
rocket_loader
security_level
server_side_exclude
sort_query_string_for_cache
ssl
true_client_ip_header
waf

type PageRuleDetailResponse added in v0.7.2

type PageRuleDetailResponse struct {
	Success  bool     `json:"success"`
	Errors   []string `json:"errors"`
	Messages []string `json:"messages"`
	Result   PageRule `json:"result"`
}

PageRuleDetailResponse is the API response, containing a single PageRule.

type PageRuleTarget added in v0.7.2

type PageRuleTarget struct {
	Target     string `json:"target"`
	Constraint struct {
		Operator string `json:"operator"`
		Value    string `json:"value"`
	} `json:"constraint"`
}

PageRuleTarget is the target to evaluate on a request.

Currently Target must always be "url" and Operator must be "matches". Value is the URL pattern to match against.

type PageRulesResponse added in v0.7.2

type PageRulesResponse struct {
	Success  bool       `json:"success"`
	Errors   []string   `json:"errors"`
	Messages []string   `json:"messages"`
	Result   []PageRule `json:"result"`
}

PageRulesResponse is the API response, containing an array of PageRules.

type PaginationOptions added in v0.8.5

type PaginationOptions struct {
	Page    int `json:"page,omitempty"`
	PerPage int `json:"per_page,omitempty"`
}

PaginationOptions can be passed to a list request to configure paging These values will be defaulted if omitted, and PerPage has min/max limits set by resource

type PurgeCacheRequest added in v0.7.2

type PurgeCacheRequest struct {
	Everything bool `json:"purge_everything,omitempty"`
	// Purge by filepath (exact match). Limit of 30
	Files []string `json:"files,omitempty"`
	// Purge by Tag (Enterprise only):
	// https://support.cloudflare.com/hc/en-us/articles/206596608-How-to-Purge-Cache-Using-Cache-Tags-Enterprise-only-
	Tags []string `json:"tags,omitempty"`
	// Purge by hostname - e.g. "assets.example.com"
	Hosts []string `json:"hosts,omitempty"`
}

PurgeCacheRequest represents the request format made to the purge endpoint.

type PurgeCacheResponse added in v0.7.2

type PurgeCacheResponse struct {
	Response
	Result struct {
		ID string `json:"id"`
	} `json:"result"`
}

PurgeCacheResponse represents the response from the purge endpoint.

type Railgun added in v0.7.2

type Railgun struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Status         string    `json:"status"`
	Enabled        bool      `json:"enabled"`
	ZonesConnected int       `json:"zones_connected"`
	Build          string    `json:"build"`
	Version        string    `json:"version"`
	Revision       string    `json:"revision"`
	ActivationKey  string    `json:"activation_key"`
	ActivatedOn    time.Time `json:"activated_on"`
	CreatedOn      time.Time `json:"created_on"`
	ModifiedOn     time.Time `json:"modified_on"`
	UpgradeInfo    struct {
		LatestVersion string `json:"latest_version"`
		DownloadLink  string `json:"download_link"`
	} `json:"upgrade_info"`
}

Railgun represents a Railgun's properties.

type RailgunDiagnosis added in v0.7.2

type RailgunDiagnosis struct {
	Method          string `json:"method"`
	HostName        string `json:"host_name"`
	HTTPStatus      int    `json:"http_status"`
	Railgun         string `json:"railgun"`
	URL             string `json:"url"`
	ResponseStatus  string `json:"response_status"`
	Protocol        string `json:"protocol"`
	ElapsedTime     string `json:"elapsed_time"`
	BodySize        string `json:"body_size"`
	BodyHash        string `json:"body_hash"`
	MissingHeaders  string `json:"missing_headers"`
	ConnectionClose bool   `json:"connection_close"`
	Cloudflare      string `json:"cloudflare"`
	CFRay           string `json:"cf-ray"`
	// NOTE: Cloudflare's online API documentation does not yet have definitions
	// for the following fields. See: https://api.cloudflare.com/#railgun-connections-for-a-zone-test-railgun-connection/
	CFWANError    string `json:"cf-wan-error"`
	CFCacheStatus string `json:"cf-cache-status"`
}

RailgunDiagnosis represents the test results from testing railgun connections to a zone.

type RailgunListOptions added in v0.7.2

type RailgunListOptions struct {
	Direction string
}

RailgunListOptions represents the parameters used to list railguns.

type RateLimit added in v0.8.5

type RateLimit struct {
	ID          string                  `json:"id,omitempty"`
	Disabled    bool                    `json:"disabled,omitempty"`
	Description string                  `json:"description,omitempty"`
	Match       RateLimitTrafficMatcher `json:"match"`
	Bypass      []RateLimitKeyValue     `json:"bypass,omitempty"`
	Threshold   int                     `json:"threshold"`
	Period      int                     `json:"period"`
	Action      RateLimitAction         `json:"action"`
	Correlate   *RateLimitCorrelate     `json:"correlate,omitempty"`
}

RateLimit is a policy than can be applied to limit traffic within a customer domain

type RateLimitAction added in v0.8.5

type RateLimitAction struct {
	Mode     string                   `json:"mode"`
	Timeout  int                      `json:"timeout"`
	Response *RateLimitActionResponse `json:"response"`
}

RateLimitAction is the action that will be taken when the rate limit threshold is reached

type RateLimitActionResponse added in v0.8.5

type RateLimitActionResponse struct {
	ContentType string `json:"content_type"`
	Body        string `json:"body"`
}

RateLimitActionResponse is the response that will be returned when rate limit action is triggered

type RateLimitCorrelate added in v0.9.0

type RateLimitCorrelate struct {
	By string `json:"by"`
}

RateLimitCorrelate pertainings to NAT support

type RateLimitKeyValue added in v0.8.5

type RateLimitKeyValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

RateLimitKeyValue is k-v formatted as expected in the rate limit description

type RateLimitRequestMatcher added in v0.8.5

type RateLimitRequestMatcher struct {
	Methods    []string `json:"methods,omitempty"`
	Schemes    []string `json:"schemes,omitempty"`
	URLPattern string   `json:"url,omitempty"`
}

RateLimitRequestMatcher contains the matching rules pertaining to requests

type RateLimitResponseMatcher added in v0.8.5

type RateLimitResponseMatcher struct {
	Statuses      []int                            `json:"status,omitempty"`
	OriginTraffic *bool                            `json:"origin_traffic,omitempty"` // api defaults to true so we need an explicit empty value
	Headers       []RateLimitResponseMatcherHeader `json:"headers,omitempty"`
}

RateLimitResponseMatcher contains the matching rules pertaining to responses

type RateLimitResponseMatcherHeader added in v0.9.0

type RateLimitResponseMatcherHeader struct {
	Name  string `json:"name"`
	Op    string `json:"op"`
	Value string `json:"value"`
}

RateLimitResponseMatcherHeader contains the structure of the origin HTTP headers used in request matcher checks.

type RateLimitTrafficMatcher added in v0.8.5

type RateLimitTrafficMatcher struct {
	Request  RateLimitRequestMatcher  `json:"request"`
	Response RateLimitResponseMatcher `json:"response"`
}

RateLimitTrafficMatcher contains the rules that will be used to apply a rate limit to traffic

type RawResponse added in v0.8.0

type RawResponse struct {
	Response
	Result json.RawMessage `json:"result"`
}

RawResponse keeps the result as JSON form

type RegistrantContact added in v0.9.0

type RegistrantContact struct {
	ID           string `json:"id"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Organization string `json:"organization"`
	Address      string `json:"address"`
	Address2     string `json:"address2"`
	City         string `json:"city"`
	State        string `json:"state"`
	Zip          string `json:"zip"`
	Country      string `json:"country"`
	Phone        string `json:"phone"`
	Email        string `json:"email"`
	Fax          string `json:"fax"`
}

RegistrantContact is the contact details for the domain registration.

type RegistrarDomain added in v0.9.0

type RegistrarDomain struct {
	ID                string              `json:"id"`
	Available         bool                `json:"available"`
	SupportedTLD      bool                `json:"supported_tld"`
	CanRegister       bool                `json:"can_register"`
	TransferIn        RegistrarTransferIn `json:"transfer_in"`
	CurrentRegistrar  string              `json:"current_registrar"`
	ExpiresAt         time.Time           `json:"expires_at"`
	RegistryStatuses  string              `json:"registry_statuses"`
	Locked            bool                `json:"locked"`
	CreatedAt         time.Time           `json:"created_at"`
	UpdatedAt         time.Time           `json:"updated_at"`
	RegistrantContact RegistrantContact   `json:"registrant_contact"`
}

RegistrarDomain is the structure of the API response for a new Cloudflare Registrar domain.

type RegistrarDomainConfiguration added in v0.9.0

type RegistrarDomainConfiguration struct {
	NameServers []string `json:"name_servers"`
	Privacy     bool     `json:"privacy"`
	Locked      bool     `json:"locked"`
	AutoRenew   bool     `json:"auto_renew"`
}

RegistrarDomainConfiguration is the structure for making updates to and existing domain.

type RegistrarDomainDetailResponse added in v0.9.0

type RegistrarDomainDetailResponse struct {
	Response
	Result RegistrarDomain `json:"result"`
}

RegistrarDomainDetailResponse is the structure of the detailed response from the API for a single domain.

type RegistrarDomainsDetailResponse added in v0.9.0

type RegistrarDomainsDetailResponse struct {
	Response
	Result []RegistrarDomain `json:"result"`
}

RegistrarDomainsDetailResponse is the structure of the detailed response from the API.

type RegistrarTransferIn added in v0.9.0

type RegistrarTransferIn struct {
	UnlockDomain      string `json:"unlock_domain"`
	DisablePrivacy    string `json:"disable_privacy"`
	EnterAuthCode     string `json:"enter_auth_code"`
	ApproveTransfer   string `json:"approve_transfer"`
	AcceptFoa         string `json:"accept_foa"`
	CanCancelTransfer bool   `json:"can_cancel_transfer"`
}

RegistrarTransferIn contains the structure for a domain transfer in request.

type ReqOption added in v0.9.0

type ReqOption func(opt *reqOption)

ReqOption is a functional option for configuring API requests

func WithPagination added in v0.9.0

func WithPagination(opts PaginationOptions) ReqOption

WithPagination configures the pagination for a response.

func WithZoneFilter added in v0.9.0

func WithZoneFilter(zone string) ReqOption

WithZoneFilter applies a filter based on zone name.

type Response added in v0.7.2

type Response struct {
	Success  bool           `json:"success"`
	Errors   []ResponseInfo `json:"errors"`
	Messages []ResponseInfo `json:"messages"`
}

Response is a template. There will also be a result struct. There will be a unique response type for each response, which will include this type.

type ResponseInfo added in v0.7.2

type ResponseInfo struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ResponseInfo contains a code and message returned by the API as errors or informational messages inside the response.

type ResultInfo added in v0.7.2

type ResultInfo struct {
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	TotalPages int `json:"total_pages"`
	Count      int `json:"count"`
	Total      int `json:"total_count"`
}

ResultInfo contains metadata about the Response.

type RetryPolicy added in v0.8.5

type RetryPolicy struct {
	MaxRetries    int
	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

RetryPolicy specifies number of retries and min/max retry delays This config is used when the client exponentially backs off after errored requests

type SpectrumApplication added in v0.9.0

type SpectrumApplication struct {
	ID            string                        `json:"id,omitempty"`
	Protocol      string                        `json:"protocol,omitempty"`
	IPv4          bool                          `json:"ipv4,omitempty"`
	DNS           SpectrumApplicationDNS        `json:"dns,omitempty"`
	OriginDirect  []string                      `json:"origin_direct,omitempty"`
	OriginPort    int                           `json:"origin_port,omitempty"`
	OriginDNS     *SpectrumApplicationOriginDNS `json:"origin_dns,omitempty"`
	IPFirewall    bool                          `json:"ip_firewall,omitempty"`
	ProxyProtocol bool                          `json:"proxy_protocol,omitempty"`
	TLS           string                        `json:"tls,omitempty"`
	CreatedOn     *time.Time                    `json:"created_on,omitempty"`
	ModifiedOn    *time.Time                    `json:"modified_on,omitempty"`
}

SpectrumApplication defines a single Spectrum Application.

type SpectrumApplicationDNS added in v0.9.0

type SpectrumApplicationDNS struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

SpectrumApplicationDNS holds the external DNS configuration for a Spectrum Application.

type SpectrumApplicationDetailResponse added in v0.9.0

type SpectrumApplicationDetailResponse struct {
	Response
	Result SpectrumApplication `json:"result"`
}

SpectrumApplicationDetailResponse is the structure of the detailed response from the API.

type SpectrumApplicationOriginDNS added in v0.9.0

type SpectrumApplicationOriginDNS struct {
	Name string `json:"name"`
}

SpectrumApplicationOriginDNS holds the origin DNS configuration for a Spectrum Application.

type SpectrumApplicationsDetailResponse added in v0.9.0

type SpectrumApplicationsDetailResponse struct {
	Response
	Result []SpectrumApplication `json:"result"`
}

SpectrumApplicationsDetailResponse is the structure of the detailed response from the API.

type StorageKey added in v0.9.0

type StorageKey struct {
	Name string `json:"name"`
}

StorageKey is a key name used to identify a storage value

type UniversalSSLSetting added in v0.9.0

type UniversalSSLSetting struct {
	Enabled bool `json:"enabled"`
}

UniversalSSLSetting represents a universal ssl setting's properties.

type UniversalSSLVerificationDetails added in v0.10.0

type UniversalSSLVerificationDetails struct {
	CertificateStatus  string                       `json:"certificate_status"`
	VerificationType   string                       `json:"verification_type"`
	ValidationMethod   string                       `json:"validation_method"`
	CertPackUUID       string                       `json:"cert_pack_uuid"`
	VerificationStatus bool                         `json:"verification_status"`
	BrandCheck         bool                         `json:"brand_check"`
	VerificationInfo   UniversalSSLVerificationInfo `json:"verification_info"`
}

UniversalSSLVerificationDetails represents a universal ssl verifcation's properties.

type UniversalSSLVerificationInfo added in v0.10.0

type UniversalSSLVerificationInfo struct {
	RecordName   string `json:"record_name"`
	RecordTarget string `json:"record_target"`
}

UniversalSSLVerificationInfo represents DCV record.

type User added in v0.7.2

type User struct {
	ID         string     `json:"id,omitempty"`
	Email      string     `json:"email,omitempty"`
	FirstName  string     `json:"first_name,omitempty"`
	LastName   string     `json:"last_name,omitempty"`
	Username   string     `json:"username,omitempty"`
	Telephone  string     `json:"telephone,omitempty"`
	Country    string     `json:"country,omitempty"`
	Zipcode    string     `json:"zipcode,omitempty"`
	CreatedOn  *time.Time `json:"created_on,omitempty"`
	ModifiedOn *time.Time `json:"modified_on,omitempty"`
	APIKey     string     `json:"api_key,omitempty"`
	TwoFA      bool       `json:"two_factor_authentication_enabled,omitempty"`
	Betas      []string   `json:"betas,omitempty"`
	Accounts   []Account  `json:"organizations,omitempty"`
}

User describes a user account.

type UserAgentRule added in v0.8.0

type UserAgentRule struct {
	ID            string              `json:"id"`
	Description   string              `json:"description"`
	Mode          string              `json:"mode"`
	Configuration UserAgentRuleConfig `json:"configuration"`
	Paused        bool                `json:"paused"`
}

UserAgentRule represents a User-Agent Block. These rules can be used to challenge, block or whitelist specific User-Agents for a given zone.

type UserAgentRuleConfig added in v0.8.0

type UserAgentRuleConfig ZoneLockdownConfig

UserAgentRuleConfig represents a Zone Lockdown config, which comprises a Target ("ip" or "ip_range") and a Value (an IP address or IP+mask, respectively.)

type UserAgentRuleListResponse added in v0.8.0

type UserAgentRuleListResponse struct {
	Result []UserAgentRule `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

UserAgentRuleListResponse represents a response from the List Zone Lockdown endpoint.

type UserAgentRuleResponse added in v0.8.0

type UserAgentRuleResponse struct {
	Result UserAgentRule `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

UserAgentRuleResponse represents a response from the Zone Lockdown endpoint.

type UserBillingProfile added in v0.7.3

type UserBillingProfile struct {
	ID              string     `json:"id,omitempty"`
	FirstName       string     `json:"first_name,omitempty"`
	LastName        string     `json:"last_name,omitempty"`
	Address         string     `json:"address,omitempty"`
	Address2        string     `json:"address2,omitempty"`
	Company         string     `json:"company,omitempty"`
	City            string     `json:"city,omitempty"`
	State           string     `json:"state,omitempty"`
	ZipCode         string     `json:"zipcode,omitempty"`
	Country         string     `json:"country,omitempty"`
	Telephone       string     `json:"telephone,omitempty"`
	CardNumber      string     `json:"card_number,omitempty"`
	CardExpiryYear  int        `json:"card_expiry_year,omitempty"`
	CardExpiryMonth int        `json:"card_expiry_month,omitempty"`
	VAT             string     `json:"vat,omitempty"`
	CreatedOn       *time.Time `json:"created_on,omitempty"`
	EditedOn        *time.Time `json:"edited_on,omitempty"`
}

UserBillingProfile contains Billing Profile information.

type UserError added in v0.7.2

type UserError struct {
	Err error
}

UserError represents a user-generated error.

func (*UserError) Error added in v0.7.2

func (e *UserError) Error() string

Error wraps the underlying error.

func (*UserError) Network added in v0.7.2

func (e *UserError) Network() bool

Network error.

func (*UserError) Parse added in v0.7.2

func (e *UserError) Parse() bool

Parse error.

func (*UserError) User added in v0.7.2

func (e *UserError) User() bool

User is a user-caused error.

type UserResponse added in v0.7.2

type UserResponse struct {
	Response
	Result User `json:"result"`
}

UserResponse wraps a response containing User accounts.

type VirtualDNS added in v0.7.2

type VirtualDNS struct {
	ID                   string   `json:"id"`
	Name                 string   `json:"name"`
	OriginIPs            []string `json:"origin_ips"`
	VirtualDNSIPs        []string `json:"virtual_dns_ips"`
	MinimumCacheTTL      uint     `json:"minimum_cache_ttl"`
	MaximumCacheTTL      uint     `json:"maximum_cache_ttl"`
	DeprecateAnyRequests bool     `json:"deprecate_any_requests"`
	ModifiedOn           string   `json:"modified_on"`
}

VirtualDNS represents a Virtual DNS configuration.

type VirtualDNSAnalytics added in v0.9.0

type VirtualDNSAnalytics struct {
	Totals VirtualDNSAnalyticsMetrics `json:"totals"`
	Min    VirtualDNSAnalyticsMetrics `json:"min"`
	Max    VirtualDNSAnalyticsMetrics `json:"max"`
}

VirtualDNSAnalytics represents a set of aggregated Virtual DNS metrics. TODO: Add the queried data and not only the aggregated values.

type VirtualDNSAnalyticsMetrics added in v0.9.0

type VirtualDNSAnalyticsMetrics struct {
	QueryCount         *int64   `json:"queryCount"`
	UncachedCount      *int64   `json:"uncachedCount"`
	StaleCount         *int64   `json:"staleCount"`
	ResponseTimeAvg    *float64 `json:"responseTimeAvg"`
	ResponseTimeMedian *float64 `json:"responseTimeMedian"`
	ResponseTime90th   *float64 `json:"responseTime90th"`
	ResponseTime99th   *float64 `json:"responseTime99th"`
}

VirtualDNSAnalyticsMetrics respresents a group of aggregated Virtual DNS metrics.

type VirtualDNSAnalyticsResponse added in v0.9.0

type VirtualDNSAnalyticsResponse struct {
	Response
	Result VirtualDNSAnalytics `json:"result"`
}

VirtualDNSAnalyticsResponse represents a Virtual DNS analytics response.

type VirtualDNSListResponse added in v0.7.2

type VirtualDNSListResponse struct {
	Response
	Result []*VirtualDNS `json:"result"`
}

VirtualDNSListResponse represents an array of Virtual DNS responses.

type VirtualDNSResponse added in v0.7.2

type VirtualDNSResponse struct {
	Response
	Result *VirtualDNS `json:"result"`
}

VirtualDNSResponse represents a Virtual DNS response.

type VirtualDNSUserAnalyticsOptions added in v0.9.0

type VirtualDNSUserAnalyticsOptions struct {
	Metrics []string
	Since   *time.Time
	Until   *time.Time
}

VirtualDNSUserAnalyticsOptions represents range and dimension selection on analytics endpoint

type WAFGroup added in v0.10.0

type WAFGroup struct {
	ID                 string   `json:"id"`
	Name               string   `json:"name"`
	Description        string   `json:"description"`
	RulesCount         int      `json:"rules_count"`
	ModifiedRulesCount int      `json:"modified_rules_count"`
	PackageID          string   `json:"package_id"`
	Mode               string   `json:"mode"`
	AllowedModes       []string `json:"allowed_modes"`
}

WAFGroup represents a WAF rule group.

type WAFGroupsResponse added in v0.10.0

type WAFGroupsResponse struct {
	Response
	Result     []WAFGroup `json:"result"`
	ResultInfo ResultInfo `json:"result_info"`
}

WAFGroupsResponse represents the response from the WAF groups endpoint.

type WAFPackage added in v0.7.2

type WAFPackage struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	ZoneID        string `json:"zone_id"`
	DetectionMode string `json:"detection_mode"`
	Sensitivity   string `json:"sensitivity"`
	ActionMode    string `json:"action_mode"`
}

WAFPackage represents a WAF package configuration.

type WAFPackageOptions added in v0.10.0

type WAFPackageOptions struct {
	Sensitivity string `json:"sensitivity,omitempty"`
	ActionMode  string `json:"action_mode,omitempty"`
}

WAFPackageOptions represents options to edit a WAF package.

type WAFPackageResponse added in v0.10.0

type WAFPackageResponse struct {
	Response
	Result     WAFPackage `json:"result"`
	ResultInfo ResultInfo `json:"result_info"`
}

WAFPackageResponse represents the response from the WAF package endpoint.

type WAFPackagesResponse added in v0.7.2

type WAFPackagesResponse struct {
	Response
	Result     []WAFPackage `json:"result"`
	ResultInfo ResultInfo   `json:"result_info"`
}

WAFPackagesResponse represents the response from the WAF packages endpoint.

type WAFRule added in v0.7.2

type WAFRule struct {
	ID          string `json:"id"`
	Description string `json:"description"`
	Priority    string `json:"priority"`
	PackageID   string `json:"package_id"`
	Group       struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"group"`
	Mode         string   `json:"mode"`
	DefaultMode  string   `json:"default_mode"`
	AllowedModes []string `json:"allowed_modes"`
}

WAFRule represents a WAF rule.

type WAFRuleOptions added in v0.9.0

type WAFRuleOptions struct {
	Mode string `json:"mode"`
}

WAFRuleOptions is a subset of WAFRule, for editable options.

type WAFRuleResponse added in v0.9.0

type WAFRuleResponse struct {
	Response
	Result     WAFRule    `json:"result"`
	ResultInfo ResultInfo `json:"result_info"`
}

WAFRuleResponse represents the response from the WAF rule endpoint.

type WAFRulesResponse added in v0.7.2

type WAFRulesResponse struct {
	Response
	Result     []WAFRule  `json:"result"`
	ResultInfo ResultInfo `json:"result_info"`
}

WAFRulesResponse represents the response from the WAF rules endpoint.

type WorkerListResponse added in v0.9.0

type WorkerListResponse struct {
	Response
	WorkerList []WorkerMetaData `json:"result"`
}

WorkerListResponse wrapper struct for API response to worker script list API call

type WorkerMetaData added in v0.9.0

type WorkerMetaData struct {
	ID         string    `json:"id,omitempty"`
	ETAG       string    `json:"etag,omitempty"`
	Size       int       `json:"size,omitempty"`
	CreatedOn  time.Time `json:"created_on,omitempty"`
	ModifiedOn time.Time `json:"modified_on,omitempty"`
}

WorkerMetaData contains worker script information such as size, creation & modification dates

type WorkerRequestParams added in v0.9.0

type WorkerRequestParams struct {
	ZoneID     string
	ScriptName string
}

WorkerRequestParams provides parameters for worker requests for both enterprise and standard requests

type WorkerRoute added in v0.9.0

type WorkerRoute struct {
	ID      string `json:"id,omitempty"`
	Pattern string `json:"pattern"`
	Enabled bool   `json:"enabled"`
	Script  string `json:"script,omitempty"`
}

WorkerRoute aka filters are patterns used to enable or disable workers that match requests.

API reference: https://api.cloudflare.com/#worker-filters-properties

type WorkerRouteResponse added in v0.9.0

type WorkerRouteResponse struct {
	Response
	WorkerRoute `json:"result"`
}

WorkerRouteResponse embeds Response struct and a single WorkerRoute

type WorkerRoutesResponse added in v0.9.0

type WorkerRoutesResponse struct {
	Response
	Routes []WorkerRoute `json:"result"`
}

WorkerRoutesResponse embeds Response struct and slice of WorkerRoutes

type WorkerScript added in v0.9.0

type WorkerScript struct {
	WorkerMetaData
	Script string `json:"script"`
}

WorkerScript Cloudflare Worker struct with metadata

type WorkerScriptResponse added in v0.9.0

type WorkerScriptResponse struct {
	Response
	WorkerScript `json:"result"`
}

WorkerScriptResponse wrapper struct for API response to worker script calls

type WorkersKVNamespace added in v0.9.0

type WorkersKVNamespace struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

WorkersKVNamespace contains the unique identifier and title of a storage namespace

type WorkersKVNamespaceRequest added in v0.9.0

type WorkersKVNamespaceRequest struct {
	Title string `json:"title"`
}

WorkersKVNamespaceRequest provides parameters for creating and updating storage namespaces

type WorkersKVNamespaceResponse added in v0.9.0

type WorkersKVNamespaceResponse struct {
	Response
	Result WorkersKVNamespace `json:"result"`
}

WorkersKVNamespaceResponse is the response received when creating storage namespaces

type Zone added in v0.7.2

type Zone struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// DevMode contains the time in seconds until development expires (if
	// positive) or since it expired (if negative). It will be 0 if never used.
	DevMode           int       `json:"development_mode"`
	OriginalNS        []string  `json:"original_name_servers"`
	OriginalRegistrar string    `json:"original_registrar"`
	OriginalDNSHost   string    `json:"original_dnshost"`
	CreatedOn         time.Time `json:"created_on"`
	ModifiedOn        time.Time `json:"modified_on"`
	NameServers       []string  `json:"name_servers"`
	Owner             Owner     `json:"owner"`
	Permissions       []string  `json:"permissions"`
	Plan              ZonePlan  `json:"plan"`
	PlanPending       ZonePlan  `json:"plan_pending,omitempty"`
	Status            string    `json:"status"`
	Paused            bool      `json:"paused"`
	Type              string    `json:"type"`
	Host              struct {
		Name    string
		Website string
	} `json:"host"`
	VanityNS    []string `json:"vanity_name_servers"`
	Betas       []string `json:"betas"`
	DeactReason string   `json:"deactivation_reason"`
	Meta        ZoneMeta `json:"meta"`
	Account     Account  `json:"account"`
}

Zone describes a Cloudflare zone.

type ZoneAnalytics added in v0.7.2

type ZoneAnalytics struct {
	Since    time.Time `json:"since"`
	Until    time.Time `json:"until"`
	Requests struct {
		All         int            `json:"all"`
		Cached      int            `json:"cached"`
		Uncached    int            `json:"uncached"`
		ContentType map[string]int `json:"content_type"`
		Country     map[string]int `json:"country"`
		SSL         struct {
			Encrypted   int `json:"encrypted"`
			Unencrypted int `json:"unencrypted"`
		} `json:"ssl"`
		HTTPStatus map[string]int `json:"http_status"`
	} `json:"requests"`
	Bandwidth struct {
		All         int            `json:"all"`
		Cached      int            `json:"cached"`
		Uncached    int            `json:"uncached"`
		ContentType map[string]int `json:"content_type"`
		Country     map[string]int `json:"country"`
		SSL         struct {
			Encrypted   int `json:"encrypted"`
			Unencrypted int `json:"unencrypted"`
		} `json:"ssl"`
	} `json:"bandwidth"`
	Threats struct {
		All     int            `json:"all"`
		Country map[string]int `json:"country"`
		Type    map[string]int `json:"type"`
	} `json:"threats"`
	Pageviews struct {
		All           int            `json:"all"`
		SearchEngines map[string]int `json:"search_engines"`
	} `json:"pageviews"`
	Uniques struct {
		All int `json:"all"`
	}
}

ZoneAnalytics contains analytics data for a zone.

type ZoneAnalyticsColocation added in v0.7.2

type ZoneAnalyticsColocation struct {
	ColocationID string          `json:"colo_id"`
	Timeseries   []ZoneAnalytics `json:"timeseries"`
}

ZoneAnalyticsColocation contains analytics data by datacenter.

type ZoneAnalyticsData added in v0.7.2

type ZoneAnalyticsData struct {
	Totals     ZoneAnalytics   `json:"totals"`
	Timeseries []ZoneAnalytics `json:"timeseries"`
}

ZoneAnalyticsData contains totals and timeseries analytics data for a zone.

type ZoneAnalyticsOptions added in v0.7.2

type ZoneAnalyticsOptions struct {
	Since      *time.Time
	Until      *time.Time
	Continuous *bool
}

ZoneAnalyticsOptions represents the optional parameters in Zone Analytics endpoint requests.

type ZoneCustomSSL added in v0.7.2

type ZoneCustomSSL struct {
	ID              string                       `json:"id"`
	Hosts           []string                     `json:"hosts"`
	Issuer          string                       `json:"issuer"`
	Signature       string                       `json:"signature"`
	Status          string                       `json:"status"`
	BundleMethod    string                       `json:"bundle_method"`
	GeoRestrictions ZoneCustomSSLGeoRestrictions `json:"geo_restrictions"`
	ZoneID          string                       `json:"zone_id"`
	UploadedOn      time.Time                    `json:"uploaded_on"`
	ModifiedOn      time.Time                    `json:"modified_on"`
	ExpiresOn       time.Time                    `json:"expires_on"`
	Priority        int                          `json:"priority"`
	KeylessServer   KeylessSSL                   `json:"keyless_server"`
}

ZoneCustomSSL represents custom SSL certificate metadata.

type ZoneCustomSSLGeoRestrictions added in v0.9.4

type ZoneCustomSSLGeoRestrictions struct {
	Label string `json:"label"`
}

ZoneCustomSSLGeoRestrictions represents the parameter to create or update geographic restrictions on a custom ssl certificate.

type ZoneCustomSSLOptions added in v0.7.2

type ZoneCustomSSLOptions struct {
	Certificate     string                       `json:"certificate"`
	PrivateKey      string                       `json:"private_key"`
	BundleMethod    string                       `json:"bundle_method,omitempty"`
	GeoRestrictions ZoneCustomSSLGeoRestrictions `json:"geo_restrictions,omitempty"`
	Type            string                       `json:"type,omitempty"`
}

ZoneCustomSSLOptions represents the parameters to create or update an existing custom SSL configuration.

type ZoneCustomSSLPriority added in v0.7.2

type ZoneCustomSSLPriority struct {
	ID       string `json:"ID"`
	Priority int    `json:"priority"`
}

ZoneCustomSSLPriority represents a certificate's ID and priority. It is a subset of ZoneCustomSSL used for patch requests.

type ZoneID added in v0.7.2

type ZoneID struct {
	ID string `json:"id"`
}

ZoneID contains only the zone ID.

type ZoneIDResponse added in v0.7.2

type ZoneIDResponse struct {
	Response
	Result ZoneID `json:"result"`
}

ZoneIDResponse represents the response from the Zone endpoint, containing only a zone ID.

type ZoneLockdown added in v0.8.0

type ZoneLockdown struct {
	ID             string               `json:"id"`
	Description    string               `json:"description"`
	URLs           []string             `json:"urls"`
	Configurations []ZoneLockdownConfig `json:"configurations"`
	Paused         bool                 `json:"paused"`
	Priority       int                  `json:"priority,omitempty"`
}

ZoneLockdown represents a Zone Lockdown rule. A rule only permits access to the provided URL pattern(s) from the given IP address(es) or subnet(s).

type ZoneLockdownConfig added in v0.8.0

type ZoneLockdownConfig struct {
	Target string `json:"target"`
	Value  string `json:"value"`
}

ZoneLockdownConfig represents a Zone Lockdown config, which comprises a Target ("ip" or "ip_range") and a Value (an IP address or IP+mask, respectively.)

type ZoneLockdownListResponse added in v0.8.0

type ZoneLockdownListResponse struct {
	Result []ZoneLockdown `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

ZoneLockdownListResponse represents a response from the List Zone Lockdown endpoint.

type ZoneLockdownResponse added in v0.8.0

type ZoneLockdownResponse struct {
	Result ZoneLockdown `json:"result"`
	Response
	ResultInfo `json:"result_info"`
}

ZoneLockdownResponse represents a response from the Zone Lockdown endpoint.

type ZoneMeta added in v0.7.2

type ZoneMeta struct {
	// custom_certificate_quota is broken - sometimes it's a string, sometimes a number!
	// CustCertQuota     int    `json:"custom_certificate_quota"`
	PageRuleQuota     int  `json:"page_rule_quota"`
	WildcardProxiable bool `json:"wildcard_proxiable"`
	PhishingDetected  bool `json:"phishing_detected"`
}

ZoneMeta describes metadata about a zone.

type ZoneOptions added in v0.7.2

type ZoneOptions struct {
	Paused   *bool     `json:"paused,omitempty"`
	VanityNS []string  `json:"vanity_name_servers,omitempty"`
	Plan     *ZonePlan `json:"plan,omitempty"`
}

ZoneOptions is a subset of Zone, for editable options.

type ZonePlan added in v0.7.2

type ZonePlan struct {
	ZonePlanCommon
	IsSubscribed      bool   `json:"is_subscribed"`
	CanSubscribe      bool   `json:"can_subscribe"`
	LegacyID          string `json:"legacy_id"`
	LegacyDiscount    bool   `json:"legacy_discount"`
	ExternallyManaged bool   `json:"externally_managed"`
}

ZonePlan contains the plan information for a zone.

type ZonePlanCommon added in v0.9.0

type ZonePlanCommon struct {
	ID        string `json:"id"`
	Name      string `json:"name,omitempty"`
	Price     int    `json:"price,omitempty"`
	Currency  string `json:"currency,omitempty"`
	Frequency string `json:"frequency,omitempty"`
}

ZonePlanCommon contains fields used by various Plan endpoints

type ZoneRailgun added in v0.7.2

type ZoneRailgun struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Enabled   bool   `json:"enabled"`
	Connected bool   `json:"connected"`
}

ZoneRailgun represents the status of a Railgun on a zone.

type ZoneRatePlan added in v0.7.4

type ZoneRatePlan struct {
	ZonePlanCommon
	Components []zoneRatePlanComponents `json:"components,omitempty"`
}

ZoneRatePlan contains the plan information for a zone.

type ZoneRatePlanResponse added in v0.7.4

type ZoneRatePlanResponse struct {
	Response
	Result ZoneRatePlan `json:"result"`
}

ZoneRatePlanResponse represents the response from the Plan Details endpoint.

type ZoneResponse added in v0.7.2

type ZoneResponse struct {
	Response
	Result Zone `json:"result"`
}

ZoneResponse represents the response from the Zone endpoint containing a single zone.

type ZoneSSLSetting added in v0.7.4

type ZoneSSLSetting struct {
	ID                string `json:"id"`
	Editable          bool   `json:"editable"`
	ModifiedOn        string `json:"modified_on"`
	Value             string `json:"value"`
	CertificateStatus string `json:"certificate_status"`
}

ZoneSSLSetting contains ssl setting for a zone.

type ZoneSSLSettingResponse added in v0.7.4

type ZoneSSLSettingResponse struct {
	Response
	Result ZoneSSLSetting `json:"result"`
}

ZoneSSLSettingResponse represents the response from the Zone SSL Setting endpoint.

type ZoneSetting added in v0.7.2

type ZoneSetting struct {
	ID            string      `json:"id"`
	Editable      bool        `json:"editable"`
	ModifiedOn    string      `json:"modified_on"`
	Value         interface{} `json:"value"`
	TimeRemaining int         `json:"time_remaining"`
}

ZoneSetting contains settings for a zone.

type ZoneSettingResponse added in v0.7.2

type ZoneSettingResponse struct {
	Response
	Result []ZoneSetting `json:"result"`
}

ZoneSettingResponse represents the response from the Zone Setting endpoint.

type ZonesResponse added in v0.7.2

type ZonesResponse struct {
	Response
	Result     []Zone `json:"result"`
	ResultInfo `json:"result_info"`
}

ZonesResponse represents the response from the Zone endpoint containing an array of zones.

Directories

Path Synopsis
cmd
internal
tools Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL