cloudflare-go: github.com/cloudflare/cloudflare-go Index | Examples | Files

package cloudflare

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

Package cloudflare implements the Cloudflare v4 API.

Code:

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)
    }
}

Index

Examples

Package Files

cloudflare.go cpage.go custom_hostname.go dns.go errors.go firewall.go ips.go keyless.go load_balancing.go lockdown.go options.go organizations.go origin_ca.go page_rules.go railgun.go rate_limiting.go ssl.go user.go user_agent.go virtualdns.go waf.go zone.go

Constants

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
)

Variables

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",
    "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.

type API Uses

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

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

func New Uses

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

New creates a new Cloudflare v4 API client.

func (*API) AvailableZoneRatePlans Uses

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) ChangePageRule Uses

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) ConnectZoneRailgun Uses

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) CreateCustomHostname Uses

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 Uses

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) CreateKeyless Uses

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 Uses

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 Uses

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 Uses

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) CreateOrganizationAccessRule Uses

func (api *API) CreateOrganizationAccessRule(organizationID string, accessRule AccessRule) (*AccessRuleResponse, error)

CreateOrganizationAccessRule creates a firewall access rule for the given organization identifier.

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

func (*API) CreateOriginCertificate Uses

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 Uses

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

Code:

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)

func (*API) CreateRailgun Uses

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 Uses

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

Code:

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)

func (*API) CreateSSL Uses

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) CreateUserAccessRule Uses

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 Uses

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 Uses

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) CreateZone Uses

func (api *API) CreateZone(name string, jumpstart bool, org Organization) (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 Organization is non-empty, it must have at least the ID field populated. This will add the new zone to the specified multi-user organization.

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

func (*API) CreateZoneAccessRule Uses

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 Uses

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

func (*API) CustomHostname Uses

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 Uses

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 Uses

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) DNSRecord Uses

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 Uses

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

Code:

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)
}

Code:

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)
}

Code:

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)
}

Code:

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)
}

func (*API) DeleteCustomHostname Uses

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 Uses

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) DeleteKeyless Uses

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 Uses

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 Uses

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 Uses

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) DeleteOrganizationAccessRule Uses

func (api *API) DeleteOrganizationAccessRule(organizationID, accessRuleID string) (*AccessRuleResponse, error)

DeleteOrganizationAccessRule deletes a single access rule for the given organization and access rule identifiers.

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

func (*API) DeletePageRule Uses

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

Code:

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)
}

func (*API) DeleteRailgun Uses

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 Uses

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

Code:

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)
}

func (*API) DeleteSSL Uses

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) DeleteUserAccessRule Uses

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 Uses

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 Uses

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) DeleteZone Uses

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 Uses

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 Uses

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 Uses

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 Uses

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) EditZone Uses

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 Uses

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) Keyless Uses

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) ListAllRateLimits Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

func (*API) ListOrganizationAccessRules Uses

func (api *API) ListOrganizationAccessRules(organizationID string, accessRule AccessRule, page int) (*AccessRuleListResponse, error)

ListOrganizationAccessRules returns a slice of access rules for the given organization identifier.

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

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

func (*API) ListOrganizations Uses

func (api *API) ListOrganizations() ([]Organization, ResultInfo, error)

ListOrganizations lists organizations of the logged-in user.

API reference: https://api.cloudflare.com/#user-s-organizations-list-organizations

func (*API) ListPageRules Uses

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

Code:

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)
}

func (*API) ListRailguns Uses

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 Uses

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

Code:

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)
}

func (*API) ListSSL Uses

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 Uses

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 Uses

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

Code:

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)
}

func (*API) ListVirtualDNS Uses

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) ListWAFPackages Uses

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

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

func (*API) ListWAFRules Uses

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

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

func (*API) ListZoneAccessRules Uses

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

Code:

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)
}

Code:

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)
}

Code:

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)
}

Code:

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)
}

func (*API) ListZoneLockdowns Uses

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

Code:

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)
}

func (*API) ListZones Uses

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

Code:

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

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

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

Code:

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)
}

func (*API) LoadBalancerDetails Uses

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 Uses

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 Uses

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) ModifyLoadBalancer Uses

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 Uses

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 Uses

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) OrganizationDetails Uses

func (api *API) OrganizationDetails(organizationID string) (OrganizationDetails, error)

OrganizationDetails returns details for the specified organization of the logged-in user.

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

func (*API) OrganizationInvites Uses

func (api *API) OrganizationInvites(organizationID string) ([]OrganizationInvite, ResultInfo, error)

OrganizationInvites returns list of invites for specified organization of the logged-in user.

API reference: https://api.cloudflare.com/#organization-invites

func (*API) OrganizationMembers Uses

func (api *API) OrganizationMembers(organizationID string) ([]OrganizationMember, ResultInfo, error)

OrganizationMembers returns list of members for specified organization of the logged-in user.

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

func (*API) OrganizationRoles Uses

func (api *API) OrganizationRoles(organizationID string) ([]OrganizationRole, ResultInfo, error)

OrganizationRoles returns list of roles for specified organization of the logged-in user.

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

func (*API) OriginCertificate Uses

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 Uses

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 Uses

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

Code:

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)

func (*API) PurgeCache Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

Code:

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)

func (*API) Raw Uses

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) ReprioritizeSSL Uses

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) RevokeOriginCertificate Uses

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 Uses

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 Uses

func (api *API) SetAuthType(authType int)

SetAuthType sets the authentication method (AuthyKeyEmail or AuthUserService).

func (*API) TestRailgunConnection Uses

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) UpdateCustomHostnameSSL Uses

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) UpdateDNSRecord Uses

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) UpdateKeyless Uses

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) UpdateOrganizationAccessRule Uses

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

UpdateOrganizationAccessRule updates a single access rule for the given organization & access rule identifiers.

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

func (*API) UpdatePageRule Uses

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 Uses

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) UpdateSSL Uses

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) UpdateUser Uses

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 Uses

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 Uses

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 Uses

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) UpdateZoneAccessRule Uses

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 Uses

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 Uses

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) UserAgentRule Uses

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 Uses

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 Uses

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) VirtualDNS Uses

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) ZoneActivationCheck Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

ZoneIDByName retrieves a zone's ID from the name.

func (*API) ZoneLockdown Uses

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 Uses

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 Uses

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 Uses

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 Uses

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) ZoneSetRatePlan Uses

func (api *API) ZoneSetRatePlan(zoneID string, plan ZoneRatePlan) (Zone, error)

ZoneSetRatePlan changes the zone plan.

func (*API) ZoneSetVanityNS Uses

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 Uses

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 AccessRule Uses

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 Uses

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

AccessRuleConfiguration represents the configuration of a firewall access rule.

type AccessRuleListResponse Uses

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

AccessRuleListResponse represents the response from the list access rules endpoint.

type AccessRuleResponse Uses

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

AccessRuleResponse represents the response from the firewall access rule endpoint.

type AccessRuleScope Uses

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 AvailableZoneRatePlansResponse Uses

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

AvailableZoneRatePlansResponse represents the response from the Available Rate Plans endpoint.

type CustomHostname Uses

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 Uses

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

CustomHostnameListResponse represents a response from the Custom Hostnames endpoints.

type CustomHostnameResponse Uses

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

CustomHostnameResponse represents a response from the Custom Hostnames endpoints.

type CustomHostnameSSL Uses

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_name,omitempty"`
}

CustomHostnameSSL represents the SSL section in a given custom hostname.

type CustomMetadata Uses

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 Uses

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

CustomPage represents a custom page configuration.

type CustomPageResponse Uses

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

CustomPageResponse represents the response from the custom pages endpoint.

type DNSListResponse Uses

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

DNSListResponse represents the response from the list DNS records endpoint.

type DNSRecord Uses

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,omitempty"`
    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,omitempty"`
}

DNSRecord represents a DNS record in a zone.

type DNSRecordResponse Uses

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

DNSRecordResponse represents the response from the DNS endpoint.

type Error Uses

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 IPRanges Uses

type IPRanges struct {
    IPv4CIDRs []string `json:"ipv4_cidrs"`
    IPv6CIDRs []string `json:"ipv6_cidrs"`
}

IPRanges contains lists of IPv4 and IPv6 CIDRs.

func IPs Uses

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 Uses

type IPsResponse struct {
    Response
    Result IPRanges `json:"result"`
}

IPsResponse is the API response containing a list of IPs.

type KeylessSSL Uses

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 Uses

type KeylessSSLResponse struct {
    Response
    Result []KeylessSSL `json:"result"`
}

KeylessSSLResponse represents the response from the Keyless SSL endpoint.

type LoadBalancer Uses

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"`
    Persistence  string              `json:"session_affinity,omitempty"`
}

LoadBalancer represents a load balancer's properties.

type LoadBalancerMonitor Uses

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"`
    ExpectedBody  string              `json:"expected_body"`
    ExpectedCodes string              `json:"expected_codes"`
}

LoadBalancerMonitor represents a load balancer monitor's properties.

type LoadBalancerOrigin Uses

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 LoadBalancerPool Uses

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 Logger Uses

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 Option Uses

type Option func(*API) error

Option is a functional option for configuring the API client.

func HTTPClient Uses

func HTTPClient(client *http.Client) Option

HTTPClient accepts a custom *http.Client for making API calls.

func Headers Uses

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 UsingLogger Uses

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 UsingOrganization Uses

func UsingOrganization(orgID string) Option

UsingOrganization allows you to apply account-level changes (Load Balancing, Railguns) to an organization instead.

func UsingRateLimit Uses

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 Uses

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 Organization Uses

type Organization struct {
    ID          string   `json:"id,omitempty"`
    Name        string   `json:"name,omitempty"`
    Status      string   `json:"status,omitempty"`
    Permissions []string `json:"permissions,omitempty"`
    Roles       []string `json:"roles,omitempty"`
}

Organization represents a multi-user organization.

type OrganizationDetails Uses

type OrganizationDetails struct {
    ID      string               `json:"id,omitempty"`
    Name    string               `json:"name,omitempty"`
    Members []OrganizationMember `json:"members"`
    Invites []OrganizationInvite `json:"invites"`
    Roles   []OrganizationRole   `json:"roles,omitempty"`
}

OrganizationDetails represents details of an organization.

type OrganizationInvite Uses

type OrganizationInvite struct {
    ID                 string             `json:"id,omitempty"`
    InvitedMemberID    string             `json:"invited_member_id,omitempty"`
    InvitedMemberEmail string             `json:"invited_member_email,omitempty"`
    OrganizationID     string             `json:"organization_id,omitempty"`
    OrganizationName   string             `json:"organization_name,omitempty"`
    Roles              []OrganizationRole `json:"roles,omitempty"`
    InvitedBy          string             `json:"invited_by,omitempty"`
    InvitedOn          *time.Time         `json:"invited_on,omitempty"`
    ExpiresOn          *time.Time         `json:"expires_on,omitempty"`
    Status             string             `json:"status,omitempty"`
}

OrganizationInvite has details on an invite.

type OrganizationMember Uses

type OrganizationMember struct {
    ID     string             `json:"id,omitempty"`
    Name   string             `json:"name,omitempty"`
    Email  string             `json:"email,omitempty"`
    Status string             `json:"status,omitempty"`
    Roles  []OrganizationRole `json:"roles,omitempty"`
}

OrganizationMember has details on a member.

type OrganizationRole Uses

type OrganizationRole struct {
    ID          string   `json:"id,omitempty"`
    Name        string   `json:"name,omitempty"`
    Description string   `json:"description,omitempty"`
    Permissions []string `json:"permissions,omitempty"`
}

OrganizationRole has details on a role.

type OriginCACertificate Uses

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 Uses

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

OriginCACertificateID represents the ID of the revoked certificate from the Revoke Certificate endpoint.

type OriginCACertificateListOptions Uses

type OriginCACertificateListOptions struct {
    ZoneID string
}

OriginCACertificateListOptions represents the parameters used to list Cloudflare-issued certificates.

type Owner Uses

type Owner struct {
    ID        string `json:"id"`
    Email     string `json:"email"`
    OwnerType string `json:"owner_type"`
}

Owner describes the resource owner.

type PageRule Uses

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 Uses

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
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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type PurgeCacheResponse struct {
    Response
    Result struct {
        ID string `json:"id"`
    }   `json:"result"`
}

PurgeCacheResponse represents the response from the purge endpoint.

type Railgun Uses

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 Uses

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 Uses

type RailgunListOptions struct {
    Direction string
}

RailgunListOptions represents the parameters used to list railguns.

type RateLimit Uses

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"`
}

RateLimit is a policy than can be applied to limit traffic within a customer domain

type RateLimitAction Uses

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 Uses

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 RateLimitKeyValue Uses

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 Uses

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 Uses

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
}

RateLimitResponseMatcher contains the matching rules pertaining to responses

type RateLimitTrafficMatcher Uses

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 Uses

type RawResponse struct {
    Response
    Result json.RawMessage `json:"result"`
}

RawResponse keeps the result as JSON form

type Response Uses

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 Uses

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 Uses

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 Uses

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 User Uses

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"`
    Organizations []Organization `json:"organizations,omitempty"`
}

User describes a user account.

type UserAgentRule Uses

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 Uses

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 Uses

type UserAgentRuleListResponse struct {
    Result []UserAgentRule `json:"result"`
    Response
    ResultInfo `json:"result_info"`
}

UserAgentRuleListResponse represents a response from the List Zone Lockdown endpoint.

type UserAgentRuleResponse Uses

type UserAgentRuleResponse struct {
    Result UserAgentRule `json:"result"`
    Response
    ResultInfo `json:"result_info"`
}

UserAgentRuleResponse represents a response from the Zone Lockdown endpoint.

type UserBillingProfile Uses

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 Uses

type UserError struct {
    Err error
}

UserError represents a user-generated error.

func (*UserError) Error Uses

func (e *UserError) Error() string

Error wraps the underlying error.

func (*UserError) Network Uses

func (e *UserError) Network() bool

Network error.

func (*UserError) Parse Uses

func (e *UserError) Parse() bool

Parse error.

func (*UserError) User Uses

func (e *UserError) User() bool

User is a user-caused error.

type UserResponse Uses

type UserResponse struct {
    Response
    Result User `json:"result"`
}

UserResponse wraps a response containing User accounts.

type VirtualDNS Uses

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 VirtualDNSListResponse Uses

type VirtualDNSListResponse struct {
    Response
    Result []*VirtualDNS `json:"result"`
}

VirtualDNSListResponse represents an array of Virtual DNS responses.

type VirtualDNSResponse Uses

type VirtualDNSResponse struct {
    Response
    Result *VirtualDNS `json:"result"`
}

VirtualDNSResponse represents a Virtual DNS response.

type WAFPackage Uses

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 WAFPackagesResponse Uses

type WAFPackagesResponse struct {
    Response
    Result     []WAFPackage `json:"result"`
    ResultInfo ResultInfo   `json:"result_info"`
}

WAFPackagesResponse represents the response from the WAF packages endpoint.

type WAFRule Uses

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 WAFRulesResponse Uses

type WAFRulesResponse struct {
    Response
    Result     []WAFRule  `json:"result"`
    ResultInfo ResultInfo `json:"result_info"`
}

WAFRulesResponse represents the response from the WAF rule endpoint.

type Zone Uses

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              ZoneRatePlan `json:"plan"`
    PlanPending       ZoneRatePlan `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"`
}

Zone describes a Cloudflare zone.

type ZoneAnalytics Uses

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 Uses

type ZoneAnalyticsColocation struct {
    ColocationID string          `json:"colo_id"`
    Timeseries   []ZoneAnalytics `json:"timeseries"`
}

ZoneAnalyticsColocation contains analytics data by datacenter.

type ZoneAnalyticsData Uses

type ZoneAnalyticsData struct {
    Totals     ZoneAnalytics   `json:"totals"`
    Timeseries []ZoneAnalytics `json:"timeseries"`
}

ZoneAnalyticsData contains totals and timeseries analytics data for a zone.

type ZoneAnalyticsOptions Uses

type ZoneAnalyticsOptions struct {
    Since      *time.Time
    Until      *time.Time
    Continuous *bool
}

ZoneAnalyticsOptions represents the optional parameters in Zone Analytics endpoint requests.

type ZoneCustomSSL Uses

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"`
    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 ZoneCustomSSLOptions Uses

type ZoneCustomSSLOptions struct {
    Certificate  string `json:"certificate"`
    PrivateKey   string `json:"private_key"`
    BundleMethod string `json:"bundle_method,omitempty"`
}

ZoneCustomSSLOptions represents the parameters to create or update an existing custom SSL configuration.

type ZoneCustomSSLPriority Uses

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 Uses

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

ZoneID contains only the zone ID.

type ZoneIDResponse Uses

type ZoneIDResponse struct {
    Response
    Result ZoneID `json:"result"`
}

ZoneIDResponse represents the response from the Zone endpoint, containing only a zone ID.

type ZoneLockdown Uses

type ZoneLockdown struct {
    ID             string               `json:"id"`
    Description    string               `json:"description"`
    URLs           []string             `json:"urls"`
    Configurations []ZoneLockdownConfig `json:"configurations"`
    Paused         bool                 `json:"paused"`
}

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 Uses

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 Uses

type ZoneLockdownListResponse struct {
    Result []ZoneLockdown `json:"result"`
    Response
    ResultInfo `json:"result_info"`
}

ZoneLockdownListResponse represents a response from the List Zone Lockdown endpoint.

type ZoneLockdownResponse Uses

type ZoneLockdownResponse struct {
    Result ZoneLockdown `json:"result"`
    Response
    ResultInfo `json:"result_info"`
}

ZoneLockdownResponse represents a response from the Zone Lockdown endpoint.

type ZoneMeta Uses

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 Uses

type ZoneOptions struct {
    Paused   *bool         `json:"paused,omitempty"`
    VanityNS []string      `json:"vanity_name_servers,omitempty"`
    Plan     *ZoneRatePlan `json:"plan,omitempty"`
}

ZoneOptions is a subset of Zone, for editable options.

type ZoneRailgun Uses

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 Uses

type ZoneRatePlan struct {
    ID         string                   `json:"id"`
    Name       string                   `json:"name,omitempty"`
    Price      int                      `json:"price,omitempty"`
    Currency   string                   `json:"currency,omitempty"`
    Duration   int                      `json:"duration,omitempty"`
    Frequency  string                   `json:"frequency,omitempty"`
    Components []zoneRatePlanComponents `json:"components,omitempty"`
}

ZoneRatePlan contains the plan information for a zone.

type ZoneRatePlanResponse Uses

type ZoneRatePlanResponse struct {
    Response
    Result ZoneRatePlan `json:"result"`
}

ZoneRatePlanResponse represents the response from the Plan Details endpoint.

type ZoneResponse Uses

type ZoneResponse struct {
    Response
    Result Zone `json:"result"`
}

ZoneResponse represents the response from the Zone endpoint containing a single zone.

type ZoneSSLSetting Uses

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 Uses

type ZoneSSLSettingResponse struct {
    Response
    Result ZoneSSLSetting `json:"result"`
}

ZoneSSLSettingResponse represents the response from the Zone SSL Setting endpoint.

type ZoneSetting Uses

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 Uses

type ZoneSettingResponse struct {
    Response
    Result []ZoneSetting `json:"result"`
}

ZoneSettingResponse represents the response from the Zone Setting endpoint.

type ZonesResponse Uses

type ZonesResponse struct {
    Response
    Result []Zone `json:"result"`
}

ZonesResponse represents the response from the Zone endpoint containing an array of zones.

Package cloudflare imports 15 packages (graph) and is imported by 37 packages. Updated 2018-07-20. Refresh now. Tools for package owners.