-
Notifications
You must be signed in to change notification settings - Fork 4
/
changes.clj
112 lines (100 loc) · 3.47 KB
/
changes.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(ns happygapi.dns.changes
"Google Cloud DNS API: changes.
Configures and serves authoritative DNS records.
See: https://developers.google.com/cloud-dnsapi/reference/rest/v1/changes"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn create$
"https://developers.google.com/cloud-dnsapi/reference/rest/v1/changes/create
Required parameters: managedZone, project
Optional parameters: clientOperationId
Body:
{:additions [{:kind string,
:name string,
:rrdatas [string],
:signatureRrdatas [string],
:ttl integer,
:type string}],
:deletions [{:kind string,
:name string,
:rrdatas [string],
:signatureRrdatas [string],
:ttl integer,
:type string}],
:id string,
:isServing boolean,
:kind string,
:startTime string,
:status string}
Atomically update the ResourceRecordSet collection."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/ndev.clouddns.readwrite"]}
[auth args body]
{:pre [(util/has-keys? args #{:managedZone :project})]}
(util/get-response
(http/post
(util/get-url
"https://dns.googleapis.com/dns/v1/projects/"
"{project}/managedZones/{managedZone}/changes"
#{:managedZone :project}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn get$
"https://developers.google.com/cloud-dnsapi/reference/rest/v1/changes/get
Required parameters: changeId, managedZone, project
Optional parameters: clientOperationId
Fetch the representation of an existing Change."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"
"https://www.googleapis.com/auth/ndev.clouddns.readonly"
"https://www.googleapis.com/auth/ndev.clouddns.readwrite"]}
[auth args]
{:pre [(util/has-keys? args #{:managedZone :project :changeId})]}
(util/get-response
(http/get
(util/get-url
"https://dns.googleapis.com/dns/v1/projects/"
"{project}/managedZones/{managedZone}/changes/{changeId}"
#{:managedZone :project :changeId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/cloud-dnsapi/reference/rest/v1/changes/list
Required parameters: managedZone, project
Optional parameters: maxResults, pageToken, sortBy, sortOrder
Enumerate Changes to a ResourceRecordSet collection."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"
"https://www.googleapis.com/auth/ndev.clouddns.readonly"
"https://www.googleapis.com/auth/ndev.clouddns.readwrite"]}
[auth args]
{:pre [(util/has-keys? args #{:managedZone :project})]}
(util/get-response
(http/get
(util/get-url
"https://dns.googleapis.com/dns/v1/projects/"
"{project}/managedZones/{managedZone}/changes"
#{:managedZone :project}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))