-
Notifications
You must be signed in to change notification settings - Fork 7
/
CloudV2.ts
597 lines (508 loc) · 13.2 KB
/
CloudV2.ts
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/**
Juju Cloud version 2.
This facade is available on:
Controllers
NOTE: This file was generated using the Juju schema
from Juju 2.9-rc3 at the git SHA cb361902f8.
Do not manually edit this file.
*/
import type { JujuRequest } from "../../../generator/interfaces.js";
import { ConnectionInfo, Transport } from "../../client.js";
import { Facade } from "../../types.js";
import { autoBind } from "../../utils.js";
export interface AddCloudArgs {
cloud: Cloud;
force?: boolean;
name: string;
}
export interface Cloud {
"auth-types"?: string[];
"ca-certificates"?: string[];
config?: AdditionalProperties;
endpoint?: string;
"host-cloud-region"?: string;
"identity-endpoint"?: string;
"region-config"?: AdditionalProperties;
regions?: CloudRegion[];
"storage-endpoint"?: string;
type: string;
}
export interface CloudCredential {
attrs?: Record<string, string>;
"auth-type": string;
redacted?: string[];
}
export interface CloudCredentialArg {
"cloud-name": string;
"credential-name": string;
}
export interface CloudCredentialArgs {
credentials?: CloudCredentialArg[];
"include-secrets": boolean;
}
export interface CloudCredentialResult {
error?: Error;
result?: CloudCredential;
}
export interface CloudCredentialResults {
results?: CloudCredentialResult[];
}
export interface CloudDetails {
"auth-types"?: string[];
endpoint?: string;
"identity-endpoint"?: string;
regions?: CloudRegion[];
"storage-endpoint"?: string;
type: string;
}
export interface CloudInfo {
CloudDetails: CloudDetails;
users: CloudUserInfo[];
}
export interface CloudInfoResult {
error?: Error;
result?: CloudInfo;
}
export interface CloudInfoResults {
results: CloudInfoResult[];
}
export interface CloudInstanceTypesConstraint {
"cloud-tag": string;
constraints?: Value;
region: string;
}
export interface CloudInstanceTypesConstraints {
constraints: CloudInstanceTypesConstraint[];
}
export interface CloudRegion {
endpoint?: string;
"identity-endpoint"?: string;
name: string;
"storage-endpoint"?: string;
}
export interface CloudResult {
cloud?: Cloud;
error?: Error;
}
export interface CloudResults {
results?: CloudResult[];
}
export interface CloudUserInfo {
access: string;
"display-name": string;
user: string;
}
export interface CloudsResult {
clouds?: Record<string, Cloud>;
}
export interface ControllerCredentialInfo {
content?: CredentialContent;
models?: ModelAccess[];
}
export interface CredentialContent {
attrs?: Record<string, string>;
"auth-type": string;
cloud: string;
name: string;
valid?: boolean;
}
export interface CredentialContentResult {
error?: Error;
result?: ControllerCredentialInfo;
}
export interface CredentialContentResults {
results?: CredentialContentResult[];
}
export interface Entities {
entities: Entity[];
}
export interface Entity {
tag: string;
}
export interface Error {
code: string;
info?: AdditionalProperties;
message: string;
}
export interface ErrorResult {
error?: Error;
}
export interface ErrorResults {
results: ErrorResult[];
}
export interface InstanceType {
arches: string[];
cost?: number;
"cpu-cores": number;
deprecated?: boolean;
memory: number;
name?: string;
"root-disk"?: number;
"virt-type"?: string;
}
export interface InstanceTypesResult {
"cost-currency"?: string;
"cost-divisor"?: number;
"cost-unit"?: string;
error?: Error;
"instance-types"?: InstanceType[];
}
export interface InstanceTypesResults {
results: InstanceTypesResult[];
}
export interface ListCloudInfo {
CloudDetails: CloudDetails;
"user-access": string;
}
export interface ListCloudInfoResult {
error?: Error;
result?: ListCloudInfo;
}
export interface ListCloudInfoResults {
results: ListCloudInfoResult[];
}
export interface ListCloudsRequest {
all?: boolean;
"user-tag": string;
}
export interface ModelAccess {
access?: string;
model?: string;
}
export interface ModifyCloudAccess {
access: string;
action: string;
"cloud-tag": string;
"user-tag": string;
}
export interface ModifyCloudAccessRequest {
changes: ModifyCloudAccess[];
}
export interface StringResult {
error?: Error;
result: string;
}
export interface StringsResult {
error?: Error;
result?: string[];
}
export interface StringsResults {
results: StringsResult[];
}
export interface TaggedCredential {
credential: CloudCredential;
tag: string;
}
export interface TaggedCredentials {
credentials?: TaggedCredential[];
}
export interface UpdateCredentialArgs {
credentials: TaggedCredential[];
force: boolean;
}
export interface UpdateCredentialModelResult {
errors?: ErrorResult[];
name: string;
uuid: string;
}
export interface UpdateCredentialResult {
error?: Error;
models?: UpdateCredentialModelResult[];
tag: string;
}
export interface UpdateCredentialResults {
results?: UpdateCredentialResult[];
}
export interface UserCloud {
"cloud-tag": string;
"user-tag": string;
}
export interface UserClouds {
"user-clouds"?: UserCloud[];
}
export interface Value {
"allocate-public-ip"?: boolean;
arch?: string;
container?: string;
cores?: number;
"cpu-power"?: number;
"instance-type"?: string;
mem?: number;
"root-disk"?: number;
"root-disk-source"?: string;
spaces?: string[];
tags?: string[];
"virt-type"?: string;
zones?: string[];
}
export interface AdditionalProperties {
[key: string]: any;
}
/**
CloudAPIV2 provides a way to wrap the different calls
between version 2 and version 3 of the cloud API.
*/
class CloudV2 implements Facade {
static NAME = "Cloud";
static VERSION = 2;
NAME = "Cloud";
VERSION = 2;
_transport: Transport;
_info: ConnectionInfo;
constructor(transport: Transport, info: ConnectionInfo) {
this._transport = transport;
this._info = info;
// Automatically bind all methods to instances.
autoBind(this);
}
/**
AddCloud adds a new cloud, different from the one managed by the controller.
*/
addCloud(params: AddCloudArgs): Promise<any> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "AddCloud",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
AddCredentials adds new credentials.
In contrast to UpdateCredentials() below, the new credentials can be
for a cloud that the controller does not manage (this is required
for CAAS models)
*/
addCredentials(params: TaggedCredentials): Promise<ErrorResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "AddCredentials",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
Cloud returns the cloud definitions for the specified clouds.
*/
cloud(params: Entities): Promise<CloudResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "Cloud",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
CloudInfo returns information about the specified clouds.
*/
cloudInfo(params: Entities): Promise<CloudInfoResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "CloudInfo",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
Clouds returns the definitions of all clouds supported by the controller
that the logged in user can see.
*/
clouds(params: any): Promise<CloudsResult> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "Clouds",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
Credential returns the specified cloud credential for each tag, minus secrets.
*/
credential(params: Entities): Promise<CloudCredentialResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "Credential",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
CredentialContents returns the specified cloud credentials,
including the secrets if requested.
If no specific credential name/cloud was passed in, all credentials for this user
are returned.
Only credential owner can see its contents as well as what models use it.
Controller admin has no special superpowers here and is treated the same as all other users.
*/
credentialContents(
params: CloudCredentialArgs
): Promise<CredentialContentResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "CredentialContents",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
DefaultCloud returns the tag of the cloud that models will be
created in by default.
*/
defaultCloud(params: any): Promise<StringResult> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "DefaultCloud",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
InstanceTypes returns instance type information for the cloud and region
in which the current model is deployed.
*/
instanceTypes(
params: CloudInstanceTypesConstraints
): Promise<InstanceTypesResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "InstanceTypes",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
ListCloudInfo returns clouds that the specified user has access to.
Controller admins (superuser) can list clouds for any user.
Other users can only ask about their own clouds.
*/
listCloudInfo(params: ListCloudsRequest): Promise<ListCloudInfoResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "ListCloudInfo",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
ModifyCloudAccess changes the model access granted to users.
*/
modifyCloudAccess(params: ModifyCloudAccessRequest): Promise<ErrorResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "ModifyCloudAccess",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
RemoveClouds removes the specified clouds from the controller.
If a cloud is in use (has models deployed to it), the removal will fail.
*/
removeClouds(params: Entities): Promise<ErrorResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "RemoveClouds",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
UpdateCredentials updates a set of cloud credentials' content.
*/
revokeCredentials(params: Entities): Promise<ErrorResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "RevokeCredentials",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
UpdateCredentials updates a set of cloud credentials' content.
*/
updateCredentials(params: TaggedCredentials): Promise<ErrorResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "UpdateCredentials",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
UpdateCredentialsCheckModels updates a set of cloud credentials' content.
If there are any models that are using a credential and these models
are not going to be visible with updated credential content,
there will be detailed validation errors per model.
Controller admins can 'force' an update of the credential
regardless of whether it is deemed valid or not.
*/
updateCredentialsCheckModels(
params: UpdateCredentialArgs
): Promise<UpdateCredentialResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "UpdateCredentialsCheckModels",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
/**
UserCredentials returns the cloud credentials for a set of users.
*/
userCredentials(params: UserClouds): Promise<StringsResults> {
return new Promise((resolve, reject) => {
const req: JujuRequest = {
type: "Cloud",
request: "UserCredentials",
version: 2,
params: params,
};
this._transport.write(req, resolve, reject);
});
}
}
export default CloudV2;