appwrite-cli 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +66 -74
- package/lib/commands/account.js +458 -199
- package/lib/commands/assistant.js +40 -10
- package/lib/commands/avatars.js +171 -71
- package/lib/commands/console.js +40 -6
- package/lib/commands/databases.js +838 -555
- package/lib/commands/functions.js +493 -288
- package/lib/commands/generic.js +0 -1
- package/lib/commands/graphql.js +53 -14
- package/lib/commands/health.js +272 -71
- package/lib/commands/locale.js +131 -20
- package/lib/commands/migrations.js +282 -151
- package/lib/commands/project.js +111 -36
- package/lib/commands/projects.js +670 -415
- package/lib/commands/proxy.js +100 -32
- package/lib/commands/storage.js +374 -204
- package/lib/commands/teams.js +239 -107
- package/lib/commands/users.js +465 -266
- package/lib/commands/vcs.js +161 -57
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
package/lib/commands/teams.js
CHANGED
|
@@ -9,390 +9,523 @@ const { Command } = require('commander');
|
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
|
+
const { File } = require('undici');
|
|
13
|
+
const { ReadableStream } = require('stream/web');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {fs.ReadStream} readStream
|
|
17
|
+
* @returns {ReadableStream}
|
|
18
|
+
*/
|
|
19
|
+
function convertReadStreamToReadableStream(readStream) {
|
|
20
|
+
return new ReadableStream({
|
|
21
|
+
start(controller) {
|
|
22
|
+
readStream.on("data", (chunk) => {
|
|
23
|
+
controller.enqueue(chunk);
|
|
24
|
+
});
|
|
25
|
+
readStream.on("end", () => {
|
|
26
|
+
controller.close();
|
|
27
|
+
});
|
|
28
|
+
readStream.on("error", (err) => {
|
|
29
|
+
controller.error(err);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
cancel() {
|
|
33
|
+
readStream.destroy();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
12
37
|
|
|
13
38
|
const teams = new Command("teams").description(commandDescriptions['teams']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} TeamsListRequestParams
|
|
44
|
+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total
|
|
45
|
+
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
46
|
+
* @property {boolean} parseOutput
|
|
47
|
+
* @property {libClient | undefined} sdk
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {TeamsListRequestParams} params
|
|
52
|
+
*/
|
|
17
53
|
const teamsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
18
|
-
/* @param {string[]} queries */
|
|
19
|
-
/* @param {string} search */
|
|
20
|
-
|
|
21
54
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
22
55
|
let apiPath = '/teams';
|
|
23
56
|
let payload = {};
|
|
24
|
-
|
|
25
|
-
/** Query Params */
|
|
26
57
|
if (typeof queries !== 'undefined') {
|
|
27
58
|
payload['queries'] = queries;
|
|
28
59
|
}
|
|
29
60
|
if (typeof search !== 'undefined') {
|
|
30
61
|
payload['search'] = search;
|
|
31
62
|
}
|
|
63
|
+
|
|
32
64
|
let response = undefined;
|
|
65
|
+
|
|
33
66
|
response = await client.call('get', apiPath, {
|
|
34
67
|
'content-type': 'application/json',
|
|
35
68
|
}, payload);
|
|
36
|
-
|
|
69
|
+
|
|
37
70
|
if (parseOutput) {
|
|
38
71
|
parse(response)
|
|
39
72
|
success()
|
|
40
73
|
}
|
|
74
|
+
|
|
41
75
|
return response;
|
|
42
76
|
}
|
|
43
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {Object} TeamsCreateRequestParams
|
|
80
|
+
* @property {string} teamId Team ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
81
|
+
* @property {string} name Team name. Max length: 128 chars.
|
|
82
|
+
* @property {string[]} roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
|
83
|
+
* @property {boolean} parseOutput
|
|
84
|
+
* @property {libClient | undefined} sdk
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {TeamsCreateRequestParams} params
|
|
89
|
+
*/
|
|
44
90
|
const teamsCreate = async ({ teamId, name, roles, parseOutput = true, sdk = undefined}) => {
|
|
45
|
-
/* @param {string} teamId */
|
|
46
|
-
/* @param {string} name */
|
|
47
|
-
/* @param {string[]} roles */
|
|
48
|
-
|
|
49
91
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
50
92
|
let apiPath = '/teams';
|
|
51
93
|
let payload = {};
|
|
52
|
-
|
|
53
|
-
/** Body Params */
|
|
54
|
-
|
|
55
94
|
if (typeof teamId !== 'undefined') {
|
|
56
95
|
payload['teamId'] = teamId;
|
|
57
96
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
97
|
if (typeof name !== 'undefined') {
|
|
61
98
|
payload['name'] = name;
|
|
62
99
|
}
|
|
63
|
-
|
|
64
100
|
roles = roles === true ? [] : roles;
|
|
65
|
-
|
|
66
101
|
if (typeof roles !== 'undefined') {
|
|
67
102
|
payload['roles'] = roles;
|
|
68
103
|
}
|
|
69
104
|
|
|
70
105
|
let response = undefined;
|
|
106
|
+
|
|
71
107
|
response = await client.call('post', apiPath, {
|
|
72
108
|
'content-type': 'application/json',
|
|
73
109
|
}, payload);
|
|
74
|
-
|
|
110
|
+
|
|
75
111
|
if (parseOutput) {
|
|
76
112
|
parse(response)
|
|
77
113
|
success()
|
|
78
114
|
}
|
|
115
|
+
|
|
79
116
|
return response;
|
|
80
117
|
}
|
|
81
118
|
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {Object} TeamsGetRequestParams
|
|
121
|
+
* @property {string} teamId Team ID.
|
|
122
|
+
* @property {boolean} parseOutput
|
|
123
|
+
* @property {libClient | undefined} sdk
|
|
124
|
+
*/
|
|
84
125
|
|
|
126
|
+
/**
|
|
127
|
+
* @param {TeamsGetRequestParams} params
|
|
128
|
+
*/
|
|
129
|
+
const teamsGet = async ({ teamId, parseOutput = true, sdk = undefined}) => {
|
|
85
130
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
86
131
|
let apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
|
|
87
132
|
let payload = {};
|
|
133
|
+
|
|
88
134
|
let response = undefined;
|
|
135
|
+
|
|
89
136
|
response = await client.call('get', apiPath, {
|
|
90
137
|
'content-type': 'application/json',
|
|
91
138
|
}, payload);
|
|
92
|
-
|
|
139
|
+
|
|
93
140
|
if (parseOutput) {
|
|
94
141
|
parse(response)
|
|
95
142
|
success()
|
|
96
143
|
}
|
|
144
|
+
|
|
97
145
|
return response;
|
|
98
146
|
}
|
|
99
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @typedef {Object} TeamsUpdateNameRequestParams
|
|
150
|
+
* @property {string} teamId Team ID.
|
|
151
|
+
* @property {string} name New team name. Max length: 128 chars.
|
|
152
|
+
* @property {boolean} parseOutput
|
|
153
|
+
* @property {libClient | undefined} sdk
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {TeamsUpdateNameRequestParams} params
|
|
158
|
+
*/
|
|
100
159
|
const teamsUpdateName = async ({ teamId, name, parseOutput = true, sdk = undefined}) => {
|
|
101
|
-
/* @param {string} teamId */
|
|
102
|
-
/* @param {string} name */
|
|
103
|
-
|
|
104
160
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
105
161
|
let apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
|
|
106
162
|
let payload = {};
|
|
107
|
-
|
|
108
|
-
/** Body Params */
|
|
109
|
-
|
|
110
163
|
if (typeof name !== 'undefined') {
|
|
111
164
|
payload['name'] = name;
|
|
112
165
|
}
|
|
113
166
|
|
|
114
167
|
let response = undefined;
|
|
168
|
+
|
|
115
169
|
response = await client.call('put', apiPath, {
|
|
116
170
|
'content-type': 'application/json',
|
|
117
171
|
}, payload);
|
|
118
|
-
|
|
172
|
+
|
|
119
173
|
if (parseOutput) {
|
|
120
174
|
parse(response)
|
|
121
175
|
success()
|
|
122
176
|
}
|
|
177
|
+
|
|
123
178
|
return response;
|
|
124
179
|
}
|
|
125
180
|
|
|
126
|
-
|
|
127
|
-
|
|
181
|
+
/**
|
|
182
|
+
* @typedef {Object} TeamsDeleteRequestParams
|
|
183
|
+
* @property {string} teamId Team ID.
|
|
184
|
+
* @property {boolean} parseOutput
|
|
185
|
+
* @property {libClient | undefined} sdk
|
|
186
|
+
*/
|
|
128
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @param {TeamsDeleteRequestParams} params
|
|
190
|
+
*/
|
|
191
|
+
const teamsDelete = async ({ teamId, parseOutput = true, sdk = undefined}) => {
|
|
129
192
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
130
193
|
let apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
|
|
131
194
|
let payload = {};
|
|
195
|
+
|
|
132
196
|
let response = undefined;
|
|
197
|
+
|
|
133
198
|
response = await client.call('delete', apiPath, {
|
|
134
199
|
'content-type': 'application/json',
|
|
135
200
|
}, payload);
|
|
136
|
-
|
|
201
|
+
|
|
137
202
|
if (parseOutput) {
|
|
138
203
|
parse(response)
|
|
139
204
|
success()
|
|
140
205
|
}
|
|
206
|
+
|
|
141
207
|
return response;
|
|
142
208
|
}
|
|
143
209
|
|
|
210
|
+
/**
|
|
211
|
+
* @typedef {Object} TeamsListLogsRequestParams
|
|
212
|
+
* @property {string} teamId Team ID.
|
|
213
|
+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset
|
|
214
|
+
* @property {boolean} parseOutput
|
|
215
|
+
* @property {libClient | undefined} sdk
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param {TeamsListLogsRequestParams} params
|
|
220
|
+
*/
|
|
144
221
|
const teamsListLogs = async ({ teamId, queries, parseOutput = true, sdk = undefined}) => {
|
|
145
|
-
/* @param {string} teamId */
|
|
146
|
-
/* @param {string[]} queries */
|
|
147
|
-
|
|
148
222
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
149
223
|
let apiPath = '/teams/{teamId}/logs'.replace('{teamId}', teamId);
|
|
150
224
|
let payload = {};
|
|
151
|
-
|
|
152
|
-
/** Query Params */
|
|
153
225
|
if (typeof queries !== 'undefined') {
|
|
154
226
|
payload['queries'] = queries;
|
|
155
227
|
}
|
|
228
|
+
|
|
156
229
|
let response = undefined;
|
|
230
|
+
|
|
157
231
|
response = await client.call('get', apiPath, {
|
|
158
232
|
'content-type': 'application/json',
|
|
159
233
|
}, payload);
|
|
160
|
-
|
|
234
|
+
|
|
161
235
|
if (parseOutput) {
|
|
162
236
|
parse(response)
|
|
163
237
|
success()
|
|
164
238
|
}
|
|
239
|
+
|
|
165
240
|
return response;
|
|
166
241
|
}
|
|
167
242
|
|
|
243
|
+
/**
|
|
244
|
+
* @typedef {Object} TeamsListMembershipsRequestParams
|
|
245
|
+
* @property {string} teamId Team ID.
|
|
246
|
+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm
|
|
247
|
+
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
248
|
+
* @property {boolean} parseOutput
|
|
249
|
+
* @property {libClient | undefined} sdk
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @param {TeamsListMembershipsRequestParams} params
|
|
254
|
+
*/
|
|
168
255
|
const teamsListMemberships = async ({ teamId, queries, search, parseOutput = true, sdk = undefined}) => {
|
|
169
|
-
/* @param {string} teamId */
|
|
170
|
-
/* @param {string[]} queries */
|
|
171
|
-
/* @param {string} search */
|
|
172
|
-
|
|
173
256
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
174
257
|
let apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
|
|
175
258
|
let payload = {};
|
|
176
|
-
|
|
177
|
-
/** Query Params */
|
|
178
259
|
if (typeof queries !== 'undefined') {
|
|
179
260
|
payload['queries'] = queries;
|
|
180
261
|
}
|
|
181
262
|
if (typeof search !== 'undefined') {
|
|
182
263
|
payload['search'] = search;
|
|
183
264
|
}
|
|
265
|
+
|
|
184
266
|
let response = undefined;
|
|
267
|
+
|
|
185
268
|
response = await client.call('get', apiPath, {
|
|
186
269
|
'content-type': 'application/json',
|
|
187
270
|
}, payload);
|
|
188
|
-
|
|
271
|
+
|
|
189
272
|
if (parseOutput) {
|
|
190
273
|
parse(response)
|
|
191
274
|
success()
|
|
192
275
|
}
|
|
276
|
+
|
|
193
277
|
return response;
|
|
194
278
|
}
|
|
195
279
|
|
|
280
|
+
/**
|
|
281
|
+
* @typedef {Object} TeamsCreateMembershipRequestParams
|
|
282
|
+
* @property {string} teamId Team ID.
|
|
283
|
+
* @property {string[]} roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
|
284
|
+
* @property {string} email Email of the new team member.
|
|
285
|
+
* @property {string} userId ID of the user to be added to a team.
|
|
286
|
+
* @property {string} phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
|
|
287
|
+
* @property {string} url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
|
288
|
+
* @property {string} name Name of the new team member. Max length: 128 chars.
|
|
289
|
+
* @property {boolean} parseOutput
|
|
290
|
+
* @property {libClient | undefined} sdk
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @param {TeamsCreateMembershipRequestParams} params
|
|
295
|
+
*/
|
|
196
296
|
const teamsCreateMembership = async ({ teamId, roles, email, userId, phone, url, name, parseOutput = true, sdk = undefined}) => {
|
|
197
|
-
/* @param {string} teamId */
|
|
198
|
-
/* @param {string[]} roles */
|
|
199
|
-
/* @param {string} email */
|
|
200
|
-
/* @param {string} userId */
|
|
201
|
-
/* @param {string} phone */
|
|
202
|
-
/* @param {string} url */
|
|
203
|
-
/* @param {string} name */
|
|
204
|
-
|
|
205
297
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
206
298
|
let apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
|
|
207
299
|
let payload = {};
|
|
208
|
-
|
|
209
|
-
/** Body Params */
|
|
210
|
-
|
|
211
300
|
if (typeof email !== 'undefined') {
|
|
212
301
|
payload['email'] = email;
|
|
213
302
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
303
|
if (typeof userId !== 'undefined') {
|
|
217
304
|
payload['userId'] = userId;
|
|
218
305
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
306
|
if (typeof phone !== 'undefined') {
|
|
222
307
|
payload['phone'] = phone;
|
|
223
308
|
}
|
|
224
|
-
|
|
225
309
|
roles = roles === true ? [] : roles;
|
|
226
|
-
|
|
227
310
|
if (typeof roles !== 'undefined') {
|
|
228
311
|
payload['roles'] = roles;
|
|
229
312
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
313
|
if (typeof url !== 'undefined') {
|
|
233
314
|
payload['url'] = url;
|
|
234
315
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
316
|
if (typeof name !== 'undefined') {
|
|
238
317
|
payload['name'] = name;
|
|
239
318
|
}
|
|
240
319
|
|
|
241
320
|
let response = undefined;
|
|
321
|
+
|
|
242
322
|
response = await client.call('post', apiPath, {
|
|
243
323
|
'content-type': 'application/json',
|
|
244
324
|
}, payload);
|
|
245
|
-
|
|
325
|
+
|
|
246
326
|
if (parseOutput) {
|
|
247
327
|
parse(response)
|
|
248
328
|
success()
|
|
249
329
|
}
|
|
330
|
+
|
|
250
331
|
return response;
|
|
251
332
|
}
|
|
252
333
|
|
|
334
|
+
/**
|
|
335
|
+
* @typedef {Object} TeamsGetMembershipRequestParams
|
|
336
|
+
* @property {string} teamId Team ID.
|
|
337
|
+
* @property {string} membershipId Membership ID.
|
|
338
|
+
* @property {boolean} parseOutput
|
|
339
|
+
* @property {libClient | undefined} sdk
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @param {TeamsGetMembershipRequestParams} params
|
|
344
|
+
*/
|
|
253
345
|
const teamsGetMembership = async ({ teamId, membershipId, parseOutput = true, sdk = undefined}) => {
|
|
254
|
-
/* @param {string} teamId */
|
|
255
|
-
/* @param {string} membershipId */
|
|
256
|
-
|
|
257
346
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
258
347
|
let apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
|
|
259
348
|
let payload = {};
|
|
349
|
+
|
|
260
350
|
let response = undefined;
|
|
351
|
+
|
|
261
352
|
response = await client.call('get', apiPath, {
|
|
262
353
|
'content-type': 'application/json',
|
|
263
354
|
}, payload);
|
|
264
|
-
|
|
355
|
+
|
|
265
356
|
if (parseOutput) {
|
|
266
357
|
parse(response)
|
|
267
358
|
success()
|
|
268
359
|
}
|
|
360
|
+
|
|
269
361
|
return response;
|
|
270
362
|
}
|
|
271
363
|
|
|
364
|
+
/**
|
|
365
|
+
* @typedef {Object} TeamsUpdateMembershipRequestParams
|
|
366
|
+
* @property {string} teamId Team ID.
|
|
367
|
+
* @property {string} membershipId Membership ID.
|
|
368
|
+
* @property {string[]} roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
|
369
|
+
* @property {boolean} parseOutput
|
|
370
|
+
* @property {libClient | undefined} sdk
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* @param {TeamsUpdateMembershipRequestParams} params
|
|
375
|
+
*/
|
|
272
376
|
const teamsUpdateMembership = async ({ teamId, membershipId, roles, parseOutput = true, sdk = undefined}) => {
|
|
273
|
-
/* @param {string} teamId */
|
|
274
|
-
/* @param {string} membershipId */
|
|
275
|
-
/* @param {string[]} roles */
|
|
276
|
-
|
|
277
377
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
278
378
|
let apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
|
|
279
379
|
let payload = {};
|
|
280
|
-
|
|
281
|
-
/** Body Params */
|
|
282
380
|
roles = roles === true ? [] : roles;
|
|
283
|
-
|
|
284
381
|
if (typeof roles !== 'undefined') {
|
|
285
382
|
payload['roles'] = roles;
|
|
286
383
|
}
|
|
287
384
|
|
|
288
385
|
let response = undefined;
|
|
386
|
+
|
|
289
387
|
response = await client.call('patch', apiPath, {
|
|
290
388
|
'content-type': 'application/json',
|
|
291
389
|
}, payload);
|
|
292
|
-
|
|
390
|
+
|
|
293
391
|
if (parseOutput) {
|
|
294
392
|
parse(response)
|
|
295
393
|
success()
|
|
296
394
|
}
|
|
395
|
+
|
|
297
396
|
return response;
|
|
298
397
|
}
|
|
299
398
|
|
|
399
|
+
/**
|
|
400
|
+
* @typedef {Object} TeamsDeleteMembershipRequestParams
|
|
401
|
+
* @property {string} teamId Team ID.
|
|
402
|
+
* @property {string} membershipId Membership ID.
|
|
403
|
+
* @property {boolean} parseOutput
|
|
404
|
+
* @property {libClient | undefined} sdk
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @param {TeamsDeleteMembershipRequestParams} params
|
|
409
|
+
*/
|
|
300
410
|
const teamsDeleteMembership = async ({ teamId, membershipId, parseOutput = true, sdk = undefined}) => {
|
|
301
|
-
/* @param {string} teamId */
|
|
302
|
-
/* @param {string} membershipId */
|
|
303
|
-
|
|
304
411
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
305
412
|
let apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
|
|
306
413
|
let payload = {};
|
|
414
|
+
|
|
307
415
|
let response = undefined;
|
|
416
|
+
|
|
308
417
|
response = await client.call('delete', apiPath, {
|
|
309
418
|
'content-type': 'application/json',
|
|
310
419
|
}, payload);
|
|
311
|
-
|
|
420
|
+
|
|
312
421
|
if (parseOutput) {
|
|
313
422
|
parse(response)
|
|
314
423
|
success()
|
|
315
424
|
}
|
|
425
|
+
|
|
316
426
|
return response;
|
|
317
427
|
}
|
|
318
428
|
|
|
429
|
+
/**
|
|
430
|
+
* @typedef {Object} TeamsUpdateMembershipStatusRequestParams
|
|
431
|
+
* @property {string} teamId Team ID.
|
|
432
|
+
* @property {string} membershipId Membership ID.
|
|
433
|
+
* @property {string} userId User ID.
|
|
434
|
+
* @property {string} secret Secret key.
|
|
435
|
+
* @property {boolean} parseOutput
|
|
436
|
+
* @property {libClient | undefined} sdk
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @param {TeamsUpdateMembershipStatusRequestParams} params
|
|
441
|
+
*/
|
|
319
442
|
const teamsUpdateMembershipStatus = async ({ teamId, membershipId, userId, secret, parseOutput = true, sdk = undefined}) => {
|
|
320
|
-
/* @param {string} teamId */
|
|
321
|
-
/* @param {string} membershipId */
|
|
322
|
-
/* @param {string} userId */
|
|
323
|
-
/* @param {string} secret */
|
|
324
|
-
|
|
325
443
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
326
444
|
let apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
|
|
327
445
|
let payload = {};
|
|
328
|
-
|
|
329
|
-
/** Body Params */
|
|
330
|
-
|
|
331
446
|
if (typeof userId !== 'undefined') {
|
|
332
447
|
payload['userId'] = userId;
|
|
333
448
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
449
|
if (typeof secret !== 'undefined') {
|
|
337
450
|
payload['secret'] = secret;
|
|
338
451
|
}
|
|
339
452
|
|
|
340
453
|
let response = undefined;
|
|
454
|
+
|
|
341
455
|
response = await client.call('patch', apiPath, {
|
|
342
456
|
'content-type': 'application/json',
|
|
343
457
|
}, payload);
|
|
344
|
-
|
|
458
|
+
|
|
345
459
|
if (parseOutput) {
|
|
346
460
|
parse(response)
|
|
347
461
|
success()
|
|
348
462
|
}
|
|
463
|
+
|
|
349
464
|
return response;
|
|
350
465
|
}
|
|
351
466
|
|
|
352
|
-
|
|
353
|
-
|
|
467
|
+
/**
|
|
468
|
+
* @typedef {Object} TeamsGetPrefsRequestParams
|
|
469
|
+
* @property {string} teamId Team ID.
|
|
470
|
+
* @property {boolean} parseOutput
|
|
471
|
+
* @property {libClient | undefined} sdk
|
|
472
|
+
*/
|
|
354
473
|
|
|
474
|
+
/**
|
|
475
|
+
* @param {TeamsGetPrefsRequestParams} params
|
|
476
|
+
*/
|
|
477
|
+
const teamsGetPrefs = async ({ teamId, parseOutput = true, sdk = undefined}) => {
|
|
355
478
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
356
479
|
let apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
|
|
357
480
|
let payload = {};
|
|
481
|
+
|
|
358
482
|
let response = undefined;
|
|
483
|
+
|
|
359
484
|
response = await client.call('get', apiPath, {
|
|
360
485
|
'content-type': 'application/json',
|
|
361
486
|
}, payload);
|
|
362
|
-
|
|
487
|
+
|
|
363
488
|
if (parseOutput) {
|
|
364
489
|
parse(response)
|
|
365
490
|
success()
|
|
366
491
|
}
|
|
492
|
+
|
|
367
493
|
return response;
|
|
368
494
|
}
|
|
369
495
|
|
|
496
|
+
/**
|
|
497
|
+
* @typedef {Object} TeamsUpdatePrefsRequestParams
|
|
498
|
+
* @property {string} teamId Team ID.
|
|
499
|
+
* @property {object} prefs Prefs key-value JSON object.
|
|
500
|
+
* @property {boolean} parseOutput
|
|
501
|
+
* @property {libClient | undefined} sdk
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @param {TeamsUpdatePrefsRequestParams} params
|
|
506
|
+
*/
|
|
370
507
|
const teamsUpdatePrefs = async ({ teamId, prefs, parseOutput = true, sdk = undefined}) => {
|
|
371
|
-
/* @param {string} teamId */
|
|
372
|
-
/* @param {object} prefs */
|
|
373
|
-
|
|
374
508
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
375
509
|
let apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
|
|
376
510
|
let payload = {};
|
|
377
|
-
|
|
378
|
-
/** Body Params */
|
|
379
511
|
if (typeof prefs !== 'undefined') {
|
|
380
512
|
payload['prefs'] = JSON.parse(prefs);
|
|
381
513
|
}
|
|
382
514
|
|
|
383
515
|
let response = undefined;
|
|
516
|
+
|
|
384
517
|
response = await client.call('put', apiPath, {
|
|
385
518
|
'content-type': 'application/json',
|
|
386
519
|
}, payload);
|
|
387
|
-
|
|
520
|
+
|
|
388
521
|
if (parseOutput) {
|
|
389
522
|
parse(response)
|
|
390
523
|
success()
|
|
391
524
|
}
|
|
525
|
+
|
|
392
526
|
return response;
|
|
393
527
|
}
|
|
394
528
|
|
|
395
|
-
|
|
396
529
|
teams
|
|
397
530
|
.command(`list`)
|
|
398
531
|
.description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.`)
|
|
@@ -498,7 +631,6 @@ teams
|
|
|
498
631
|
.requiredOption(`--prefs <prefs>`, `Prefs key-value JSON object.`)
|
|
499
632
|
.action(actionRunner(teamsUpdatePrefs))
|
|
500
633
|
|
|
501
|
-
|
|
502
634
|
module.exports = {
|
|
503
635
|
teams,
|
|
504
636
|
teamsList,
|
|
@@ -515,4 +647,4 @@ module.exports = {
|
|
|
515
647
|
teamsUpdateMembershipStatus,
|
|
516
648
|
teamsGetPrefs,
|
|
517
649
|
teamsUpdatePrefs
|
|
518
|
-
};
|
|
650
|
+
};
|