Skip to content

crackcomm/cloudflare

Folders and files

NameName
Last commit message
Last commit date
Dec 21, 2015
May 3, 2016
Dec 21, 2015
Dec 21, 2015
Nov 13, 2015
Dec 21, 2015
Apr 29, 2016
Dec 21, 2015
May 1, 2016
May 3, 2016
May 1, 2016
Apr 28, 2016
May 3, 2016
Apr 28, 2016
May 1, 2016
Apr 28, 2016
Nov 13, 2015
Apr 28, 2016
Mar 6, 2016
Apr 29, 2016

Repository files navigation

Golang CloudFlare® API v4 client

GoDoc Circle CI

Golang API Client for CloudFlare® API v4.

Command Line Tool

$ 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

package main

import (
	"log"
	"time"

	"golang.org/x/net/context"

	"github.com/crackcomm/cloudflare"
)

func main() {
	client := cloudflare.New(&cloudflare.Options{
		Email: "[email protected]",
		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.

License

Apache 2.0 License.