libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [1/3] libcloud git commit: Completed documentation and examples for the GoDaddy driver.
Date Wed, 02 Dec 2015 23:38:53 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk dc4daeef4 -> b5cb7bfd3


Completed documentation and examples for the GoDaddy driver.

Signed-off-by: Anthony Shaw <anthony.p.shaw@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ab5f76da
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ab5f76da
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ab5f76da

Branch: refs/heads/trunk
Commit: ab5f76daab1c14c83549e544f0549cfd3e25588c
Parents: 7e087d6
Author: Anthony Shaw <anthony.p.shaw@gmail.com>
Authored: Thu Dec 3 10:02:06 2015 +1100
Committer: Anthony Shaw <anthony.p.shaw@gmail.com>
Committed: Thu Dec 3 10:37:58 2015 +1100

----------------------------------------------------------------------
 CHANGES.rst                                    |   4 +-
 docs/_static/images/provider_logos/godaddy.png | Bin 0 -> 86453 bytes
 docs/dns/drivers/godaddy.rst                   |  96 +++++++++++++++++++-
 docs/examples/dns/create_record_custom_ttl.py  |   4 +-
 docs/examples/dns/godaddy/adding_records.py    |  10 ++
 docs/examples/dns/godaddy/listing_records.py   |  12 +++
 docs/examples/dns/godaddy/listing_zones.py     |  10 ++
 docs/examples/dns/godaddy/pricing_domain.py    |  11 +++
 docs/examples/dns/godaddy/purchasing_domain.py |  16 ++++
 docs/examples/dns/godaddy/updating_records.py  |  15 +++
 libcloud/test/dns/test_godaddy.py              |   2 +-
 11 files changed, 174 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index a3ff33c..4b8a104 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -117,8 +117,8 @@ DNS
   (GITHUB-621)
   [Alejandro Pereira]
 
-- Introduced GoDaddy DNS Driver
-  (LIBCLOUD-772, GITHUB-640)
+- Introduced GoDaddy DNS Driver with examples and documentation
+  (LIBCLOUD-772, GITHUB-640, LIBCLOUD-778)
   [Anthony Shaw]
 
 Changes with Apache Libcloud 0.19.0

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/_static/images/provider_logos/godaddy.png
----------------------------------------------------------------------
diff --git a/docs/_static/images/provider_logos/godaddy.png b/docs/_static/images/provider_logos/godaddy.png
new file mode 100644
index 0000000..730e4a2
Binary files /dev/null and b/docs/_static/images/provider_logos/godaddy.png differ

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/dns/drivers/godaddy.rst
----------------------------------------------------------------------
diff --git a/docs/dns/drivers/godaddy.rst b/docs/dns/drivers/godaddy.rst
index fc3d2c4..f2238fb 100644
--- a/docs/dns/drivers/godaddy.rst
+++ b/docs/dns/drivers/godaddy.rst
@@ -4,14 +4,107 @@ GoDaddy DNS Driver Documentation
 `GoDaddy`_ provide domain name registration and are the worlds largest with over 13 million
customers. They also provide nameservers and DNS hosting as
 well as cloud and website hosting.
 
-See more at https://www.godaddy.com/
+.. figure:: /_static/images/provider_logos/godaddy.png
+    :align: center
+    :width: 300
+    :target: https://www.godaddy.com/
+
+Further information on `GoDaddy`_ API is available on the `GoDaddy API Website`_
+
+Driver features
+---------------
+
+* Manage the records for GoDaddy hosted domains
+* Price and purchase domains with an existing GoDaddy account
+* Fetch legal agreements required to register and purchase domains for a range of TLDs
+* Submit completed agreements to purchase domains
 
 Instantiating the driver
 -------------------------------------
 
+Before you instantiate a driver, you will need a GoDaddy account.
+
+Once you have an account you need to request a Production key on the GoDaddy API website:

+https://developer.godaddy.com/getstarted#access 
+
+You can then use these details to instantiate a driver with the arguments:
+
+* `shopper_id` - Your customer ID
+* `key` - An API key
+* `secret` - The matching secret for the API key
+
 .. literalinclude:: /examples/dns/godaddy/instantiate_driver.py
    :language: python
 
+Listing zones
+---------------
+
+.. literalinclude:: /examples/dns/godaddy/listing_zones.py
+   :language: python
+
+Returns
+
+::
+
+    Zone : wassle-layer.com
+    Expires: 2018-09-30T18:22:00Z
+    Zone : wizzle-wobble.org
+    Expires: 2017-01-04T04:02:07Z
+
+Listing records
+---------------
+
+.. literalinclude:: /examples/dns/godaddy/listing_records.py
+   :language: python
+
+Returns
+
+::
+
+    Type : CNAME
+    Data: @
+    TTL: 3600
+    Type : CNAME
+    Data: @
+    TTL: 3600
+    Type : MX
+    Data: mailstore1.secureserver.net
+    TTL: 3600
+    Type : MX
+    Data: smtp.secureserver.net
+    TTL: 3600
+
+Adding records
+--------------
+
+.. literalinclude:: /examples/dns/godaddy/adding_records.py
+   :language: python
+
+Updating records
+----------------
+
+.. literalinclude:: /examples/dns/godaddy/updating_records.py
+   :language: python
+
+It is important to note that the GoDaddy API does not give records a unique identifier.
+So if you have multiple existing records for a single data and type, e.g. 2 A records for
www, they will both be replaced with 1 record if you run the update_records method
+
+Pricing a domain
+----------------
+
+The driver supports checking the availability of a domain that you would like to purchase.
+
+.. literalinclude:: /examples/dns/godaddy/pricing_domain.py
+   :language: python
+
+Purchasing a domain
+-------------------
+
+Domains can be purchased by requesting the agreement schema, which is a JSON schema and submitted
a completed document.
+
+.. literalinclude:: /examples/dns/godaddy/purchasing_domain.py
+   :language: python
+
 API Docs
 --------
 
@@ -20,3 +113,4 @@ API Docs
     :inherited-members:
 
 .. _`GoDaddy`: https://godaddy.com/
+.. _`GoDaddy API Website`: https://developer.godaddy.com/doc
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/create_record_custom_ttl.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/create_record_custom_ttl.py b/docs/examples/dns/create_record_custom_ttl.py
index 4632a57..3a1dd72 100644
--- a/docs/examples/dns/create_record_custom_ttl.py
+++ b/docs/examples/dns/create_record_custom_ttl.py
@@ -8,6 +8,6 @@ driver = cls(*CREDENTIALS_ZERIGO)
 
 zone = [z for z in driver.list_zones() if z.domain == 'example.com'][0]
 
-extra = {'ttl': 900}
+ttl = 900
 record = zone.create_record(name='www', type=RecordType.A, data='127.0.0.1',
-                            extra=extra)
+                            ttl=ttl)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/adding_records.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/adding_records.py b/docs/examples/dns/godaddy/adding_records.py
new file mode 100644
index 0000000..a54a496
--- /dev/null
+++ b/docs/examples/dns/godaddy/adding_records.py
@@ -0,0 +1,10 @@
+from libcloud.dns.types import Provider, RecordType
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+zone = driver.get_zone('waffle-machines.com')
+record = zone.create_record(name='www',
+                            type=RecordType.A,
+                            data='127.0.0.1',
+                            ttl=5)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/listing_records.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/listing_records.py b/docs/examples/dns/godaddy/listing_records.py
new file mode 100644
index 0000000..8ae1703
--- /dev/null
+++ b/docs/examples/dns/godaddy/listing_records.py
@@ -0,0 +1,12 @@
+from libcloud.dns.types import Provider
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+
+zone = driver.get_zone('wazzle-flooble.com')
+records = driver.list_records(zone)
+for record in records:
+    print("Type : %s" % record.type)
+    print("Data: %s" % record.data)
+    print("TTL: %s" % record.ttl)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/listing_zones.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/listing_zones.py b/docs/examples/dns/godaddy/listing_zones.py
new file mode 100644
index 0000000..7704c8d
--- /dev/null
+++ b/docs/examples/dns/godaddy/listing_zones.py
@@ -0,0 +1,10 @@
+from libcloud.dns.types import Provider
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+
+zones = driver.list_zones()
+for zone in zones:
+    print("Domain : %s" % zone.domain)
+    print("Expires: %s" % zone.extra['expires'])

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/pricing_domain.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/pricing_domain.py b/docs/examples/dns/godaddy/pricing_domain.py
new file mode 100644
index 0000000..4b9b40e
--- /dev/null
+++ b/docs/examples/dns/godaddy/pricing_domain.py
@@ -0,0 +1,11 @@
+from libcloud.dns.types import Provider
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+
+check = driver.ex_check_availability("wazzlewobbleflooble.com")
+if check.available is True:
+    print("Domain is available for %s %s" % (check.price, check.currency))
+else:
+    print("Domain is taken")

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/purchasing_domain.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/purchasing_domain.py b/docs/examples/dns/godaddy/purchasing_domain.py
new file mode 100644
index 0000000..d2ce231
--- /dev/null
+++ b/docs/examples/dns/godaddy/purchasing_domain.py
@@ -0,0 +1,16 @@
+from libcloud.dns.types import Provider
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+
+# Get the JSON schema for the domain
+schema = driver.ex_get_purchase_schema('com')
+
+# Use this schema to prepare a purchase request document
+
+# Load a JSON document that has the completed purchase request
+file = open('purchase_request.json', 'r')
+document = file.read()
+order = driver.ex_purchase_domain(document)
+print("Made request : order ID : %s" % order.order_id)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/docs/examples/dns/godaddy/updating_records.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/godaddy/updating_records.py b/docs/examples/dns/godaddy/updating_records.py
new file mode 100644
index 0000000..902f56c
--- /dev/null
+++ b/docs/examples/dns/godaddy/updating_records.py
@@ -0,0 +1,15 @@
+from libcloud.dns.types import Provider, RecordType
+from libcloud.dns.providers import get_driver
+
+cls = get_driver(Provider.GODADDY)
+driver = cls('customer_id', 'api_key', 'api_secret')
+
+record = driver.get_record(
+    'waffle-machines.com',
+    'www:A')
+record = driver.update_record(
+    record=record,
+    name='www',
+    type=RecordType.A,
+    data='50.63.202.22'
+)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ab5f76da/libcloud/test/dns/test_godaddy.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_godaddy.py b/libcloud/test/dns/test_godaddy.py
index 76360b1..027d108 100644
--- a/libcloud/test/dns/test_godaddy.py
+++ b/libcloud/test/dns/test_godaddy.py
@@ -15,7 +15,7 @@
 
 import sys
 import unittest
-
+from pprint import pprint
 from libcloud.utils.py3 import httplib
 from libcloud.dns.drivers.godaddy import GoDaddyDNSDriver
 from libcloud.test import MockHttp


Mime
View raw message