• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H02-Aug-2021-

cmd/flarectl/H02-Aug-2021-

.gitignoreH A D02-Aug-202156

.golintci.yamlH A D02-Aug-2021449

CODE_OF_CONDUCT.mdH A D02-Aug-20213.3 KiB

LICENSEH A D02-Aug-20211.5 KiB

README.mdH A D02-Aug-20213.2 KiB

access_application.goH A D02-Aug-202111 KiB

access_application_test.goH A D02-Aug-202114.1 KiB

access_audit_log.goH A D02-Aug-20212.3 KiB

access_audit_log_example_test.goH A D02-Aug-2021502

access_audit_log_test.goH A D02-Aug-20212.4 KiB

access_ca_certificate.goH A D02-Aug-20215.9 KiB

access_ca_certificate_test.goH A D02-Aug-20215.4 KiB

access_group.goH A D02-Aug-202111.9 KiB

access_group_test.goH A D02-Aug-20217.7 KiB

access_identity_provider.goH A D02-Aug-202110.2 KiB

access_identity_provider_test.goH A D02-Aug-20217.5 KiB

access_mutual_tls_certificates.goH A D02-Aug-20218.8 KiB

access_mutual_tls_certificates_test.goH A D02-Aug-20219 KiB

access_organization.goH A D02-Aug-20215.6 KiB

access_organization_test.goH A D02-Aug-20215 KiB

access_policy.goH A D02-Aug-20218.4 KiB

access_policy_test.goH A D02-Aug-20218.9 KiB

access_service_tokens.goH A D02-Aug-20218.6 KiB

access_service_tokens_test.goH A D02-Aug-20216.4 KiB

account_members.goH A D02-Aug-20215.5 KiB

account_members_test.goH A D02-Aug-20219.3 KiB

account_roles.goH A D02-Aug-20212.3 KiB

account_roles_test.goH A D02-Aug-20212.6 KiB

accounts.goH A D02-Aug-20214.3 KiB

accounts_test.goH A D02-Aug-20214.7 KiB

api_token.goH A D02-Aug-20217.3 KiB

api_token_test.goH A D02-Aug-202111.7 KiB

argo.goH A D02-Aug-20213.7 KiB

argo_example_test.goH A D02-Aug-20211.5 KiB

argo_test.goH A D02-Aug-20214.3 KiB

argo_tunnel.goH A D02-Aug-20214.8 KiB

argo_tunnel_test.goH A D02-Aug-20215.8 KiB

auditlogs.goH A D02-Aug-20214.2 KiB

auditlogs_test.goH A D02-Aug-20211.8 KiB

authenticated_origin_pulls.goH A D02-Aug-20212.2 KiB

authenticated_origin_pulls_per_hostname.goH A D02-Aug-20218.8 KiB

authenticated_origin_pulls_per_hostname_test.goH A D02-Aug-202133.5 KiB

authenticated_origin_pulls_per_zone.goH A D02-Aug-20217.2 KiB

authenticated_origin_pulls_per_zone_test.goH A D02-Aug-202120.5 KiB

authenticated_origin_pulls_test.goH A D02-Aug-20212.8 KiB

certificate_packs.goH A D02-Aug-20217.3 KiB

certificate_packs_test.goH A D02-Aug-20219.1 KiB

cloudflare.goH A D02-Aug-202115.2 KiB

cloudflare_test.goH A D02-Aug-202117.1 KiB

consts.goH A D02-Aug-2021477

custom_hostname.goH A D02-Aug-202112.6 KiB

custom_hostname_test.goH A D02-Aug-202126.3 KiB

custom_pages.goH A D02-Aug-20215.3 KiB

custom_pages_test.goH A D02-Aug-20219.4 KiB

device_posture_rule.goH A D02-Aug-20215.5 KiB

device_posture_rule_test.goH A D02-Aug-202110.7 KiB

diagnostics.goH A D02-Aug-20213.8 KiB

diagnostics_test.goH A D02-Aug-20216.2 KiB

dns.goH A D02-Aug-20215.2 KiB

dns_example_test.goH A D02-Aug-20212.1 KiB

dns_test.goH A D02-Aug-202112.8 KiB

duration.goH A D02-Aug-2021838

duration_test.goH A D02-Aug-2021374

errors.goH A D02-Aug-20213.5 KiB

errors_test.goH A D02-Aug-20214 KiB

example_test.goH A D02-Aug-2021724

filter.goH A D02-Aug-20217 KiB

filter_test.goH A D02-Aug-20219.1 KiB

firewall.goH A D02-Aug-202110.7 KiB

firewall_example_test.goH A D02-Aug-20212.3 KiB

firewall_rules.goH A D02-Aug-20216.1 KiB

firewall_rules_test.goH A D02-Aug-202114.4 KiB

firewall_test.goH A D02-Aug-202111.8 KiB

go.modH A D02-Aug-2021467

go.sumH A D02-Aug-20214.7 KiB

healthchecks.goH A D02-Aug-20217.5 KiB

healthchecks_test.goH A D02-Aug-20217.9 KiB

ip_address_management.goH A D02-Aug-20215 KiB

ip_address_management_test.goH A D02-Aug-20216.9 KiB

ip_list.goH A D02-Aug-202114.3 KiB

ip_list_test.goH A D02-Aug-202112.9 KiB

ips.goH A D02-Aug-20211.7 KiB

ips_test.goH A D02-Aug-20211.6 KiB

keyless.goH A D02-Aug-20214.7 KiB

keyless_test.goH A D02-Aug-20216.9 KiB

load_balancing.goH A D02-Aug-202119.3 KiB

load_balancing_example_test.goH A D02-Aug-2021986

load_balancing_test.goH A D02-Aug-202146.1 KiB

lockdown.goH A D02-Aug-20214.7 KiB

lockdown_example_test.goH A D02-Aug-20211.3 KiB

lockdown_test.goH A D02-Aug-20218.5 KiB

logpull.goH A D02-Aug-20211.8 KiB

logpull_test.goH A D02-Aug-20211.5 KiB

logpush.goH A D02-Aug-20218.9 KiB

logpush_example_test.goH A D02-Aug-20213.3 KiB

logpush_test.goH A D02-Aug-20218.6 KiB

magic_firewall_rulesets.goH A D02-Aug-20217.9 KiB

magic_firewall_rulesets_test.goH A D02-Aug-20219.1 KiB

magic_transit_static_routes.goH A D02-Aug-20216.7 KiB

magic_transit_static_routes_test.goH A D02-Aug-20218.9 KiB

notifications.goH A D02-Aug-202114 KiB

notifications_test.goH A D02-Aug-202115.6 KiB

options.goH A D02-Aug-20213.2 KiB

origin_ca.goH A D02-Aug-20216.3 KiB

origin_ca_test.goH A D02-Aug-202118.4 KiB

page_rules.goH A D02-Aug-20218.8 KiB

page_rules_example_test.goH A D02-Aug-20211.9 KiB

page_rules_test.goH A D02-Aug-20214.4 KiB

railgun.goH A D02-Aug-202110.1 KiB

railgun_test.goH A D02-Aug-202119.5 KiB

rate_limiting.goH A D02-Aug-20216.9 KiB

rate_limiting_example_test.goH A D02-Aug-20212 KiB

rate_limiting_test.goH A D02-Aug-20218.3 KiB

registrar.goH A D02-Aug-20216.1 KiB

registrar_example_test.goH A D02-Aug-20211.8 KiB

registrar_test.goH A D02-Aug-202110.4 KiB

rulesets.goH A D02-Aug-202118.5 KiB

rulesets_test.goH A D02-Aug-202112.8 KiB

secondary_dns_primaries.goH A D02-Aug-20215 KiB

secondary_dns_primaries_test.goH A D02-Aug-20215.6 KiB

secondary_dns_tsig.goH A D02-Aug-20213.9 KiB

secondary_dns_tsig_test.goH A D02-Aug-20215.7 KiB

secondary_dns_zone.goH A D02-Aug-20215.2 KiB

secondary_zone_dns_test.goH A D02-Aug-20217.3 KiB

spectrum.goH A D02-Aug-202111 KiB

spectrum_test.goH A D02-Aug-202114.8 KiB

ssl.goH A D02-Aug-20216 KiB

ssl_test.goH A D02-Aug-202124.2 KiB

teams_list.goH A D02-Aug-20216.3 KiB

teams_list_test.goH A D02-Aug-20218.6 KiB

universal_ssl.goH A D02-Aug-20214.5 KiB

universal_ssl_test.goH A D02-Aug-20214 KiB

user.goH A D02-Aug-20213.6 KiB

user_agent.goH A D02-Aug-20214.7 KiB

user_agent_example_test.goH A D02-Aug-2021615

user_test.goH A D02-Aug-20215.1 KiB

virtualdns.goH A D02-Aug-20216.1 KiB

virtualdns_test.goH A D02-Aug-20212.1 KiB

waf.goH A D02-Aug-202110.1 KiB

waf_overrides.goH A D02-Aug-20214.2 KiB

waf_overrides_test.goH A D02-Aug-20216.1 KiB

waf_test.goH A D02-Aug-202121 KiB

waiting_room.goH A D02-Aug-20215 KiB

waiting_room_test.goH A D02-Aug-20217.6 KiB

workers.goH A D02-Aug-202124.2 KiB

workers_cron_triggers.goH A D02-Aug-20212.3 KiB

workers_cron_triggers_test.goH A D02-Aug-20212.3 KiB

workers_example_test.goH A D02-Aug-20214.6 KiB

workers_kv.goH A D02-Aug-202110 KiB

workers_kv_example_test.goH A D02-Aug-20214.3 KiB

workers_kv_test.goH A D02-Aug-202112.6 KiB

workers_secrets.goH A D02-Aug-20212.6 KiB

workers_secrets_test.goH A D02-Aug-20212.5 KiB

workers_test.goH A D02-Aug-202131.9 KiB

zone.goH A D02-Aug-202130.2 KiB

zone_example_test.goH A D02-Aug-2021797

zone_test.goH A D02-Aug-202138.3 KiB

README.md

1# cloudflare-go
2
3[![Go Reference](https://pkg.go.dev/badge/github.com/cloudflare/cloudflare-go.svg)](https://pkg.go.dev/github.com/cloudflare/cloudflare-go)
4![Test](https://github.com/cloudflare/cloudflare-go/workflows/Test/badge.svg)
5[![Go Report Card](https://goreportcard.com/badge/github.com/cloudflare/cloudflare-go?style=flat-square)](https://goreportcard.com/report/github.com/cloudflare/cloudflare-go)
6
7> **Note**: This library is under active development as we expand it to cover
8> our (expanding!) API. Consider the public API of this package a little
9> unstable as we work towards a v1.0.
10
11A Go library for interacting with
12[Cloudflare's API v4](https://api.cloudflare.com/). This library allows you to:
13
14* Manage and automate changes to your DNS records within Cloudflare
15* Manage and automate changes to your zones (domains) on Cloudflare, including
16  adding new zones to your account
17* List and modify the status of WAF (Web Application Firewall) rules for your
18  zones
19* Fetch Cloudflare's IP ranges for automating your firewall whitelisting
20
21A command-line client, [flarectl](cmd/flarectl), is also available as part of
22this project.
23
24## Features
25
26The current feature list includes:
27
28* [x] Cache purging
29* [x] Cloudflare IPs
30* [x] Custom hostnames
31* [x] DNS Records
32* [x] Firewall (partial)
33* [x] [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/)
34* [x] [Load Balancing](https://blog.cloudflare.com/introducing-load-balancing-intelligent-failover-with-cloudflare/)
35* [x] [Logpush Jobs](https://developers.cloudflare.com/logs/logpush/)
36* [ ] Organization Administration
37* [x] [Origin CA](https://blog.cloudflare.com/universal-ssl-encryption-all-the-way-to-the-origin-for-free/)
38* [x] [Railgun](https://www.cloudflare.com/railgun/) administration
39* [x] Rate Limiting
40* [x] User Administration (partial)
41* [x] Virtual DNS Management
42* [x] Web Application Firewall (WAF)
43* [x] Zone Lockdown and User-Agent Block rules
44* [x] Zones
45* [x] Workers KV
46* [x] Notifications
47
48Pull Requests are welcome, but please open an issue (or comment in an existing
49issue) to discuss any non-trivial changes before submitting code.
50
51## Installation
52
53You need a working Go environment.
54
55```
56go get github.com/cloudflare/cloudflare-go
57```
58
59## Getting Started
60
61```go
62package main
63
64import (
65	"context"
66	"fmt"
67	"log"
68	"os"
69
70	"github.com/cloudflare/cloudflare-go"
71)
72
73func main() {
74	// Construct a new API object
75	api, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))
76	if err != nil {
77		log.Fatal(err)
78	}
79
80	// Most API calls require a Context
81	ctx := context.Background()
82
83	// Fetch user details on the account
84	u, err := api.UserDetails(ctx)
85	if err != nil {
86		log.Fatal(err)
87	}
88	// Print user details
89	fmt.Println(u)
90
91	// Fetch the zone ID
92	id, err := api.ZoneIDByName("example.com") // Assuming example.com exists in your Cloudflare account already
93	if err != nil {
94		log.Fatal(err)
95	}
96
97	// Fetch zone details
98	zone, err := api.ZoneDetails(ctx, id)
99	if err != nil {
100		log.Fatal(err)
101	}
102	// Print zone details
103	fmt.Println(zone)
104}
105```
106
107Also refer to the
108[API documentation](https://pkg.go.dev/github.com/cloudflare/cloudflare-go) for
109how to use this package in-depth.
110
111# License
112
113BSD licensed. See the [LICENSE](LICENSE) file for details.
114