README.md in cloudflare-2.1.0 vs README.md in cloudflare-3.0.0
- old
+ new
@@ -1,76 +1,91 @@
-# CloudFlare
+# Cloudflare
-It is a Ruby wrapper for the CloudFlare API.
+It is a Ruby wrapper for the Cloudflare V4 API. It provides a light weight wrapper using `RestClient::Resource`. The wrapper functionality is limited to zones and DNS records at this time, *PRs welcome*.
-[![Build Status](https://travis-ci.org/b4k3r/cloudflare.png?branch=master)](https://travis-ci.org/b4k3r/cloudflare)
+[![Build Status](https://secure.travis-ci.org/ioquatix/cloudflare.svg)](http://travis-ci.org/ioquatix/cloudflare)
-Official home page is [here](https://github.com/b4k3r/cloudflare). The complete [RDoc](http://rdoc.info/github/b4k3r/cloudflare/) is online.
-
-Visit also a CloudFlare API documentation:
-
-- [Client](http://www.cloudflare.com/docs/client-api.html)
-- [Host](http://www.cloudflare.com/docs/host-api.html)
-
## Installation
Add this line to your application's Gemfile:
- gem 'cloudflare'
+```ruby
+gem 'cloudflare'
+```
And then execute:
- $ bundle
+```
+$ bundle
+```
Or install it yourself as:
- $ gem install cloudflare
+```
+$ gem install cloudflare
+```
## Usage
-**Example for Client API:**
+Prepare a connection to the remote API:
- require 'cloudflare'
+```ruby
+require 'cloudflare'
- cf = CloudFlare::connection('user_api_key', 'user_email')
+# Grab some details from somewhere:
+email = ENV['CLOUDFLARE_EMAIL']
+key = ENV['CLOUDFLARE_KEY']
- begin
- cf.rec_new('domain.com', 'A', 'subdomain', '212.11.6.211', 1)
- rescue => e
- puts e.message # error message
- else
- puts 'Successfuly added DNS record'
- end
+# Set up the connection:
+connection = Cloudflare.connect(key: key, email: email)
+```
-**Example for Host API:**
+Get all available zones:
- require 'cloudflare'
+```ruby
+zones = connection.zones.all
+```
- cf = CloudFlare::connection('host_api_key')
+Get a specific zone:
- begin
- output = cf.create_user('john@example.com', 'secret', 'john')
- rescue => e
- puts e.message # error message
- else
- puts output['msg']
- puts "Your login is #{output['response']['cloudflare_username']}" # => john
- end
+```ruby
+zone = connection.zones.find_by_id("...")
+zone = connection.zones.find_by_name("example.com")
+```
+Get DNS records for a given zone:
+
+```ruby
+dns_records = zones.first.dns_records.all
+```
+
+Show some details of the DNS record:
+
+```ruby
+dns_record = records.first
+puts records.first.record[:name]
+puts records
+```
+
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
+## See Also
+
+- [Cloudflare::DNS::Update](https://github.com/ioquatix/cloudflare-dns-update) - A dynamic DNS updater based on this gem.
+- [Rubyflare](https://github.com/trev/rubyflare) - Another implementation.
+
## License
Released under the MIT license.
Copyright, 2012, 2014, by [Marcin Prokop](https://github.com/b4k3r).
-Copyright, 2014, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
+Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell