dnsimple 2.2.0 → 3.0.0.pre.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -1
- data/CHANGELOG.md +13 -2
- data/CONTRIBUTING.md +35 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +30 -82
- data/dnsimple.gemspec +2 -1
- data/lib/dnsimple.rb +0 -2
- data/lib/dnsimple/client.rb +64 -64
- data/lib/dnsimple/client/clients.rb +82 -58
- data/lib/dnsimple/client/contacts.rb +74 -37
- data/lib/dnsimple/client/domains.rb +82 -28
- data/lib/dnsimple/client/domains_email_forwards.rb +107 -0
- data/lib/dnsimple/client/identity.rb +38 -0
- data/lib/dnsimple/client/oauth.rb +42 -0
- data/lib/dnsimple/client/registrar.rb +64 -72
- data/lib/dnsimple/client/registrar_auto_renewal.rb +41 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +74 -0
- data/lib/dnsimple/client/tlds.rb +88 -0
- data/lib/dnsimple/client/webhooks.rb +82 -0
- data/lib/dnsimple/client/zones.rb +68 -0
- data/lib/dnsimple/client/zones_records.rb +127 -0
- data/lib/dnsimple/default.rb +10 -17
- data/lib/dnsimple/error.rb +5 -8
- data/lib/dnsimple/extra.rb +1 -1
- data/lib/dnsimple/response.rb +80 -0
- data/lib/dnsimple/struct.rb +13 -14
- data/lib/dnsimple/struct/account.rb +13 -0
- data/lib/dnsimple/struct/contact.rb +6 -3
- data/lib/dnsimple/struct/domain.rb +10 -10
- data/lib/dnsimple/struct/domain_check.rb +16 -0
- data/lib/dnsimple/struct/email_forward.rb +11 -1
- data/lib/dnsimple/struct/oauth_token.rb +19 -0
- data/lib/dnsimple/struct/record.rb +25 -7
- data/lib/dnsimple/struct/tld.rb +22 -0
- data/lib/dnsimple/struct/user.rb +3 -7
- data/lib/dnsimple/struct/webhook.rb +13 -0
- data/lib/dnsimple/struct/whois_privacy.rb +8 -5
- data/lib/dnsimple/struct/zone.rb +25 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/client_service_spec.rb +37 -0
- data/spec/dnsimple/client/contacts_spec.rb +108 -78
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +190 -0
- data/spec/dnsimple/client/domains_spec.rb +121 -58
- data/spec/dnsimple/client/identity_spec.rb +56 -0
- data/spec/dnsimple/client/oauth_spec.rb +48 -0
- data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +80 -0
- data/spec/dnsimple/client/registrar_spec.rb +109 -122
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +119 -0
- data/spec/dnsimple/client/tlds_spec.rb +139 -0
- data/spec/dnsimple/client/webhooks_spec.rb +142 -0
- data/spec/dnsimple/client/zones_records_spec.rb +277 -0
- data/spec/dnsimple/client/zones_spec.rb +109 -0
- data/spec/dnsimple/client_spec.rb +34 -46
- data/spec/dnsimple/extra_spec.rb +22 -0
- data/spec/{files → fixtures.http}/badgateway.http +14 -14
- data/spec/fixtures.http/checkDomain/success.http +17 -0
- data/spec/fixtures.http/createContact/created.http +17 -0
- data/spec/fixtures.http/createDomain/created.http +16 -0
- data/spec/fixtures.http/createEmailForward/created.http +17 -0
- data/spec/fixtures.http/createWebhook/created.http +17 -0
- data/spec/fixtures.http/createZoneRecord/created.http +17 -0
- data/spec/fixtures.http/deleteContact/success.http +13 -0
- data/spec/fixtures.http/deleteDomain/success.http +13 -0
- data/spec/fixtures.http/deleteEmailForward/success.http +12 -0
- data/spec/fixtures.http/deleteWebhook/success.http +13 -0
- data/spec/fixtures.http/deleteZoneRecord/success.http +13 -0
- data/spec/fixtures.http/disableAutoRenewal/success.http +12 -0
- data/spec/fixtures.http/disableWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/enableAutoRenewal/success.http +12 -0
- data/spec/fixtures.http/enableWhoisPrivacy/created.http +17 -0
- data/spec/fixtures.http/enableWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/getContact/success.http +17 -0
- data/spec/fixtures.http/getDomain/success.http +16 -0
- data/spec/fixtures.http/getEmailForward/success.http +17 -0
- data/spec/fixtures.http/getTld/success.http +17 -0
- data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +17 -0
- data/spec/fixtures.http/getTldExtendedAttributes/success.http +17 -0
- data/spec/fixtures.http/getWebhook/success.http +17 -0
- data/spec/fixtures.http/getWhoisPrivacy/success.http +17 -0
- data/spec/fixtures.http/getZone/success.http +17 -0
- data/spec/fixtures.http/getZoneRecord/success.http +17 -0
- data/spec/fixtures.http/listContacts/success.http +17 -0
- data/spec/fixtures.http/listDomains/success.http +16 -0
- data/spec/fixtures.http/listEmailForwards/success.http +17 -0
- data/spec/fixtures.http/listTlds/success.http +17 -0
- data/spec/fixtures.http/listWebhooks/success.http +17 -0
- data/spec/fixtures.http/listZoneRecords/success.http +17 -0
- data/spec/fixtures.http/listZones/success.http +17 -0
- data/spec/fixtures.http/notfound-contact.http +12 -0
- data/spec/fixtures.http/notfound-domain.http +12 -0
- data/spec/fixtures.http/notfound-emailforward.http +12 -0
- data/spec/fixtures.http/notfound-record.http +12 -0
- data/spec/fixtures.http/notfound-webhook.http +12 -0
- data/spec/fixtures.http/notfound-zone.http +12 -0
- data/spec/fixtures.http/oauthAccessToken/success.http +17 -0
- data/spec/fixtures.http/pages-1of3.http +16 -0
- data/spec/fixtures.http/pages-2of3.http +16 -0
- data/spec/fixtures.http/pages-3of3.http +16 -0
- data/spec/fixtures.http/registerDomain/success.http +17 -0
- data/spec/fixtures.http/renewDomain/error-tooearly.http +15 -0
- data/spec/fixtures.http/renewDomain/success.http +17 -0
- data/spec/fixtures.http/resetDomainToken/success.http +17 -0
- data/spec/fixtures.http/response.http +16 -0
- data/spec/fixtures.http/transferDomain/error-indnsimple.http +15 -0
- data/spec/fixtures.http/transferDomain/error-missing-authcode.http +15 -0
- data/spec/fixtures.http/transferDomain/success.http +17 -0
- data/spec/fixtures.http/transferDomainOut/success.http +13 -0
- data/spec/fixtures.http/updateContact/success.http +17 -0
- data/spec/fixtures.http/updateZoneRecord/success.http +17 -0
- data/spec/fixtures.http/whoami/success.http +16 -0
- data/spec/fixtures.http/whoami/success_account.http +16 -0
- data/spec/fixtures.http/whoami/success_user.http +16 -0
- data/spec/spec_helper.rb +0 -6
- data/spec/support/helpers.rb +4 -4
- metadata +161 -238
- data/lib/dnsimple/client/certificates.rb +0 -100
- data/lib/dnsimple/client/domains_autorenewal.rb +0 -35
- data/lib/dnsimple/client/domains_forwards.rb +0 -71
- data/lib/dnsimple/client/domains_privacy.rb +0 -35
- data/lib/dnsimple/client/domains_records.rb +0 -90
- data/lib/dnsimple/client/domains_sharing.rb +0 -54
- data/lib/dnsimple/client/domains_zones.rb +0 -22
- data/lib/dnsimple/client/name_servers.rb +0 -71
- data/lib/dnsimple/client/services.rb +0 -37
- data/lib/dnsimple/client/services_domains.rb +0 -68
- data/lib/dnsimple/client/templates.rb +0 -88
- data/lib/dnsimple/client/templates_domains.rb +0 -23
- data/lib/dnsimple/client/templates_records.rb +0 -88
- data/lib/dnsimple/client/users.rb +0 -39
- data/lib/dnsimple/client/vanity_name_servers.rb +0 -39
- data/lib/dnsimple/compatibility.rb +0 -46
- data/lib/dnsimple/struct/certificate.rb +0 -56
- data/lib/dnsimple/struct/membership.rb +0 -22
- data/lib/dnsimple/struct/price.rb +0 -16
- data/lib/dnsimple/struct/service.rb +0 -19
- data/lib/dnsimple/struct/template.rb +0 -19
- data/lib/dnsimple/struct/template_record.rb +0 -24
- data/lib/dnsimple/struct/transfer_order.rb +0 -10
- data/spec/dnsimple/client/certificates_spec.rb +0 -196
- data/spec/dnsimple/client/domains_autorenewals_spec.rb +0 -72
- data/spec/dnsimple/client/domains_forwards_spec.rb +0 -146
- data/spec/dnsimple/client/domains_privacy_spec.rb +0 -74
- data/spec/dnsimple/client/domains_records_spec.rb +0 -191
- data/spec/dnsimple/client/domains_sharing_spec.rb +0 -109
- data/spec/dnsimple/client/domains_zones_spec.rb +0 -40
- data/spec/dnsimple/client/name_servers_spec.rb +0 -131
- data/spec/dnsimple/client/services_domains_spec.rb +0 -101
- data/spec/dnsimple/client/services_spec.rb +0 -69
- data/spec/dnsimple/client/templates_domains_spec.rb +0 -38
- data/spec/dnsimple/client/templates_records_spec.rb +0 -180
- data/spec/dnsimple/client/templates_spec.rb +0 -166
- data/spec/dnsimple/client/users_spec.rb +0 -70
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +0 -61
- data/spec/dnsimple/compatibility_spec.rb +0 -57
- data/spec/files/2fa/error-badtoken.http +0 -22
- data/spec/files/2fa/error-required.http +0 -23
- data/spec/files/2fa/exchange-token.http +0 -22
- data/spec/files/certificates/configure/success.http +0 -19
- data/spec/files/certificates/get/success.http +0 -19
- data/spec/files/certificates/list/success.http +0 -19
- data/spec/files/certificates/notfound.http +0 -19
- data/spec/files/certificates/purchase/success.http +0 -19
- data/spec/files/certificates/submit/success.http +0 -19
- data/spec/files/contacts/contact/success.http +0 -19
- data/spec/files/contacts/contacts/success.http +0 -23
- data/spec/files/contacts/create_contact/badrequest-missingcontact.http +0 -19
- data/spec/files/contacts/create_contact/badrequest-validationerror.http +0 -19
- data/spec/files/contacts/create_contact/created.http +0 -22
- data/spec/files/contacts/delete_contact/success-204.http +0 -18
- data/spec/files/contacts/delete_contact/success.http +0 -19
- data/spec/files/contacts/notfound-contact.http +0 -19
- data/spec/files/contacts/update_contact/success.http +0 -21
- data/spec/files/domains/create_domain/created.http +0 -21
- data/spec/files/domains/create_forward/created.http +0 -22
- data/spec/files/domains/create_membership/success.http +0 -21
- data/spec/files/domains/create_record/created.http +0 -21
- data/spec/files/domains/delete_domain/success-204.http +0 -18
- data/spec/files/domains/delete_domain/success.http +0 -19
- data/spec/files/domains/delete_forward/success.http +0 -17
- data/spec/files/domains/delete_membership/success.http +0 -17
- data/spec/files/domains/delete_record/success-204.http +0 -18
- data/spec/files/domains/delete_record/success.http +0 -19
- data/spec/files/domains/disable_auto_renewal/success.http +0 -21
- data/spec/files/domains/disable_whois_privacy/success.http +0 -21
- data/spec/files/domains/domain/success.http +0 -21
- data/spec/files/domains/domains/success.http +0 -21
- data/spec/files/domains/enable_auto_renewal/success.http +0 -21
- data/spec/files/domains/enable_whois_privacy/success.http +0 -22
- data/spec/files/domains/forward/success.http +0 -21
- data/spec/files/domains/forwards/success.http +0 -21
- data/spec/files/domains/memberships/success.http +0 -21
- data/spec/files/domains/notfound-domain.http +0 -19
- data/spec/files/domains/notfound-forward.http +0 -19
- data/spec/files/domains/notfound-membership.http +0 -19
- data/spec/files/domains/record/success.http +0 -19
- data/spec/files/domains/records/success.http +0 -19
- data/spec/files/domains/update_record/success.http +0 -21
- data/spec/files/domains/zone/success.http +0 -21
- data/spec/files/nameservers/change/success.http +0 -23
- data/spec/files/nameservers/deregister/success.http +0 -17
- data/spec/files/nameservers/name_servers/success.http +0 -23
- data/spec/files/nameservers/notfound-domain.http +0 -19
- data/spec/files/nameservers/register/badrequest-valueerror.http +0 -19
- data/spec/files/nameservers/register/success.http +0 -21
- data/spec/files/nameservers/vanity_name_servers/disabled.http +0 -23
- data/spec/files/nameservers/vanity_name_servers/enabled.http +0 -23
- data/spec/files/registrar/check/available.http +0 -19
- data/spec/files/registrar/check/registered.http +0 -21
- data/spec/files/registrar/extended_attributes/success.http +0 -21
- data/spec/files/registrar/prices/success.http +0 -21
- data/spec/files/registrar/register/badrequest-missingdomain.http +0 -19
- data/spec/files/registrar/register/badrequest-missingregistrant.http +0 -19
- data/spec/files/registrar/register/success.http +0 -21
- data/spec/files/registrar/renew/badrequest-missingrenewal.http +0 -19
- data/spec/files/registrar/renew/badrequest-unable.http +0 -19
- data/spec/files/registrar/renew/success.http +0 -21
- data/spec/files/registrar/transfer/success.http +0 -21
- data/spec/files/services/applied/success.http +0 -21
- data/spec/files/services/apply/success.http +0 -21
- data/spec/files/services/available/success.http +0 -21
- data/spec/files/services/notfound-service.http +0 -19
- data/spec/files/services/service/success.http +0 -21
- data/spec/files/services/services/success.http +0 -21
- data/spec/files/services/unapply/success.http +0 -21
- data/spec/files/subscriptions/subscription/success.http +0 -21
- data/spec/files/templates/apply_template/success.http +0 -21
- data/spec/files/templates/create_template/created.http +0 -22
- data/spec/files/templates/delete_template/success-204.http +0 -21
- data/spec/files/templates/delete_template/success.http +0 -21
- data/spec/files/templates/notfound-template.http +0 -19
- data/spec/files/templates/template/success.http +0 -21
- data/spec/files/templates/templates/success.http +0 -21
- data/spec/files/templates/update_template/success.http +0 -21
- data/spec/files/templates_records/create_record/created.http +0 -22
- data/spec/files/templates_records/delete_record/success-204.http +0 -19
- data/spec/files/templates_records/delete_record/success.http +0 -21
- data/spec/files/templates_records/notfound-template-record.http +0 -19
- data/spec/files/templates_records/record/success.http +0 -21
- data/spec/files/templates_records/records/success.http +0 -21
- data/spec/files/templates_records/update_record/success.http +0 -21
- data/spec/files/users/user/success.http +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6571b9393456ff941623f5001f393bfd819493f3
|
|
4
|
+
data.tar.gz: bf1878874ee2fa403519e51bcf28e7c1a36afbd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fb5142d55bbc3408be6b2626c67a7c2c41caeb4239ace0a1b3624e870857bfb987e0073e3cea7180eec3fb935c819441d9ff1f6eee3de6c9c38b5de2f184763
|
|
7
|
+
data.tar.gz: e681b2fc92d3c1c4d6c51bf9407c28c89b3129e73180009ab6a1e2aabf2ebf7579b70af34c638e8e627dd1979724de3313bdd58057e42b68de1361e19878f433
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.
|
|
1
|
+
ruby-2.3.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This project uses [Semantic Versioning 2.0.0](http://semver.org/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
#### 3.0
|
|
7
|
+
|
|
8
|
+
##### beta1
|
|
9
|
+
|
|
10
|
+
- CHANGED: Minimum Ruby version >= 2
|
|
11
|
+
|
|
12
|
+
- CHANGED: Renamed `api_endpoint` to `base_url` to match the other clients.
|
|
13
|
+
|
|
14
|
+
The client has been completely redesigned to support the [API v2](https://developer.dnsimple.com/v2). Overall, the client behaves like the previous version, however it has been rewritten to leverage the API v2 features specifically.
|
|
15
|
+
|
|
16
|
+
Internal changes were made to match conventions adopted in other clients, such as the Go one and the Elixir one.
|
|
6
17
|
|
|
7
18
|
#### 2.1.1
|
|
8
19
|
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing to DNSimple/Ruby
|
|
2
|
+
|
|
3
|
+
## Getting started
|
|
4
|
+
|
|
5
|
+
Clone the repository and move into it:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ git clone git@github.com:aetrion/dnsimple-ruby.git
|
|
9
|
+
$ cd dnsimple-ruby
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Install the dependencies using [Bundler](http://bundler.io/):
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
$ bundle
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
[Run the test suite](#testing) to check everything works as expected.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Testing
|
|
22
|
+
|
|
23
|
+
To run the test suite:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
$ rake
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Tests
|
|
31
|
+
|
|
32
|
+
Submit unit tests for your changes. You can test your changes on your machine by [running the test suite](#testing).
|
|
33
|
+
|
|
34
|
+
When you submit a PR, tests will also be run on the continuous integration environment [through Travis](https://travis-ci.org/aetrion/dnsimple-ruby).
|
|
35
|
+
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
# DNSimple Ruby Client
|
|
2
2
|
|
|
3
|
-
A Ruby client for the [DNSimple API](https://developer.dnsimple.com/).
|
|
3
|
+
A Ruby client for the [DNSimple API v2](https://developer.dnsimple.com/v2/).
|
|
4
4
|
|
|
5
|
-
[](https://coveralls.io/r/aetrion/dnsimple-ruby?branch=master
|
|
5
|
+
[](https://travis-ci.org/aetrion/dnsimple-ruby)
|
|
6
|
+
[](https://coveralls.io/r/aetrion/dnsimple-ruby?branch=master)
|
|
7
7
|
|
|
8
8
|
[DNSimple](https://dnsimple.com/) provides DNS hosting and domain registration that is simple and friendly.
|
|
9
9
|
We provide a full API and an easy-to-use web interface so you can get your domain registered and set up with a minimal amount of effort.
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
## :warning: Beta Warning
|
|
13
|
+
|
|
14
|
+
This branch targets the development of the API client for the [DNSimple API v2](https://developer.dnsimple.com/v2/). If you are looking for the stable version of the client for [DNSimple API v1](https://developer.dnsimple.com/v1/) then use the [`master-v1`](https://github.com/aetrion/dnsimple-ruby/tree/master-v1) branch.
|
|
15
|
+
|
|
16
|
+
This library is currently in beta version, the methods and the implementation should be considered a work-in-progress. Changes in the method naming, method signatures, public or internal APIs may happen during the beta period.
|
|
17
|
+
|
|
18
|
+
|
|
12
19
|
## Installation
|
|
13
20
|
|
|
14
21
|
```
|
|
@@ -16,103 +23,44 @@ $ gem install dnsimple
|
|
|
16
23
|
```
|
|
17
24
|
|
|
18
25
|
|
|
19
|
-
##
|
|
26
|
+
## Usage
|
|
20
27
|
|
|
21
|
-
This library is a Ruby client you can use to interact with the [DNSimple API](https://developer.dnsimple.com/). Here are some examples.
|
|
28
|
+
This library is a Ruby client you can use to interact with the [DNSimple API v2](https://developer.dnsimple.com/v2/). Here are some examples.
|
|
22
29
|
|
|
23
30
|
```ruby
|
|
24
31
|
require 'dnsimple'
|
|
25
32
|
|
|
26
|
-
client = Dnsimple::Client.new(
|
|
33
|
+
client = Dnsimple::Client.new(access_token: "a1b2c3")
|
|
27
34
|
|
|
28
|
-
# Fetch your
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
# Fetch your details
|
|
36
|
+
response = client.identity.whoami # execute the call
|
|
37
|
+
response.data # extract the relevant data from the response or
|
|
38
|
+
client.identity.whoami.data # execute the call and get the data in one line
|
|
31
39
|
|
|
40
|
+
# Define an account ID.
|
|
41
|
+
account_id = 1010
|
|
42
|
+
|
|
43
|
+
# You can also fetch it from the whoami response
|
|
44
|
+
whoami = client.identity.whoami.data
|
|
45
|
+
account_id = whoami.account.id
|
|
32
46
|
|
|
33
47
|
# List your domains
|
|
34
|
-
|
|
35
|
-
domains.
|
|
36
|
-
|
|
37
|
-
end
|
|
48
|
+
puts client.domains.list_domains(account_id).data # => domains from the account 1234, first page
|
|
49
|
+
puts client.domains.list_domains(account_id, query: { page: 3 }).data # => domains from the account 1234, third page
|
|
50
|
+
puts client.domains.all_domains(account_id).data # => all domains from the account 1234 (use carefully)
|
|
38
51
|
|
|
39
52
|
# Create a domain
|
|
40
|
-
|
|
41
|
-
puts
|
|
53
|
+
response = client.domains.create_domain(account_id, name: "example.com")
|
|
54
|
+
puts response.data
|
|
42
55
|
|
|
43
56
|
# Get a domain
|
|
44
|
-
|
|
45
|
-
puts
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# Create a domain record
|
|
49
|
-
record = client.domains.create_record("example.com", record_type: "A", name: "www", content: "127.0.0.1")
|
|
50
|
-
puts "Record: %s (id: %d)" % [record.name, record.id]
|
|
51
|
-
|
|
52
|
-
# Get a domain record
|
|
53
|
-
record = client.domains.record("example.com", 1234)
|
|
54
|
-
puts "Record: %s (id: %d)" % [record.name, record.id]
|
|
55
|
-
|
|
56
|
-
# List domain records
|
|
57
|
-
records = client.domains.records("example.com")
|
|
58
|
-
records.each do |record|
|
|
59
|
-
puts "Record: %s (id: %d)" % [record.name, record.id]
|
|
60
|
-
end
|
|
57
|
+
response = client.domains.domain(account_id, "example.com")
|
|
58
|
+
puts response.data
|
|
61
59
|
```
|
|
62
60
|
|
|
63
61
|
For the full library documentation visit http://rubydoc.info/gems/dnsimple
|
|
64
62
|
|
|
65
63
|
|
|
66
|
-
## Authentication
|
|
67
|
-
|
|
68
|
-
This client supports both the HTTP Basic and API Token authentication mechanism.
|
|
69
|
-
|
|
70
|
-
#### HTTP Basic
|
|
71
|
-
|
|
72
|
-
```ruby
|
|
73
|
-
client = Dnsimple::Client.new(username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD')
|
|
74
|
-
client.users.user
|
|
75
|
-
# => Dnsimple::Struct::User
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
#### HTTP Basic with two-factor authentication enabled
|
|
79
|
-
|
|
80
|
-
See the [2FA API documentation](https://developer.dnsimple.com/authentication/#twofa).
|
|
81
|
-
|
|
82
|
-
```ruby
|
|
83
|
-
# Request the 2FA exchange token
|
|
84
|
-
client = Dnsimple::Client.new(username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD')
|
|
85
|
-
token = client.users.exchange_token('otp-token')
|
|
86
|
-
|
|
87
|
-
# Authenticate with the exchange token
|
|
88
|
-
client.exchange_token = token
|
|
89
|
-
client.users.user
|
|
90
|
-
# => Dnsimple::Struct::User
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
#### API Token
|
|
94
|
-
|
|
95
|
-
```ruby
|
|
96
|
-
client = Dnsimple::Client.new(username: 'YOUR_USERNAME', api_token: 'YOUR_TOKEN')
|
|
97
|
-
|
|
98
|
-
client.users.user
|
|
99
|
-
# => Dnsimple::Struct::User
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
#### Domain API Token
|
|
103
|
-
|
|
104
|
-
The domain API token grants [limited access]](https://developer.dnsimple.com/v1/authentication/#domain-token) to a single domain.
|
|
105
|
-
|
|
106
|
-
```ruby
|
|
107
|
-
client = Dnsimple::Client.new(domain_api_token: 'DOMAIN_TOKEN')
|
|
108
|
-
|
|
109
|
-
client.domains.records("example.com")
|
|
110
|
-
# => [Dnsimple::Struct::Record, Dnsimple::Struct::Record, ...]
|
|
111
|
-
|
|
112
|
-
client.domains.records("foobar.com")
|
|
113
|
-
# => Authentication error
|
|
114
|
-
```
|
|
115
|
-
|
|
116
64
|
## License
|
|
117
65
|
|
|
118
66
|
Copyright (c) 2010-2016 Aetrion LLC. This is Free Software distributed under the MIT license.
|
data/dnsimple.gemspec
CHANGED
|
@@ -11,11 +11,12 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.summary = 'The DNSimple API client for Ruby'
|
|
12
12
|
s.description = 'The DNSimple API client for Ruby.'
|
|
13
13
|
|
|
14
|
-
s.required_ruby_version = ">=
|
|
14
|
+
s.required_ruby_version = ">= 2.0"
|
|
15
15
|
|
|
16
16
|
s.require_paths = ['lib']
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.extra_rdoc_files = %w( LICENSE.txt )
|
|
19
20
|
|
|
20
21
|
s.add_dependency 'httparty'
|
|
21
22
|
|
data/lib/dnsimple.rb
CHANGED
data/lib/dnsimple/client.rb
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'httparty'
|
|
2
2
|
require 'dnsimple/extra'
|
|
3
3
|
require 'dnsimple/struct'
|
|
4
|
+
require 'dnsimple/response'
|
|
4
5
|
require 'dnsimple/client/clients'
|
|
5
6
|
|
|
6
7
|
module Dnsimple
|
|
7
8
|
|
|
8
9
|
# Client for the DNSimple API
|
|
9
10
|
#
|
|
10
|
-
# @see
|
|
11
|
+
# @see https://developer.dnsimple.com/
|
|
11
12
|
class Client
|
|
12
|
-
include Dnsimple::Compatibility
|
|
13
13
|
|
|
14
|
-
HEADER_2FA_STRICT = "X-DNSimple-2FA-Strict"
|
|
15
|
-
HEADER_API_TOKEN = "X-DNSimple-Token"
|
|
16
14
|
HEADER_DOMAIN_API_TOKEN = "X-DNSimple-Domain-Token"
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
HEADER_AUTHORIZATION = "Authorization"
|
|
16
|
+
WILDCARD_ACCOUNT = "_"
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
# @return [String] The current API version.
|
|
22
|
-
API_VERSION = "
|
|
20
|
+
API_VERSION = "v2"
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
# Prepends the correct API version to +path+.
|
|
@@ -30,29 +28,27 @@ module Dnsimple
|
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
|
|
33
|
-
# @!attribute api_endpoint
|
|
34
|
-
# @return [String] Base URL for API requests. (default: https://api.dnsimple.com/)
|
|
35
31
|
# @!attribute username
|
|
32
|
+
# @see https://developer.dnsimple.com/v2/#authentication
|
|
36
33
|
# @return [String] DNSimple username for Basic Authentication
|
|
37
34
|
# @!attribute password
|
|
38
|
-
# @see
|
|
35
|
+
# @see https://developer.dnsimple.com/v2/#authentication
|
|
39
36
|
# @return [String] DNSimple password for Basic Authentication
|
|
40
|
-
# @!attribute exchange_token
|
|
41
|
-
# @see http://developer.dnsimple.com/authentication/
|
|
42
|
-
# @return [String] Exchange Token for Basic Authentication with 2FA
|
|
43
|
-
# @!attribute api_token
|
|
44
|
-
# @see http://developer.dnsimple.com/authentication/
|
|
45
|
-
# @return [String] API access token for authentication
|
|
46
37
|
# @!attribute domain_api_token
|
|
47
|
-
# @see
|
|
38
|
+
# @see https://developer.dnsimple.com/v2/#authentication
|
|
39
|
+
# @return [String] Domain API access token for authentication
|
|
40
|
+
# @!attribute access_token
|
|
41
|
+
# @see https://developer.dnsimple.com/v2/#authentication
|
|
48
42
|
# @return [String] Domain API access token for authentication
|
|
43
|
+
# @!attribute base_url
|
|
44
|
+
# @return [String] Base URL for API requests. (default: https://api.dnsimple.com/)
|
|
49
45
|
# @!attribute user_agent
|
|
50
46
|
# @return [String] Configure User-Agent header for requests.
|
|
51
47
|
# @!attribute proxy
|
|
52
48
|
# @return [String,nil] Configure address:port values for proxy server
|
|
53
49
|
|
|
54
|
-
attr_accessor :
|
|
55
|
-
:user_agent, :proxy
|
|
50
|
+
attr_accessor :username, :password, :domain_api_token, :access_token,
|
|
51
|
+
:base_url, :user_agent, :proxy
|
|
56
52
|
|
|
57
53
|
|
|
58
54
|
def initialize(options = {})
|
|
@@ -66,61 +62,79 @@ module Dnsimple
|
|
|
66
62
|
end
|
|
67
63
|
|
|
68
64
|
|
|
65
|
+
# @return [String] Base URL for API requests.
|
|
66
|
+
def base_url
|
|
67
|
+
Extra.join_uri(@base_url, "")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
69
71
|
# Make a HTTP GET request.
|
|
70
72
|
#
|
|
71
|
-
# @param [String] path The path, relative to {#
|
|
72
|
-
# @param [Hash] options
|
|
73
|
+
# @param [String] path The path, relative to {#base_url}
|
|
74
|
+
# @param [Hash] options The query and header params for the request
|
|
73
75
|
# @return [HTTParty::Response]
|
|
74
76
|
def get(path, options = {})
|
|
75
|
-
execute :get, path, options
|
|
77
|
+
execute :get, path, nil, options
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
# Make a HTTP POST request.
|
|
79
81
|
#
|
|
80
|
-
# @param [String] path The path, relative to {#
|
|
81
|
-
# @param [Hash]
|
|
82
|
+
# @param [String] path The path, relative to {#base_url}
|
|
83
|
+
# @param [Hash] data The body for the request
|
|
84
|
+
# @param [Hash] options The query and header params for the request
|
|
82
85
|
# @return [HTTParty::Response]
|
|
83
|
-
def post(path,
|
|
84
|
-
execute :post, path, options
|
|
86
|
+
def post(path, data = nil, options= {})
|
|
87
|
+
execute :post, path, data, options
|
|
85
88
|
end
|
|
86
89
|
|
|
87
90
|
# Make a HTTP PUT request.
|
|
88
91
|
#
|
|
89
|
-
# @param [String] path The path, relative to {#
|
|
90
|
-
# @param [Hash]
|
|
92
|
+
# @param [String] path The path, relative to {#base_url}
|
|
93
|
+
# @param [Hash] data The body for the request
|
|
94
|
+
# @param [Hash] options The query and header params for the request
|
|
91
95
|
# @return [HTTParty::Response]
|
|
92
|
-
def put(path, options = {})
|
|
93
|
-
execute :put, path, options
|
|
96
|
+
def put(path, data = nil, options = {})
|
|
97
|
+
execute :put, path, data, options
|
|
94
98
|
end
|
|
95
99
|
|
|
96
|
-
# Make a HTTP
|
|
100
|
+
# Make a HTTP PATCH request.
|
|
97
101
|
#
|
|
98
|
-
# @param [String] path The path, relative to {#
|
|
99
|
-
# @param [Hash]
|
|
102
|
+
# @param [String] path The path, relative to {#base_url}
|
|
103
|
+
# @param [Hash] data The body for the request
|
|
104
|
+
# @param [Hash] options The query and header params for the request
|
|
100
105
|
# @return [HTTParty::Response]
|
|
101
|
-
def
|
|
102
|
-
execute :
|
|
106
|
+
def patch(path, data = nil, options = {})
|
|
107
|
+
execute :patch, path, data, options
|
|
103
108
|
end
|
|
104
109
|
|
|
110
|
+
# Make a HTTP DELETE request.
|
|
111
|
+
#
|
|
112
|
+
# @param [String] path The path, relative to {#base_url}
|
|
113
|
+
# @param [Hash] options The query and header params for the request
|
|
114
|
+
# @return [HTTParty::Response]
|
|
115
|
+
def delete(path, data = nil, options = {})
|
|
116
|
+
execute :delete, path, data, options
|
|
117
|
+
end
|
|
105
118
|
|
|
106
119
|
# Executes a request, validates and returns the response.
|
|
107
120
|
#
|
|
108
121
|
# @param [String] method The HTTP method
|
|
109
|
-
# @param [String] path The path, relative to {#
|
|
110
|
-
# @param [Hash]
|
|
122
|
+
# @param [String] path The path, relative to {#base_url}
|
|
123
|
+
# @param [Hash] data The body for the request
|
|
124
|
+
# @param [Hash] options The query and header params for the request
|
|
111
125
|
# @return [HTTParty::Response]
|
|
112
126
|
# @raise [RequestError]
|
|
113
127
|
# @raise [NotFoundError]
|
|
114
128
|
# @raise [AuthenticationFailed]
|
|
115
129
|
# @raise [TwoFactorAuthenticationRequired]
|
|
116
|
-
def execute(method, path, data, options = {})
|
|
130
|
+
def execute(method, path, data = nil, options = {})
|
|
117
131
|
response = request(method, path, data, options)
|
|
118
132
|
|
|
119
133
|
case response.code
|
|
120
134
|
when 200..299
|
|
121
135
|
response
|
|
122
136
|
when 401
|
|
123
|
-
raise (response
|
|
137
|
+
raise AuthenticationFailed.new(response["message"])
|
|
124
138
|
when 404
|
|
125
139
|
raise NotFoundError.new(response)
|
|
126
140
|
else
|
|
@@ -128,7 +142,6 @@ module Dnsimple
|
|
|
128
142
|
end
|
|
129
143
|
end
|
|
130
144
|
|
|
131
|
-
|
|
132
145
|
# Make a HTTP request.
|
|
133
146
|
#
|
|
134
147
|
# This method doesn't validate the response and never raise errors
|
|
@@ -138,25 +151,14 @@ module Dnsimple
|
|
|
138
151
|
# Therefore, it's up to the caller to properly handle and validate the response.
|
|
139
152
|
#
|
|
140
153
|
# @param [String] method The HTTP method
|
|
141
|
-
# @param [String] path The path, relative to {#
|
|
142
|
-
# @param [Hash]
|
|
154
|
+
# @param [String] path The path, relative to {#base_url}
|
|
155
|
+
# @param [Hash] data The body for the request
|
|
156
|
+
# @param [Hash] options The query and header params for the request
|
|
143
157
|
# @return [HTTParty::Response]
|
|
144
|
-
def request(method, path, data, options = {})
|
|
145
|
-
if data
|
|
146
|
-
options[:query] = data.delete(:query) if data.key?(:query)
|
|
147
|
-
options[:headers] = data.delete(:headers) if data.key?(:headers)
|
|
148
|
-
end
|
|
149
|
-
if !data.empty?
|
|
150
|
-
options[:body] = data
|
|
151
|
-
end
|
|
158
|
+
def request(method, path, data = nil, options = {})
|
|
159
|
+
options[:body] = data if data
|
|
152
160
|
|
|
153
|
-
HTTParty.send(method,
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# @return [String] Base URL for API requests.
|
|
158
|
-
def api_endpoint
|
|
159
|
-
Extra.join_uri(@api_endpoint, "")
|
|
161
|
+
HTTParty.send(method, base_url + path, Extra.deep_merge!(base_options, options))
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
|
|
@@ -173,16 +175,14 @@ module Dnsimple
|
|
|
173
175
|
options.merge!(http_proxyaddr: address, http_proxyport: port)
|
|
174
176
|
end
|
|
175
177
|
|
|
176
|
-
if
|
|
177
|
-
options[:basic_auth] = { username: exchange_token, password: "x-2fa-basic" }
|
|
178
|
-
elsif password
|
|
178
|
+
if password
|
|
179
179
|
options[:basic_auth] = { username: username, password: password }
|
|
180
180
|
elsif domain_api_token
|
|
181
181
|
options[:headers][HEADER_DOMAIN_API_TOKEN] = domain_api_token
|
|
182
|
-
elsif
|
|
183
|
-
options[:headers][
|
|
182
|
+
elsif access_token
|
|
183
|
+
options[:headers][HEADER_AUTHORIZATION] = "Bearer #{access_token}"
|
|
184
184
|
else
|
|
185
|
-
raise Error, 'A password
|
|
185
|
+
raise Error, 'A password, domain API token or access token is required for all API requests.'
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
options
|