/
products.clj
200 lines (168 loc) · 7 KB
/
products.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
(ns happygapi.androidenterprise.products
"Google Play EMM API: products.
Manages the deployment of apps to Android for Work users.
See: https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn approve$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/approve
Required parameters: enterpriseId, productId
Optional parameters: none
Body:
{:approvalUrlInfo {:approvalUrl string, :kind string},
:approvedPermissions string}
Approves the specified product and the relevant app permissions, if any. The maximum number of products that you can approve per enterprise customer is 1,000.
To learn how to use managed Google Play to design and create a store layout to display approved products to your users, see Store Layout Design."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}/approve"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn generateApprovalUrl$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/generateApprovalUrl
Required parameters: enterpriseId, productId
Optional parameters: languageCode
Generates a URL that can be rendered in an iframe to display the permissions (if any) of a product. An enterprise admin must view these permissions and accept them on behalf of their organization in order to approve that product.
Admins should accept the displayed permissions by interacting with a separate UI element in the EMM console, which in turn should trigger the use of this URL as the approvalUrlInfo.approvalUrl property in a Products.approve call to approve the product. This URL can only be used to display permissions for up to 1 day."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}/generateApprovalUrl"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn get$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/get
Required parameters: enterpriseId, productId
Optional parameters: language
Retrieves details of a product for display to an enterprise admin."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn getAppRestrictionsSchema$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/getAppRestrictionsSchema
Required parameters: enterpriseId, productId
Optional parameters: language
Retrieves the schema that defines the configurable properties for this product. All products have a schema, but this schema may be empty if no managed configurations have been defined. This schema can be used to populate a UI that allows an admin to configure the product. To apply a managed configuration based on the schema obtained using this API, see Managed Configurations through Play."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}/appRestrictionsSchema"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn getPermissions$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/getPermissions
Required parameters: enterpriseId, productId
Optional parameters: none
Retrieves the Android app permissions required by this app."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}/permissions"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/list
Required parameters: enterpriseId
Optional parameters: approved, language, maxResults, query, token
Finds approved products that match a query, or all approved products if there is no query."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products"
#{:enterpriseId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn unapprove$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/products/unapprove
Required parameters: enterpriseId, productId
Optional parameters: none
Unapproves the specified product (and the relevant app permissions, if any)"
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:enterpriseId :productId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/products/{productId}/unapprove"
#{:enterpriseId :productId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))