diff options
author | Chad Phillips <chad@apartmentlines.com> | 2017-11-27 09:57:15 -0700 |
---|---|---|
committer | Chad Phillips <chad@apartmentlines.com> | 2017-11-27 09:57:15 -0700 |
commit | f463f9a318d7eb9d9ab49e1e96fa9941738c492d (patch) | |
tree | be6e4679fdec218e7035ad424cc8b26bfa712484 | |
parent | bump version (diff) |
Add usage examples to README
-rw-r--r-- | README.md | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -22,3 +22,68 @@ If [available in Hex](https://hex.pm/docs/publish), the package can be installed end ``` +## Example usage + +```elixir +# CREATE ZONE: +zone_model = %PowerDNSex.Models.Zone{ + id: "example.com.", + kind: "Master", + name: "example.com.", + serial: 1, +} +{:ok, zone} = PowerDNSex.create_zone(zone_model) + +# SHOW ZONE: +{:ok, zone} = PowerDNSex.show_zone("example.com") + +# DELETE ZONE: +res = PowerDNSex.delete_zone("example.com") + +# CREATE RECORD: +{:ok, zone} = PowerDNSex.show_zone("example.com") +record = %{ + name: "test.example.com.", + type: "A", + ttl: 60, + records: [ + %{ + content: "192.168.11.67", + disabled: false, + } + ] +} +res = PowerDNSex.create_record(zone, record) + +# SHOW RECORD: +record = %{ + name: "test.example.com.", + type: "A", +} +rrset = PowerDNSex.show_record("example.com", record) + +# UPDATE RECORD: +{:ok, zone} = PowerDNSex.show_zone("example.com") +record = %{ + name: "test.example.com.", + type: "A", + ttl: 60, + records: [ + %{ + content: "192.168.11.100", + disabled: false, + } + ] +} +res = PowerDNSex.update_record(zone, record) + +# DELETE RECORD: +{:ok, zone} = PowerDNSex.show_zone("example.com") +record = %{ + name: "test.example.com.", + type: "A", +} +rrset = PowerDNSex.show_record("example.com", record) +res = PowerDNSex.delete_record(zone, rrset) + +``` |