-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.cljc
564 lines (439 loc) · 17.3 KB
/
app.cljc
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
(ns kintone-client.app
(:require
[kintone-client.constant.path.app :as path]
[kintone-client.protocols :as pt]))
(defn get-app
"Gets general information of an App, including the name, description, related Space, creator and updater information.
app - The kintone app ID.
integer"
[conn app]
(let [url (pt/-url conn path/app)]
(pt/-get conn url {:params {:id app}})))
(defn get-form
"Retrieves the form details of an app.
WARN: This API is being deprecated.
c.f. https://developer.kintone.io/hc/en-us/articles/213148927
app - The kintone app ID.
integer"
[conn app]
(let [url (pt/-url conn path/form)]
(pt/-get conn url {:params {:app app}})))
(defn get-apps
"Gets general information of multiple Apps, including the name, description, related Space, creator and updater information.
opts
:offset - The number of retrievals that will be skipped.
The default value is 0 if this is not assigned.
integer
:limit - The number of Apps to retrieve.
The default value is 100 if this is not assigned.
integer
:codes - The App Code.
sequence of string
:name - The App Name.
string
:ids - The App IDs.
sequence of integer
:space-ids - The space id where the app resides.
sequence of integer"
[conn {:keys [offset limit codes name ids space-ids]}]
(let [params (cond-> {}
(some? offset) (assoc :offset offset)
(some? limit) (assoc :limit limit)
(seq codes) (assoc :codes codes)
(some? name) (assoc :name name)
(seq ids) (assoc :ids ids)
(seq space-ids) (assoc :spaceIds space-ids))
url (pt/-url conn path/apps)]
(pt/-get conn url {:params params})))
(defn get-form-layout
"Gets form layout of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:preview? - Gets from pre-live settings."
[conn app {:keys [preview?]}]
(let [url (pt/-url conn (if preview?
path/preview-form-layout
path/form-layout))]
(pt/-get conn url {:params {:app app}})))
(defn update-form-layout
"Updates the field layout info of a form in an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID
integer
layout - A list of field layouts for each row.
See API reference regarding form layout format.
sequence of map"
[conn app layout {:keys [revision]}]
(let [params (cond-> {:app app :layout layout}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-form-layout)]
(pt/-put conn url {:params params})))
(defn get-form-fields
"Gets the list of fields and field settings of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:lang - The localized language to retrieve the data.
Support:
default: default name
ja: Japanese
zh: Chinese
en: English
user: the language setting set on the user used for the authentication
The default value is default if this is not assigned.
string
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [lang preview?]}]
(let [params (cond-> {:app app}
(some? lang) (assoc :lang lang))
url (pt/-url conn (if preview?
path/preview-form-fields
path/form-fields))]
(pt/-get conn url {:params params})))
(defn add-form-fields
"Adds fields to a form of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
fields - The field settings.
See API reference regarding field format.
map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app fields {:keys [revision]}]
(let [params (cond-> {:app app :properties fields}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-form-fields)]
(pt/-post conn url {:params params})))
(defn update-form-fields
"Updates the field settings of fields in a form of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
fields - The field settings.
See API reference regarding record format.
map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app fields {:keys [revision]}]
(let [params (cond-> {:app app :properties fields}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-form-fields)]
(pt/-put conn url {:params params})))
(defn delete-form-fields
"Deletes fields from a form of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
codes - The list of field codes of the fields to delete.
Up to 100 field codes can be specified.
sequence
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app codes {:keys [revision]}]
(let [params (cond-> {:app app :fields codes}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-form-fields)]
(pt/-delete conn url {:params params})))
(defn add-preview-app
"Creates a preview App.
The `deploy-app-settings` must be used on the created preview App for the App to become live.
API Tokens cannot be used with this API.
opts
:name - The App name. (Required)
string
:space - The Space ID of where the App will be created.
integer
:thread - The Thread ID of the thread in the Space where the App will be created.
integer"
[conn {:keys [name space thread]}]
(let [params (cond-> {:name name}
(some? space) (assoc :space space)
(some? thread) (assoc :thread thread))
url (pt/-url conn path/preview-app)]
(pt/-post conn url {:params params})))
(defn deploy-app-settings
"Updates the settings of a pre-live App to the live App.
API Tokens cannot be used with this API.
apps - The list of Apps to deploy the pre-live settings to the live Apps.
sequence of integer
opts
:revert - Specify true to cancel all changes made to the pre-live settings.
boolean"
[conn apps {:keys [revert]}]
(let [params (cond-> {:apps apps}
(some? revert) (assoc :revert revert))
url (pt/-url conn path/preview-deploy)]
(pt/-post conn url {:params params})))
(defn get-app-deploy-status
"Gets the deployment status of the App settings for multiple Apps.
API Tokens cannot be used with this API.
apps - Sequence of kintone app ID.
sequence of integer"
[conn apps]
(let [params {:apps apps}
url (pt/-url conn path/preview-deploy)]
(pt/-get conn url {:params params})))
(defn get-views
"Gets the View settings of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:lang - The localized language to retrieve the data.
Support:
default: default name
ja: Japanese
zh: Chinese
en: English
user: the language setting set on the user used for the authentication
The default value is default if this is not assigned.
string
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [lang preview?]}]
(let [params (cond-> {:app app}
(some? lang) (assoc :lang lang))
url (pt/-url conn (if preview?
path/preview-views
path/views))]
(pt/-get conn url {:params params})))
(defn update-views
"Updates the View settings of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
views - The view settings.
See API reference regarding record format.
map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app views {:keys [revision]}]
(let [params (cond-> {:app app :views views}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-views)]
(pt/-put conn url {:params params})))
(defn get-general-settings
"Gets the description, name, icon, revision and color theme of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:lang - The localized language to retrieve the data.
Support:
default: default name
ja: Japanese
zh: Chinese
en: English
user: the language setting set on the user used for the authentication
The default value is default if this is not assigned.
string
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [lang preview?]}]
(let [params (cond-> {:app app}
(some? lang) (assoc :lang lang))
url (pt/-url conn (if preview?
path/preview-settings
path/settings))]
(pt/-get conn url {:params params})))
(defn update-general-settings
"Updates the description, name, icon, revision and color theme of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
settings - The general settings.
Parameters that are ignored will not be updated.
See API reference regarding general settings format.
map
:name - The App name.
string
:icon - The app icon.
map
:type - The icon type. \"FILE\" or \"PRESET\"
string
:key - The key identifier of the icon.
string
:file - The key identifier of the icon.
map
:fileKey - The file key of the icon.
string
:theme - The Color theme.
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app settings {:keys [revision]}]
(let [params (cond-> (merge {:app app} settings)
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-settings)]
(pt/-put conn url {:params params})))
(defn get-status
"Gets the process management settings of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:lang - The localized language to retrieve the data.
Support:
default: default name
ja: Japanese
zh: Chinese
en: English
user: the language setting set on the user used for the authentication
The default value is default if this is not assigned.
string
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [lang preview?]}]
(let [params (cond-> {:app app}
(some? lang) (assoc :lang lang))
url (pt/-url conn (if preview?
path/preview-status
path/status))]
(pt/-get conn url {:params params})))
(defn update-status
"Updates the process management settings of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone App ID.
status - The process management setting.
See API reference regarding process management format.
map
:enable - The on/off settings of the process management settings.
string
:states - The process management statuses.
map
:actions - The actions.
sequence of map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app status {:keys [revision]}]
(let [params (cond-> (merge {:app app} status)
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-status)]
(pt/-put conn url {:params params})))
(defn get-customize
"Gets the JavaScript and CSS Customization settings of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [preview?]}]
(let [params {:app app}
url (pt/-url conn (if preview?
path/preview-customize
path/customize))]
(pt/-get conn url {:params params})))
(defn update-customize
"Updates the JavaScript and CSS Customization settings of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
customize - Customize setting.
See API reference regarding customize format.
map
:desktop - The setting of JavaScript and CSS files for the desktop.
map
:mobile - The setting of JavaScript and CSS files for the desktop.
map
:scope - The scope of customization.
string
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app customize {:keys [revision]}]
(let [params (cond-> (merge {:app app} customize)
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-customize)]
(pt/-put conn url {:params params})))
(defn get-acl
"Gets the App permissions of an app.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [preview?]}]
(let [params {:app app}
url (pt/-url conn (if preview?
path/preview-acl
path/acl))]
(pt/-get conn url {:params params})))
(defn update-acl
"Updates the App permissions of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
rights - The permission settings.
See API reference regarding permission format.
sequence of map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app rights {:keys [revision]}]
(let [params (cond-> {:app app :rights rights}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-acl)]
(pt/-put conn url {:params params})))
(defn get-field-acl
"Gets the Field permission settings of an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
integer
opts
:preview? - Gets from pre-live settings.
boolean"
[conn app {:keys [preview?]}]
(let [params {:app app}
url (pt/-url conn (if preview?
path/preview-field-acl
path/field-acl))]
(pt/-get conn url {:params params})))
(defn update-field-acl
"Updates the Field permission settings of an App.
After using this API, use the `deploy-app-settings` to deploy the settings to the live App.
API Tokens cannot be used with this API.
app - The kintone app ID.
rights - The field permission settings.
See API reference regarding field permission format.
sequence of map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app rights {:keys [revision]}]
(let [params (cond-> {:app app :rights rights}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/preview-field-acl)]
(pt/-put conn url {:params params})))
(defn update-live-field-acl
"Updates the Field permission settings of LIVE ENVIRONMENT an App.
API Tokens cannot be used with this API.
app - The kintone app ID.
rights - The field permission settings.
See API reference regarding field permission format.
sequence of map
opts
:revision - Specify the revision number of the settings that will be deployed.
integer"
[conn app rights {:keys [revision]}]
(let [params (cond-> {:app app :rights rights}
(some? revision) (assoc :revision revision))
url (pt/-url conn path/field-acl)]
(pt/-put conn url {:params params})))