https://github.com/crackcomm/cloudflare
CloudFlare® command line tool and Go client
https://github.com/crackcomm/cloudflare
cloudflare cloudflare-api
Last synced: 29 days ago
JSON representation
CloudFlare® command line tool and Go client
- Host: GitHub
- URL: https://github.com/crackcomm/cloudflare
- Owner: crackcomm
- License: apache-2.0
- Created: 2015-11-13T21:07:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-03T20:26:44.000Z (almost 10 years ago)
- Last Synced: 2024-06-19T16:45:44.089Z (over 1 year ago)
- Topics: cloudflare, cloudflare-api
- Language: Go
- Homepage:
- Size: 79.1 KB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang CloudFlare® API v4 client
[](https://godoc.org/github.com/crackcomm/cloudflare) [](https://circleci.com/gh/crackcomm/cloudflare)
Golang API Client for CloudFlare® API v4.
## Command Line Tool
```sh
$ go install github.com/crackcomm/cloudflare/cf
$ cf
NAME:
cf - CloudFlare command line tool
USAGE:
cf [global options] command [command options] [arguments...]
VERSION:
1.0.1
COMMANDS:
zones zones management
records zone records management
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--email CloudFlare user email [$CLOUDFLARE_EMAIL]
--key CloudFlare user key [$CLOUDFLARE_KEY]
--help, -h show help
--version, -v print the version
```
## Usage
```go
package main
import (
"log"
"time"
"golang.org/x/net/context"
"github.com/crackcomm/cloudflare"
)
func main() {
client := cloudflare.New(&cloudflare.Options{
Email: "example@email.com",
Key: "example-key",
})
ctx := context.Background()
ctx, _ = context.WithTimeout(ctx, time.Second*30)
zones, err := client.Zones.List(ctx)
if err != nil {
log.Fatal(err)
} else if len(zones) == 0 {
log.Fatal("No zones were found")
}
records, err := client.Records.List(ctx, zones[0].ID)
if err != nil {
log.Fatal(err)
}
for _, record := range records {
log.Printf("%#v", record)
}
}
```
## CloudFlare®
CloudFlare is a registered trademark of [CloudFlare, Inc](https://cloudflare.com).
## License
Apache 2.0 License.