docs: Add examples which show how to create a record with a custom TTL and record with a priority.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d05449fc Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d05449fc Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d05449fc Branch: refs/heads/trunk Commit: d05449fcfb22172f4d81021b6189f46ceb07d542 Parents: 783b5e7 Author: Tomaz Muraus <[email protected]> Authored: Wed Sep 11 00:38:18 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Wed Sep 11 00:38:18 2013 +0200 ---------------------------------------------------------------------- docs/dns/examples.rst | 18 ++++++++++++++++++ docs/examples/dns/create_record_custom_ttl.py | 13 +++++++++++++ docs/examples/dns/create_record_with_priority.py | 13 +++++++++++++ 3 files changed, 44 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/d05449fc/docs/dns/examples.rst ---------------------------------------------------------------------- diff --git a/docs/dns/examples.rst b/docs/dns/examples.rst index a9d9fd5..795d9c4 100644 --- a/docs/dns/examples.rst +++ b/docs/dns/examples.rst @@ -10,3 +10,21 @@ public IP address. .. literalinclude:: /examples/dns/create_a_record_for_all_rackspace_nodes.py :language: python + +Create a record with a custom TTL +--------------------------------- + +This example shows how to create a record with a custom TTL. Keep in mind that +not all of the providers support setting a custom, per record TTL. + +.. literalinclude:: /examples/dns/create_record_custom_ttl.py + :language: python + +Create a MX record and specify a priority +----------------------------------------- + +Some record types such as ``MX`` and ``SRV`` allow you to specify priority. This +example shows how to do that. + +.. literalinclude:: /examples/dns/create_record_with_priority.py + :language: python http://git-wip-us.apache.org/repos/asf/libcloud/blob/d05449fc/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 new file mode 100644 index 0000000..4632a57 --- /dev/null +++ b/docs/examples/dns/create_record_custom_ttl.py @@ -0,0 +1,13 @@ +from libcloud.dns.providers import get_driver +from libcloud.dns.types import Provider, RecordType + +CREDENTIALS_ZERIGO = ('email', 'api key') + +cls = get_driver(Provider.ZERIGO) +driver = cls(*CREDENTIALS_ZERIGO) + +zone = [z for z in driver.list_zones() if z.domain == 'example.com'][0] + +extra = {'ttl': 900} +record = zone.create_record(name='www', type=RecordType.A, data='127.0.0.1', + extra=extra) http://git-wip-us.apache.org/repos/asf/libcloud/blob/d05449fc/docs/examples/dns/create_record_with_priority.py ---------------------------------------------------------------------- diff --git a/docs/examples/dns/create_record_with_priority.py b/docs/examples/dns/create_record_with_priority.py new file mode 100644 index 0000000..ddcbcaf --- /dev/null +++ b/docs/examples/dns/create_record_with_priority.py @@ -0,0 +1,13 @@ +from libcloud.dns.providers import get_driver +from libcloud.dns.types import Provider, RecordType + +CREDENTIALS_ZERIGO = ('email', 'api key') + +cls = get_driver(Provider.ZERIGO) +driver = cls(*CREDENTIALS_ZERIGO) + +zone = [z for z in driver.list_zones() if z.domain == 'example.com'][0] + +extra = {'priority': 10} +record = zone.create_record(name=None, type=RecordType.MX, + data='aspmx.l.google.com', extra=extra)
