mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Felix Lange
0568e81701
|
5 years ago | |
---|---|---|
.. | ||
CODE_OF_CONDUCT.md | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
access_application.go | 5 years ago | |
access_identity_provider.go | 5 years ago | |
access_organization.go | 5 years ago | |
access_policy.go | 5 years ago | |
access_service_tokens.go | 5 years ago | |
account_members.go | 5 years ago | |
account_roles.go | 5 years ago | |
accounts.go | 5 years ago | |
argo.go | 5 years ago | |
auditlogs.go | 5 years ago | |
cloudflare.go | 5 years ago | |
custom_hostname.go | 5 years ago | |
custom_pages.go | 5 years ago | |
dns.go | 5 years ago | |
duration.go | 5 years ago | |
errors.go | 5 years ago | |
filter.go | 5 years ago | |
firewall.go | 5 years ago | |
firewall_rules.go | 5 years ago | |
go.mod | 5 years ago | |
go.sum | 5 years ago | |
ips.go | 5 years ago | |
keyless.go | 5 years ago | |
load_balancing.go | 5 years ago | |
lockdown.go | 5 years ago | |
logpush.go | 5 years ago | |
options.go | 5 years ago | |
origin_ca.go | 5 years ago | |
page_rules.go | 5 years ago | |
railgun.go | 5 years ago | |
rate_limiting.go | 5 years ago | |
registrar.go | 5 years ago | |
renovate.json | 5 years ago | |
spectrum.go | 5 years ago | |
ssl.go | 5 years ago | |
universal_ssl.go | 5 years ago | |
user.go | 5 years ago | |
user_agent.go | 5 years ago | |
virtualdns.go | 5 years ago | |
waf.go | 5 years ago | |
workers.go | 5 years ago | |
workers_kv.go | 5 years ago | |
zone.go | 5 years ago |
README.md
cloudflare-go
Note: This library is under active development as we expand it to cover our (expanding!) API. Consider the public API of this package a little unstable as we work towards a v1.0.
A Go library for interacting with Cloudflare's API v4. This library allows you to:
- Manage and automate changes to your DNS records within Cloudflare
- Manage and automate changes to your zones (domains) on Cloudflare, including adding new zones to your account
- List and modify the status of WAF (Web Application Firewall) rules for your zones
- Fetch Cloudflare's IP ranges for automating your firewall whitelisting
A command-line client, flarectl, is also available as part of this project.
Features
The current feature list includes:
- Cache purging
- Cloudflare IPs
- Custom hostnames
- DNS Records
- Firewall (partial)
- Keyless SSL
- Load Balancing
- Logpush Jobs
- Organization Administration
- Origin CA
- Railgun administration
- Rate Limiting
- User Administration (partial)
- Virtual DNS Management
- Web Application Firewall (WAF)
- Zone Lockdown and User-Agent Block rules
- Zones
Pull Requests are welcome, but please open an issue (or comment in an existing issue) to discuss any non-trivial changes before submitting code.
Installation
You need a working Go environment.
go get github.com/cloudflare/cloudflare-go
Getting Started
package main
import (
"fmt"
"log"
"os"
"github.com/cloudflare/cloudflare-go"
)
func main() {
// Construct a new API object
api, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))
if err != nil {
log.Fatal(err)
}
// Fetch user details on the account
u, err := api.UserDetails()
if err != nil {
log.Fatal(err)
}
// Print user details
fmt.Println(u)
// Fetch the zone ID
id, err := api.ZoneIDByName("example.com") // Assuming example.com exists in your Cloudflare account already
if err != nil {
log.Fatal(err)
}
// Fetch zone details
zone, err := api.ZoneDetails(id)
if err != nil {
log.Fatal(err)
}
// Print zone details
fmt.Println(zone)
}
Also refer to the API documentation for how to use this package in-depth.
License
BSD licensed. See the LICENSE file for details.