Skip to content

tlianza/cloudflare-go

 
 

Repository files navigation

cloudflare-go

GoDoc

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:

  • DNS Records
  • Zones
  • Web Application Firewall (WAF)
  • CloudFlare IPs
  • User Administration (partial)
  • Organization Administration
  • Railgun administration
  • Keyless SSL
  • Origin CA

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"

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

var api *cloudflare.API

func main() {
	// Construct a new API object
	api = cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))

	// Fetch the list of zones on the account
	zones, err := api.ListZones()
	if err != nil {
		fmt.Println(err)
	}
	// Print the zone names
	for _, z := range zones {
		fmt.Println(z.Name)
	}
}

Also refer to the API documentation for how to use this package in-depth.

License

BSD licensed. See the LICENSE file for details.

About

Go library for the CloudFlare v4 API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%