/
services.ts
3629 lines (3359 loc) · 108 KB
/
services.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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated for API Clients. DO NOT EDIT.
import { Wretcher } from 'wretch';
import * as datatypes from './datatypes';
import * as util from './util';
/**
* Abuse Reports allow you to submit take-down requests for URLs hosted by
ngrok that violate ngrok's terms of service.
*/
export class AbuseReports {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>abuseReports</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Creates a new abuse report which will be reviewed by our system and abuse response team. This API is only available to authorized accounts. Contact abuse@ngrok.com to request access
*/
public create(
arg: datatypes.AbuseReportCreate
): Promise<datatypes.AbuseReport> {
return this.httpClient
.url(`/abuse_reports`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get the detailed status of abuse report by ID.
*/
public get(id): Promise<datatypes.AbuseReport> {
return this.httpClient
.url(`/abuse_reports/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
export class AgentIngresses {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>agentIngresses</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Create a new Agent Ingress. The ngrok agent can be configured to connect to ngrok via the new set of addresses on the returned Agent Ingress.
*/
public create(
arg: datatypes.AgentIngressCreate
): Promise<datatypes.AgentIngress> {
return this.httpClient
.url(`/agent_ingresses`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete an Agent Ingress by ID
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/agent_ingresses/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get the details of an Agent Ingress by ID.
*/
public get(id): Promise<datatypes.AgentIngress> {
return this.httpClient
.url(`/agent_ingresses/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all Agent Ingresses owned by this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.AgentIngress>> {
const array: Array<datatypes.AgentIngress> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.AgentIngressList> {
return this.httpClient
.url(`/agent_ingresses`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.AgentIngress[] = pagedList.ingresses;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Update attributes of an Agent Ingress by ID.
*/
public update(
arg: datatypes.AgentIngressUpdate
): Promise<datatypes.AgentIngress> {
return this.httpClient
.url(`/agent_ingresses/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
/**
* API Keys are used to authenticate to the [ngrok
API](https://ngrok.com/docs/api#authentication). You may use the API itself
to provision and manage API Keys but you'll need to provision your first API
key from the [API Keys page](https://dashboard.ngrok.com/api/keys) on your
ngrok.com dashboard.
*/
export class APIKeys {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>apiKeys</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Create a new API key. The generated API key can be used to authenticate to the ngrok API.
*/
public create(arg: datatypes.APIKeyCreate): Promise<datatypes.APIKey> {
return this.httpClient
.url(`/api_keys`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete an API key by ID
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/api_keys/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get the details of an API key by ID.
*/
public get(id): Promise<datatypes.APIKey> {
return this.httpClient
.url(`/api_keys/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all API keys owned by this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.APIKey>> {
const array: Array<datatypes.APIKey> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(arg: datatypes.Paging): Promise<datatypes.APIKeyList> {
return this.httpClient
.url(`/api_keys`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.APIKey[] = pagedList.keys;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Update attributes of an API key by ID.
*/
public update(arg: datatypes.APIKeyUpdate): Promise<datatypes.APIKey> {
return this.httpClient
.url(`/api_keys/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
export class ApplicationSessions {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>applicationSessions</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Get an application session by ID.
*/
public get(id): Promise<datatypes.ApplicationSession> {
return this.httpClient
.url(`/app/sessions/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete an application session by ID.
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/app/sessions/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all application sessions for this account.
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.ApplicationSession>> {
const array: Array<datatypes.ApplicationSession> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.ApplicationSessionList> {
return this.httpClient
.url(`/app/sessions`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.ApplicationSession[] =
pagedList.applicationSessions;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
}
export class ApplicationUsers {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>applicationUsers</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Get an application user by ID.
*/
public get(id): Promise<datatypes.ApplicationUser> {
return this.httpClient
.url(`/app/users/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete an application user by ID.
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/app/users/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all application users for this account.
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.ApplicationUser>> {
const array: Array<datatypes.ApplicationUser> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.ApplicationUserList> {
return this.httpClient
.url(`/app/users`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.ApplicationUser[] = pagedList.applicationUsers;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
}
/**
* Tunnel Sessions represent instances of ngrok agents or SSH reverse tunnel
sessions that are running and connected to the ngrok service. Each tunnel
session can include one or more Tunnels.
*/
export class TunnelSessions {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>tunnelSessions</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* List all online tunnel sessions running on this account.
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.TunnelSession>> {
const array: Array<datatypes.TunnelSession> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.TunnelSessionList> {
return this.httpClient
.url(`/tunnel_sessions`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.TunnelSession[] = pagedList.tunnelSessions;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Get the detailed status of a tunnel session by ID
*/
public get(id): Promise<datatypes.TunnelSession> {
return this.httpClient
.url(`/tunnel_sessions/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Issues a command instructing the ngrok agent to restart. The agent restarts itself by calling exec() on platforms that support it. This operation is notably not supported on Windows. When an agent restarts, it reconnects with a new tunnel session ID.
*/
public restart(id): Promise<void> {
return this.httpClient
.url(`/tunnel_sessions/${id}/restart`)
.post(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Issues a command instructing the ngrok agent that started this tunnel session to exit.
*/
public stop(id): Promise<void> {
return this.httpClient
.url(`/tunnel_sessions/${id}/stop`)
.post(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Issues a command instructing the ngrok agent to update itself to the latest version. After this call completes successfully, the ngrok agent will be in the update process. A caller should wait some amount of time to allow the update to complete (at least 10 seconds) before making a call to the Restart endpoint to request that the agent restart itself to start using the new code. This call will never update an ngrok agent to a new major version which could cause breaking compatibility issues. If you wish to update to a new major version, that must be done manually. Still, please be aware that updating your ngrok agent could break your integration. This call will fail in any of the following circumstances: there is no update available the ngrok agent's configuration disabled update checks the agent is currently in process of updating the agent has already successfully updated but has not yet been restarted
*/
public update(arg: datatypes.TunnelSessionsUpdate): Promise<void> {
return this.httpClient
.url(`/tunnel_sessions/${arg.id}/update`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
/**
* A Failover backend defines failover behavior within a list of referenced
backends. Traffic is sent to the first backend in the list. If that backend
is offline or no connection can be established, ngrok attempts to connect to
the next backend in the list until one is successful.
*/
export class FailoverBackends {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>failoverBackends</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Create a new Failover backend
*/
public create(
arg: datatypes.FailoverBackendCreate
): Promise<datatypes.FailoverBackend> {
return this.httpClient
.url(`/backends/failover`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete a Failover backend by ID.
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/backends/failover/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get detailed information about a Failover backend by ID
*/
public get(id): Promise<datatypes.FailoverBackend> {
return this.httpClient
.url(`/backends/failover/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all Failover backends on this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.FailoverBackend>> {
const array: Array<datatypes.FailoverBackend> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.FailoverBackendList> {
return this.httpClient
.url(`/backends/failover`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.FailoverBackend[] = pagedList.backends;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Update Failover backend by ID
*/
public update(
arg: datatypes.FailoverBackendUpdate
): Promise<datatypes.FailoverBackend> {
return this.httpClient
.url(`/backends/failover/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
export class HTTPResponseBackends {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>httpResponseBackends</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
public create(
arg: datatypes.HTTPResponseBackendCreate
): Promise<datatypes.HTTPResponseBackend> {
return this.httpClient
.url(`/backends/http_response`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
public delete(id): Promise<void> {
return this.httpClient
.url(`/backends/http_response/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
public get(id): Promise<datatypes.HTTPResponseBackend> {
return this.httpClient
.url(`/backends/http_response/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.HTTPResponseBackend>> {
const array: Array<datatypes.HTTPResponseBackend> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.HTTPResponseBackendList> {
return this.httpClient
.url(`/backends/http_response`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.HTTPResponseBackend[] = pagedList.backends;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
public update(
arg: datatypes.HTTPResponseBackendUpdate
): Promise<datatypes.HTTPResponseBackend> {
return this.httpClient
.url(`/backends/http_response/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
/**
* A Tunnel Group Backend balances traffic among all online tunnels that match
a label selector.
*/
export class TunnelGroupBackends {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>tunnelGroupBackends</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Create a new TunnelGroup backend
*/
public create(
arg: datatypes.TunnelGroupBackendCreate
): Promise<datatypes.TunnelGroupBackend> {
return this.httpClient
.url(`/backends/tunnel_group`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete a TunnelGroup backend by ID.
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/backends/tunnel_group/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get detailed information about a TunnelGroup backend by ID
*/
public get(id): Promise<datatypes.TunnelGroupBackend> {
return this.httpClient
.url(`/backends/tunnel_group/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all TunnelGroup backends on this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.TunnelGroupBackend>> {
const array: Array<datatypes.TunnelGroupBackend> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.TunnelGroupBackendList> {
return this.httpClient
.url(`/backends/tunnel_group`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.TunnelGroupBackend[] = pagedList.backends;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Update TunnelGroup backend by ID
*/
public update(
arg: datatypes.TunnelGroupBackendUpdate
): Promise<datatypes.TunnelGroupBackend> {
return this.httpClient
.url(`/backends/tunnel_group/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
/**
* A Weighted Backend balances traffic among the referenced backends. Traffic
is assigned proportionally to each based on its weight. The percentage of
traffic is calculated by dividing a backend's weight by the sum of all
weights.
*/
export class WeightedBackends {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>weightedBackends</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Create a new Weighted backend
*/
public create(
arg: datatypes.WeightedBackendCreate
): Promise<datatypes.WeightedBackend> {
return this.httpClient
.url(`/backends/weighted`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete a Weighted backend by ID.
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/backends/weighted/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get detailed information about a Weighted backend by ID
*/
public get(id): Promise<datatypes.WeightedBackend> {
return this.httpClient
.url(`/backends/weighted/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all Weighted backends on this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.WeightedBackend>> {
const array: Array<datatypes.WeightedBackend> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.WeightedBackendList> {
return this.httpClient
.url(`/backends/weighted`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };
if (beforeId) {
page.beforeId = beforeId;
}
while (nextPage) {
const pagedList = await this._pagedList(page);
nextPage = pagedList.nextPageUri;
const items: datatypes.WeightedBackend[] = pagedList.backends;
if (nextPage) {
page = {
beforeId: items[items.length - 1].id,
limit: limit,
};
}
for (const item of items) {
yield item;
}
}
}
/**
* Update Weighted backend by ID
*/
public update(
arg: datatypes.WeightedBackendUpdate
): Promise<datatypes.WeightedBackend> {
return this.httpClient
.url(`/backends/weighted/${arg.id}`)
.patch(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
}
/**
* Certificate Authorities are x509 certificates that are used to sign other
x509 certificates. Attach a Certificate Authority to the Mutual TLS module
to verify that the TLS certificate presented by a client has been signed by
this CA. Certificate Authorities are used only for mTLS validation only and
thus a private key is not included in the resource.
*/
export class CertificateAuthorities {
private httpClient: Wretcher;
/** Do not construct this object directly, use the <code>certificateAuthorities</code> property of an <code>Ngrok</code> client object instead. */
public constructor(httpClient: Wretcher) {
this.httpClient = httpClient;
}
/**
* Upload a new Certificate Authority
*/
public create(
arg: datatypes.CertificateAuthorityCreate
): Promise<datatypes.CertificateAuthority> {
return this.httpClient
.url(`/certificate_authorities`)
.post(util.serializeArgument(arg))
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Delete a Certificate Authority
*/
public delete(id): Promise<void> {
return this.httpClient
.url(`/certificate_authorities/${id}`)
.delete(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* Get detailed information about a certficate authority
*/
public get(id): Promise<datatypes.CertificateAuthority> {
return this.httpClient
.url(`/certificate_authorities/${id}`)
.get(id)
.json(payload => util.deserializeResult(payload))
.then(f => f, util.onRejected);
}
/**
* List all Certificate Authority on this account
*/
public async list(
beforeId?: string,
limit?: string
): Promise<Array<datatypes.CertificateAuthority>> {
const array: Array<datatypes.CertificateAuthority> = [];
for await (const item of this._asyncList(beforeId, limit)) {
array.push(item);
}
return array;
}
private _pagedList(
arg: datatypes.Paging
): Promise<datatypes.CertificateAuthorityList> {
return this.httpClient
.url(`/certificate_authorities`)
.query(arg)
.get()
.json(payload => util.deserializeResult(payload))
.then(util.onFulfilled, util.onRejected);
}
private async *_asyncList(beforeId: string, limit = '100') {
let nextPage = 'initial loop';
let page: datatypes.Paging = { limit: limit };