<commit_before># CloudFlare Configurator

A utility to configure [CloudFlare CDN] settings from version-controllable
JSON files and using [CloudFlare's v4 API].

[CloudFlare CDN]: https://www.cloudflare.com/features-cdn
[CloudFlare's v4 API]: http://developers.cloudflare.com/next/

## Compiling

You will need [Go]. Any 1.x version should do. To compile the binary:

    go build

[Go]: http://golang.org/<commit_msg>Add usage and considerations to README.<commit_after># CloudFlare Configure

A utility to configure [CloudFlare CDN] settings from version-controllable
JSON files and using [CloudFlare's v4 API].

[CloudFlare CDN]: https://www.cloudflare.com/features-cdn
[CloudFlare's v4 API]: http://developers.cloudflare.com/next/

## Compiling

You will need [Go]. Any 1.x version should do. To compile the binary:

    go build

[Go]: http://golang.org/

## Usage

Download the current configuration for a zone:

    ➜  cdn-configs git:(master) ✗ ./cloudflare-configure -email <EMAIL> -key 123 -zone 456 -file myzone.json -download
    2014/10/08 09:57:48 Saving configuration..

Modify a setting:

    ➜  cdn-configs git:(master) ✗ gsed -ri 's/("ipv6": )"off"/\1"on"/' myzone.json

Preview the changes:

    ➜  cdn-configs git:(master) ✗ ./cloudflare-configure -email <EMAIL> -key 123 -zone 456 -file myzone.json -dry-run
    2014/10/08 10:11:22 Dry run mode. Changes won't be submitted
    2014/10/08 10:11:22 Comparing and updating configuration..
    2014/10/08 10:11:22 Changing setting: ipv6 off -> on

Upload the changes:

    ➜  cdn-configs git:(master) ✗ ./cloudflare-configure -email <EMAIL> -key 123 -zone 456 -file myzone.json
    2014/10/08 10:11:58 Comparing and updating configuration..
    2014/10/08 10:11:58 Changing setting: ipv6 off -> on

Use the `-help` argument to see all of the options available.

## Considerations

The following caveats and limitations should be borne in mind:

- If the key names in the local and remote configurations differ, for
  example if you have made a typo or CloudFlare introduce a new feature,
  then a message will be logged and you will need to update your
  configuration manually (compare with `-download`).
- It is assumed that any keys that need modifying have API endpoints of the
  same name, eg. `{"id":"always_online",…}` can be written at
  `/v4/zones/123/settings/always_online`. This appears to hold true.
- It doesn't respect `{"editable":false,…}"` which CloudFlare use to
  indicate that a key is immutable. Such keys probably don't have write
  endpoints (see the last point) and will fail, but they should also never
  change in your config.
- It will abort and cease to make any other changes as soon as it encounters
  an error.
{'fraction_non_alphanumeric': 0.10114433370247324, 'fraction_numerical': 0.042820228866740494, 'mean_word_length': 3.754385964912281, 'pattern_counts': {'":': 3, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4951689', 'n_tokens_mistral': 958, 'n_tokens_neox': 831, 'n_words': 345}