/
services.clj
174 lines (147 loc) · 5.15 KB
/
services.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
(ns happygapi.serviceusage.services
"Service Usage API: services.
Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
See: https://cloud.google.com/service-usage/api/reference/rest/v1/services"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn get$
"https://cloud.google.com/service-usage/api/reference/rest/v1/services/get
Required parameters: name
Optional parameters: none
Returns the service configuration and enabled state for a given service."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://serviceusage.googleapis.com/"
"v1/{+name}"
#{:name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn list$
"https://cloud.google.com/service-usage/api/reference/rest/v1/services/list
Required parameters: parent
Optional parameters: filter, pageToken, pageSize
List all services available to the specified project, and the current
state of those services with respect to the project. The list includes
all public services, all services for which the calling user has the
`servicemanagement.services.bind` permission, and all services that have
already been enabled on the project. The list can be filtered to
only include services in a specific state, for example to only include
services enabled on the project."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:parent})]}
(util/get-response
(http/get
(util/get-url
"https://serviceusage.googleapis.com/"
"v1/{+parent}/services"
#{:parent}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn disable$
"https://cloud.google.com/service-usage/api/reference/rest/v1/services/disable
Required parameters: name
Optional parameters: none
Body:
{:disableDependentServices boolean}
Disable a service so that it can no longer be used with a project.
This prevents unintended usage that may cause unexpected billing
charges or security leaks.
It is not valid to call the disable method on a service that is not
currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
the target service is not currently enabled."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/post
(util/get-url
"https://serviceusage.googleapis.com/"
"v1/{+name}:disable"
#{:name}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn batchEnable$
"https://cloud.google.com/service-usage/api/reference/rest/v1/services/batchEnable
Required parameters: parent
Optional parameters: none
Body:
{:serviceIds [string]}
Enable multiple services on a project. The operation is atomic: if enabling
any service fails, then the entire batch fails, and no state changes occur.
To enable a single service, use the `EnableService` method instead."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:parent})]}
(util/get-response
(http/post
(util/get-url
"https://serviceusage.googleapis.com/"
"v1/{+parent}/services:batchEnable"
#{:parent}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn enable$
"https://cloud.google.com/service-usage/api/reference/rest/v1/services/enable
Required parameters: name
Optional parameters: none
Body:
{}
Enable a service so that it can be used with a project."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/post
(util/get-url
"https://serviceusage.googleapis.com/"
"v1/{+name}:enable"
#{:name}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))