Documentation ¶
Overview ¶
Package cloudflare implements the CloudFlare v4 API.
New API requests created like:
api := cloudflare.New(apikey, apiemail)
Index ¶
- Variables
- func DeleteZone()
- func EditZone()
- type API
- func (api *API) ChangePageRule(zoneID, ruleID string, rule PageRule) error
- func (api *API) CreateDNSRecord(zoneID string, rr DNSRecord) (DNSRecord, error)
- func (c *API) CreateKeyless()
- func (api *API) CreatePageRule(zoneID string, rule PageRule) error
- func (c *API) CreateRailgun()
- func (c *API) CreateSSL()
- func (api *API) CreateZone(z Zone)
- func (api *API) DNSRecord(zoneID, recordID string) (DNSRecord, error)
- func (api *API) DNSRecords(zoneID string, rr DNSRecord) ([]DNSRecord, error)
- func (api *API) DeleteDNSRecord(zoneID, recordID string) error
- func (c *API) DeleteKeyless()
- func (api *API) DeletePageRule(zoneID, ruleID string) error
- func (c *API) DeleteSSL()
- func (c *API) Keyless()
- func (c *API) ListKeyless()
- func (api *API) ListPageRules(zoneID string) ([]PageRule, error)
- func (c *API) ListSSL()
- func (api *API) ListWAFPackages(zoneID string) ([]WAFPackage, error)
- func (api *API) ListWAFRules(zoneID, packageID string) ([]WAFRule, error)
- func (api *API) ListZones(z ...string) ([]Zone, error)
- func (api *API) PageRule(zoneID, ruleID string) (PageRule, error)
- func (api *API) PurgeCache(zoneID string, pcr PurgeCacheRequest) (PurgeCacheResponse, error)
- func (api *API) PurgeEverything(zoneID string) (PurgeCacheResponse, error)
- func (c *API) Railgun()
- func (c *API) Railguns()
- func (c *API) ReprioSSL()
- func (c *API) SSLDetails()
- func (api *API) UpdateDNSRecord(zoneID, recordID string, rr DNSRecord) error
- func (c *API) UpdateKeyless()
- func (api *API) UpdatePageRule(zoneID, ruleID string, rule PageRule) error
- func (c *API) UpdateSSL()
- func (api API) UpdateUser() (User, error)
- func (api API) UserDetails() (User, error)
- func (api *API) ZoneDetails(z Zone)
- func (api *API) ZoneIDByName(zoneName string) (string, error)
- func (c *API) ZoneRailgun(connected bool)
- type CustomPage
- type CustomPageResponse
- type DNSListResponse
- type DNSRecord
- type DNSRecordResponse
- type IPRanges
- type IPsResponse
- type KeylessSSL
- type KeylessSSLResponse
- type Organization
- type Owner
- type PageRule
- type PageRuleAction
- type PageRuleDetailResponse
- type PageRuleTarget
- type PageRulesResponse
- type PurgeCacheRequest
- type PurgeCacheResponse
- type Railgun
- type RailgunResponse
- type Response
- type ResultInfo
- type User
- type UserResponse
- type WAFPackage
- type WAFPackagesResponse
- type WAFRule
- type WAFRulesResponse
- type Zone
- type ZoneCustomSSL
- type ZoneCustomSSLResponse
- type ZoneMeta
- type ZonePlan
- type ZonePlanResponse
- type ZoneRailgun
- type ZoneRailgunResponse
- type ZoneResponse
- type ZoneSetting
- type ZoneSettingResponse
Constants ¶
This section is empty.
Variables ¶
var PageRuleActions = map[string]string{
"always_online": "Always Online",
"always_use_https": "Always Use HTTPS",
"browser_cache_ttl": "Browser Cache TTL",
"browser_check": "Browser Integrity Check",
"cache_level": "Cache Level",
"disable_apps": "Disable Apps",
"disable_performance": "Disable Performance",
"disable_security": "Disable Security",
"edge_cache_ttl": "Edge Cache TTL",
"email_obfuscation": "Email Obfuscation",
"forwarding_url": "Forwarding URL",
"ip_geolocation": "IP Geolocation Header",
"mirage": "Mirage",
"railgun": "Railgun",
"rocket_loader": "Rocker Loader",
"security_level": "Security Level",
"server_side_exclude": "Server Side Excludes",
"smart_errors": "Smart Errors",
"ssl": "SSL",
"waf": "Web Application Firewall",
}
PageRuleActions maps API action IDs to human-readable strings
Functions ¶
func DeleteZone ¶
func DeleteZone()
https://api.cloudflare.com/#zone-delete-a-zone DELETE /zones/:id
func EditZone ¶
func EditZone()
https://api.cloudflare.com/#zone-edit-zone-properties PATCH /zones/:id
Types ¶
type API ¶
func (*API) ChangePageRule ¶
ChangePageRule lets 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 PATCH /zones/:zone_identifier/pagerules/:identifier
func (*API) CreateDNSRecord ¶
Create a DNS record.
API reference:
https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record POST /zones/:zone_identifier/dns_records
func (*API) CreateKeyless ¶
func (c *API) CreateKeyless()
https://api.cloudflare.com/#keyless-ssl-for-a-zone-create-a-keyless-ssl-configuration POST /zones/:zone_identifier/keyless_certificates
func (*API) CreatePageRule ¶
CreatePageRule creates a new Page Rule for a zone.
API reference:
https://api.cloudflare.com/#page-rules-for-a-zone-create-a-page-rule POST /zones/:zone_identifier/pagerules
func (*API) CreateRailgun ¶
func (c *API) CreateRailgun()
https://api.cloudflare.com/#railgun-create-railgun POST /railguns
func (*API) CreateSSL ¶
func (c *API) CreateSSL()
https://api.cloudflare.com/#custom-ssl-for-a-zone-create-ssl-configuration POST /zones/:zone_identifier/custom_certificates
func (*API) CreateZone ¶
Creates a zone on an account.
API reference: https://api.cloudflare.com/#zone-create-a-zone
func (*API) DNSRecord ¶
Fetches a single DNS record.
API reference:
https://api.cloudflare.com/#dns-records-for-a-zone-dns-record-details GET /zones/:zone_identifier/dns_records/:identifier
func (*API) DNSRecords ¶
Fetches DNS records for a zone.
API reference:
https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records GET /zones/:zone_identifier/dns_records
func (*API) DeleteDNSRecord ¶
Delete a DNS record.
API reference:
https://api.cloudflare.com/#dns-records-for-a-zone-delete-dns-record DELETE /zones/:zone_identifier/dns_records/:identifier
func (*API) DeleteKeyless ¶
func (c *API) DeleteKeyless()
https://api.cloudflare.com/#keyless-ssl-for-a-zone-delete-keyless-configuration DELETE /zones/:zone_identifier/keyless_certificates/:identifier
func (*API) DeletePageRule ¶
DeletePageRule deletes a Page Rule for a zone.
API reference:
https://api.cloudflare.com/#page-rules-for-a-zone-delete-a-page-rule DELETE /zones/:zone_identifier/pagerules/:identifier
func (*API) DeleteSSL ¶
func (c *API) DeleteSSL()
https://api.cloudflare.com/#custom-ssl-for-a-zone-delete-an-ssl-certificate DELETE /zones/:zone_identifier/custom_certificates/:identifier
func (*API) Keyless ¶
func (c *API) Keyless()
https://api.cloudflare.com/#keyless-ssl-for-a-zone-keyless-ssl-details GET /zones/:zone_identifier/keyless_certificates/:identifier
func (*API) ListKeyless ¶
func (c *API) ListKeyless()
https://api.cloudflare.com/#keyless-ssl-for-a-zone-list-keyless-ssls GET /zones/:zone_identifier/keyless_certificates
func (*API) ListPageRules ¶
ListPageRules returns all Page Rules for a zone.
API reference:
https://api.cloudflare.com/#page-rules-for-a-zone-list-page-rules GET /zones/:zone_identifier/pagerules
func (*API) ListSSL ¶
func (c *API) ListSSL()
https://api.cloudflare.com/#custom-ssl-for-a-zone-list-ssl-configurations GET /zones/:zone_identifier/custom_certificates
func (*API) ListWAFPackages ¶
func (api *API) ListWAFPackages(zoneID string) ([]WAFPackage, error)
func (*API) ListWAFRules ¶
func (*API) ListZones ¶
List zones on an account. Optionally takes a list of zones to filter results.
API reference: https://api.cloudflare.com/#zone-list-zones
func (*API) PageRule ¶
PageRule fetches detail about one Page Rule for a zone.
API reference:
https://api.cloudflare.com/#page-rules-for-a-zone-page-rule-details GET /zones/:zone_identifier/pagerules/:identifier
func (*API) PurgeCache ¶
func (api *API) PurgeCache(zoneID string, pcr PurgeCacheRequest) (PurgeCacheResponse, error)
https://api.cloudflare.com/#zone-purge-individual-files-by-url-and-cache-tags DELETE /zones/:id/purge_cache
func (*API) PurgeEverything ¶
func (api *API) PurgeEverything(zoneID string) (PurgeCacheResponse, error)
https://api.cloudflare.com/#zone-purge-all-files DELETE /zones/:id/purge_cache
func (*API) Railgun ¶
func (c *API) Railgun()
https://api.cloudflare.com/#railguns-for-a-zone-get-railgun-details GET /zones/:zone_identifier/railguns/:identifier
func (*API) Railguns ¶
func (c *API) Railguns()
https://api.cloudflare.com/#railguns-for-a-zone-get-available-railguns GET /zones/:zone_identifier/railguns
func (*API) ReprioSSL ¶
func (c *API) ReprioSSL()
https://api.cloudflare.com/#custom-ssl-for-a-zone-re-prioritize-ssl-certificates PUT /zones/:zone_identifier/custom_certificates/prioritize
func (*API) SSLDetails ¶
func (c *API) SSLDetails()
https://api.cloudflare.com/#custom-ssl-for-a-zone-ssl-configuration-details GET /zones/:zone_identifier/custom_certificates/:identifier
func (*API) UpdateDNSRecord ¶
Change a DNS record.
API reference:
https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record PUT /zones/:zone_identifier/dns_records/:identifier
func (*API) UpdateKeyless ¶
func (c *API) UpdateKeyless()
https://api.cloudflare.com/#keyless-ssl-for-a-zone-update-keyless-configuration PATCH /zones/:zone_identifier/keyless_certificates/:identifier
func (*API) UpdatePageRule ¶
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 PUT /zones/:zone_identifier/pagerules/:identifier
func (*API) UpdateSSL ¶
func (c *API) UpdateSSL()
https://api.cloudflare.com/#custom-ssl-for-a-zone-update-ssl-configuration PATCH /zones/:zone_identifier/custom_certificates/:identifier
func (API) UpdateUser ¶
Update user properties.
API reference: https://api.cloudflare.com/#user-update-user
func (API) UserDetails ¶
Information about the logged-in user.
API reference: https://api.cloudflare.com/#user-user-details
func (*API) ZoneDetails ¶
Fetches information about a zone.
https://api.cloudflare.com/#zone-zone-details GET /zones/:id
func (*API) ZoneIDByName ¶
ZoneIDByName retrieves a zone's ID from the name.
func (*API) ZoneRailgun ¶
https://api.cloudflare.com/#railguns-for-a-zone-connect-or-disconnect-a-railgun PATCH /zones/:zone_identifier/railguns/:identifier
type CustomPage ¶
type CustomPage struct { CreatedOn string `json:"created_on"` ModifiedOn string `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"` }
Custom error pages.
type CustomPageResponse ¶
type CustomPageResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result []CustomPage `json:"result"` }
type DNSListResponse ¶
type DNSListResponse struct { Success bool `json:"success"` Errors []interface{} `json:"errors"` Messages []string `json:"messages"` Result []DNSRecord `json:"result"` }
The response for listing DNS records.
type DNSRecord ¶
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 string `json:"created_on,omitempty"` ModifiedOn string `json:"modified_on,omitempty"` Data interface{} `json:"data,omitempty"` // data returned by: SRV, LOC Meta interface{} `json:"meta,omitempty"` Priority int `json:"priority,omitempty"` }
Describes a DNS record for a zone.
type DNSRecordResponse ¶
type DNSRecordResponse struct { Success bool `json:"success"` Errors []interface{} `json:"errors"` Messages []string `json:"messages"` Result DNSRecord `json:"result"` }
The response for creating or updating a DNS record.
type IPRanges ¶
type IPRanges struct { IPv4CIDRs []string `json:"ipv4_cidrs"` IPv6CIDRs []string `json:"ipv6_cidrs"` }
IPs contains a list of IPv4 and IPv6 CIDRs
type IPsResponse ¶
type IPsResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result IPRanges `json:"result"` }
IPsResponse is the API response containing a list of IPs
type KeylessSSL ¶
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 string `json:"created_on"` ModifiedOn string `json:"modifed_on"` }
type KeylessSSLResponse ¶
type KeylessSSLResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result []KeylessSSL `json:"result"` }
type Organization ¶
type Organization struct { ID string Name string Status string Permissions []string Roles []string }
An Organization describes a multi-user organization. (Enterprise only.)
type PageRule ¶
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 string `json:"modified_on,omitempty"` CreatedOn string `json:"created_on,omitempty"` }
PageRule describes a Page Rule.
type PageRuleAction ¶
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 browser_cache_ttl browser_check cache_level disable_apps disable_performance disable_security edge_cache_ttl email_obfuscation forwarding_url ip_geolocation mirage railgun rocket_loader security_level server_side_exclude smart_errors ssl waf
type PageRuleDetailResponse ¶
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 ¶
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 ¶
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 PurgeCacheRequest ¶
type PurgeCacheResponse ¶
type Railgun ¶
type Railgun struct { ID string `json:"id"` Name string `json:"name"` Status string `json:"success"` 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 string `json:"activated_on"` CreatedOn string `json:"created_on"` ModifiedOn string `json:"modified_on"` }
type RailgunResponse ¶
type Response ¶
type Response struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` }
The Response struct 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 ResultInfo ¶
type User ¶
type User struct { ID string `json:"id"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Username string `json:"username"` Telephone string `json:"telephone"` Country string `json:"country"` Zipcode string `json:"zipcode"` CreatedOn string `json:"created_on"` // Should this be a time.Date? ModifiedOn string `json:"modified_on"` APIKey string `json:"api_key"` TwoFA bool `json:"two_factor_authentication_enabled"` Betas []string `json:"betas"` Organizations []Organization `json:"organizations"` }
A User describes a user account.
type UserResponse ¶
type WAFPackage ¶
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"` }
WAF packages
type WAFPackagesResponse ¶
type WAFRule ¶
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"` }
type WAFRulesResponse ¶
type Zone ¶
type Zone struct { ID string `json:"id"` Name string `json:"name"` DevMode int `json:"development_mode"` OriginalNS []string `json:"original_name_servers"` OriginalRegistrar string `json:"original_registrar"` OriginalDNSHost string `json:"original_dnshost"` CreatedOn string `json:"created_on"` ModifiedOn string `json:"modified_on"` NameServers []string `json:"name_servers"` Owner Owner `json:"owner"` Permissions []string `json:"permissions"` Plan ZonePlan `json:"plan"` 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"` }
A Zone describes a CloudFlare zone.
type ZoneCustomSSL ¶
type ZoneCustomSSL struct { ID string `json:"id"` Hosts []string `json:"hosts"` Issuer string `json:"issuer"` Priority int `json:"priority"` Status string `json:"success"` BundleMethod string `json:"bundle_method"` ZoneID string `json:"zone_id"` Permissions []string `json:"permissions"` UploadedOn string `json:"uploaded_on"` ModifiedOn string `json:"modified_on"` ExpiresOn string `json:"expires_on"` KeylessServer KeylessSSL `json:"keyless_server"` }
Custom SSL certificates for a zone.
type ZoneCustomSSLResponse ¶
type ZoneCustomSSLResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result []ZoneCustomSSL `json:"result"` }
type ZoneMeta ¶
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"` }
Contains metadata about a zone.
type ZonePlan ¶
type ZonePlan struct { ID string `json:"id"` Name string `json:"name"` Price int `json:"price"` Currency string `json:"currency"` Frequency string `json:"frequency"` LegacyID string `json:"legacy_id"` IsSubscribed bool `json:"is_subscribed"` CanSubscribe bool `json:"can_subscribe"` }
Contains the plan information for a zone.
type ZonePlanResponse ¶
type ZoneRailgun ¶
type ZoneRailgun struct { ID string `json:"id"` Name string `json:"string"` Enabled bool `json:"enabled"` Connected bool `json:"connected"` }
Railgun status for a zone.
type ZoneRailgunResponse ¶
type ZoneRailgunResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result []ZoneRailgun `json:"result"` }
type ZoneResponse ¶
type ZoneSetting ¶
type ZoneSettingResponse ¶
type ZoneSettingResponse struct { Success bool `json:"success"` Errors []string `json:"errors"` Messages []string `json:"messages"` Result []ZoneSetting `json:"result"` }