@api-client/core 0.10.2 → 0.10.3
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/build/cjs/src/amf/AmfMixin.js.map +1 -1
- package/build/cjs/src/amf/ApiSchemaValues.js.map +1 -1
- package/build/cjs/src/runtime/store/FilesSdk.js +11 -21
- package/build/cjs/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/cjs/src/runtime/store/RevisionsSdk.js +4 -1
- package/build/cjs/src/runtime/store/RevisionsSdk.js.map +1 -1
- package/build/cjs/src/runtime/store/RouteBuilder.d.ts +12 -17
- package/build/cjs/src/runtime/store/RouteBuilder.js +25 -40
- package/build/cjs/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/cjs/src/runtime/store/Sdk.d.ts +0 -5
- package/build/cjs/src/runtime/store/Sdk.js +0 -5
- package/build/cjs/src/runtime/store/Sdk.js.map +1 -1
- package/build/cjs/src/runtime/store/SharedSdk.js +1 -2
- package/build/cjs/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/cjs/src/runtime/store/TrashSdk.d.ts +4 -4
- package/build/cjs/src/runtime/store/TrashSdk.js +10 -11
- package/build/cjs/src/runtime/store/TrashSdk.js.map +1 -1
- package/build/cjs/src/testing/TestCliHelper.js.map +1 -1
- package/build/esm/src/amf/AmfMixin.js.map +1 -1
- package/build/esm/src/amf/ApiSchemaValues.js +2 -1
- package/build/esm/src/amf/ApiSchemaValues.js.map +1 -1
- package/build/esm/src/runtime/store/FilesSdk.js +11 -21
- package/build/esm/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/esm/src/runtime/store/RevisionsSdk.js +5 -2
- package/build/esm/src/runtime/store/RevisionsSdk.js.map +1 -1
- package/build/esm/src/runtime/store/RouteBuilder.d.ts +12 -17
- package/build/esm/src/runtime/store/RouteBuilder.js +25 -40
- package/build/esm/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/esm/src/runtime/store/Sdk.d.ts +0 -5
- package/build/esm/src/runtime/store/Sdk.js +0 -5
- package/build/esm/src/runtime/store/Sdk.js.map +1 -1
- package/build/esm/src/runtime/store/SharedSdk.js +1 -2
- package/build/esm/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/esm/src/runtime/store/TrashSdk.d.ts +4 -4
- package/build/esm/src/runtime/store/TrashSdk.js +10 -11
- package/build/esm/src/runtime/store/TrashSdk.js.map +1 -1
- package/build/esm/src/testing/TestCliHelper.js +2 -1
- package/build/esm/src/testing/TestCliHelper.js.map +1 -1
- package/package.json +3 -3
- package/src/amf/AmfMixin.ts +2 -2
- package/src/runtime/store/FilesSdk.ts +11 -21
- package/src/runtime/store/RevisionsSdk.ts +5 -2
- package/src/runtime/store/RouteBuilder.ts +25 -45
- package/src/runtime/store/Sdk.ts +0 -6
- package/src/runtime/store/SharedSdk.ts +1 -2
- package/src/runtime/store/TrashSdk.ts +10 -11
- package/build/cjs/src/runtime/store/CertificatesSdk.d.ts +0 -53
- package/build/cjs/src/runtime/store/CertificatesSdk.js +0 -238
- package/build/cjs/src/runtime/store/CertificatesSdk.js.map +0 -1
- package/build/esm/src/runtime/store/CertificatesSdk.d.ts +0 -53
- package/build/esm/src/runtime/store/CertificatesSdk.js +0 -234
- package/build/esm/src/runtime/store/CertificatesSdk.js.map +0 -1
- package/src/runtime/store/CertificatesSdk.ts +0 -238
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN } from './SdkBase.js';
|
|
2
|
-
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { SdkError } from './Errors.js';
|
|
4
|
-
export class CertificatesSdk extends SdkBase {
|
|
5
|
-
/**
|
|
6
|
-
* Inserts a certificate to the store
|
|
7
|
-
*
|
|
8
|
-
* @param value The value to insert.
|
|
9
|
-
* @param space The parent space of the certificate.
|
|
10
|
-
* @deprecated Use the `files` to store certificates.
|
|
11
|
-
*/
|
|
12
|
-
async add(value, space, request = {}) {
|
|
13
|
-
const token = request.token || this.sdk.token;
|
|
14
|
-
const url = this.sdk.getUrl(RouteBuilder.certificates());
|
|
15
|
-
url.searchParams.set('space', space);
|
|
16
|
-
const body = JSON.stringify(value);
|
|
17
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
18
|
-
this.inspectCommonStatusCodes(result);
|
|
19
|
-
const E_PREFIX = 'Unable to create a certificate. ';
|
|
20
|
-
if (result.status !== 200) {
|
|
21
|
-
this.logInvalidResponse(result);
|
|
22
|
-
let e = this.createGenericSdkError(result.body);
|
|
23
|
-
if (!e) {
|
|
24
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
25
|
-
e.response = result.body;
|
|
26
|
-
}
|
|
27
|
-
throw e;
|
|
28
|
-
}
|
|
29
|
-
if (!result.body) {
|
|
30
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
31
|
-
}
|
|
32
|
-
let data;
|
|
33
|
-
try {
|
|
34
|
-
data = JSON.parse(result.body);
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
38
|
-
}
|
|
39
|
-
if (!data.key) {
|
|
40
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
41
|
-
}
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Adds certificates in a bulk operation.
|
|
46
|
-
* @param value The lits of certificates to add.
|
|
47
|
-
* @param space The parent workspace
|
|
48
|
-
* @returns The list of inserted certificates. `undefined` when there was an error inserting a certificate.
|
|
49
|
-
* @deprecated Use the `files` to store certificates.
|
|
50
|
-
*/
|
|
51
|
-
async addBulk(values, space, request = {}) {
|
|
52
|
-
const token = request.token || this.sdk.token;
|
|
53
|
-
const url = this.sdk.getUrl(RouteBuilder.certificateBatchCreate());
|
|
54
|
-
url.searchParams.set('space', space);
|
|
55
|
-
const body = JSON.stringify(values);
|
|
56
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
57
|
-
this.inspectCommonStatusCodes(result);
|
|
58
|
-
const E_PREFIX = 'Unable to create a bulk certificates. ';
|
|
59
|
-
if (result.status !== 200) {
|
|
60
|
-
this.logInvalidResponse(result);
|
|
61
|
-
let e = this.createGenericSdkError(result.body);
|
|
62
|
-
if (!e) {
|
|
63
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
64
|
-
e.response = result.body;
|
|
65
|
-
}
|
|
66
|
-
throw e;
|
|
67
|
-
}
|
|
68
|
-
if (!result.body) {
|
|
69
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
70
|
-
}
|
|
71
|
-
let data;
|
|
72
|
-
try {
|
|
73
|
-
data = JSON.parse(result.body);
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
77
|
-
}
|
|
78
|
-
if (!data.items) {
|
|
79
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
80
|
-
}
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @param key The key of the certificate to read.
|
|
85
|
-
* @deprecated Use the `files` to store certificates.
|
|
86
|
-
*/
|
|
87
|
-
async read(key, request = {}) {
|
|
88
|
-
const token = request.token || this.sdk.token;
|
|
89
|
-
const url = this.sdk.getUrl(RouteBuilder.certificate(key));
|
|
90
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
91
|
-
this.inspectCommonStatusCodes(result);
|
|
92
|
-
const E_PREFIX = 'Unable to read a certificate. ';
|
|
93
|
-
if (result.status !== 200) {
|
|
94
|
-
this.logInvalidResponse(result);
|
|
95
|
-
let e = this.createGenericSdkError(result.body);
|
|
96
|
-
if (!e) {
|
|
97
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
98
|
-
e.response = result.body;
|
|
99
|
-
}
|
|
100
|
-
throw e;
|
|
101
|
-
}
|
|
102
|
-
if (!result.body) {
|
|
103
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
104
|
-
}
|
|
105
|
-
let data;
|
|
106
|
-
try {
|
|
107
|
-
data = JSON.parse(result.body);
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
111
|
-
}
|
|
112
|
-
if (!data.kind) {
|
|
113
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
114
|
-
}
|
|
115
|
-
return data;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Lists certificate entires.
|
|
119
|
-
*
|
|
120
|
-
* @param space The parent space of the certificate.
|
|
121
|
-
* @param options The list query options.
|
|
122
|
-
* @deprecated Use the `files` to store certificates.
|
|
123
|
-
*/
|
|
124
|
-
async list(options, request = {}) {
|
|
125
|
-
const token = request.token || this.sdk.token;
|
|
126
|
-
const url = this.sdk.getUrl(RouteBuilder.certificates());
|
|
127
|
-
this.sdk.appendListOptions(url, options);
|
|
128
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
129
|
-
this.inspectCommonStatusCodes(result);
|
|
130
|
-
const E_PREFIX = 'Unable to list certificates. ';
|
|
131
|
-
if (result.status !== 200) {
|
|
132
|
-
this.logInvalidResponse(result);
|
|
133
|
-
let e = this.createGenericSdkError(result.body);
|
|
134
|
-
if (!e) {
|
|
135
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
136
|
-
e.response = result.body;
|
|
137
|
-
}
|
|
138
|
-
throw e;
|
|
139
|
-
}
|
|
140
|
-
if (!result.body) {
|
|
141
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
142
|
-
}
|
|
143
|
-
let data;
|
|
144
|
-
try {
|
|
145
|
-
data = JSON.parse(result.body);
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
149
|
-
}
|
|
150
|
-
if (!Array.isArray(data.items)) {
|
|
151
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
152
|
-
}
|
|
153
|
-
return data;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Marks the certificate as deleted.
|
|
157
|
-
*
|
|
158
|
-
* @param key The key of the certificate to delete.
|
|
159
|
-
* @deprecated Use the `files` to store certificates.
|
|
160
|
-
*/
|
|
161
|
-
async delete(key, request = {}) {
|
|
162
|
-
const token = request.token || this.sdk.token;
|
|
163
|
-
const url = this.sdk.getUrl(RouteBuilder.certificate(key));
|
|
164
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
165
|
-
this.inspectCommonStatusCodes(result);
|
|
166
|
-
const E_PREFIX = 'Unable to delete the certificate. ';
|
|
167
|
-
if (result.status !== 204) {
|
|
168
|
-
this.logInvalidResponse(result);
|
|
169
|
-
let e = this.createGenericSdkError(result.body);
|
|
170
|
-
if (!e) {
|
|
171
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
172
|
-
e.response = result.body;
|
|
173
|
-
}
|
|
174
|
-
throw e;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Removed certificates in a bulk operation.
|
|
179
|
-
* @param keys The list of certificate keys to delete.
|
|
180
|
-
* @deprecated Use the `files` to store certificates.
|
|
181
|
-
*/
|
|
182
|
-
async deleteBulk(keys, request = {}) {
|
|
183
|
-
const token = request.token || this.sdk.token;
|
|
184
|
-
const url = this.sdk.getUrl(RouteBuilder.certificateBatchDelete());
|
|
185
|
-
const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) });
|
|
186
|
-
this.inspectCommonStatusCodes(result);
|
|
187
|
-
const E_PREFIX = 'Unable to delete history. ';
|
|
188
|
-
if (result.status !== 200) {
|
|
189
|
-
this.logInvalidResponse(result);
|
|
190
|
-
let e = this.createGenericSdkError(result.body);
|
|
191
|
-
if (!e) {
|
|
192
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
193
|
-
e.response = result.body;
|
|
194
|
-
}
|
|
195
|
-
throw e;
|
|
196
|
-
}
|
|
197
|
-
if (!result.body) {
|
|
198
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
199
|
-
}
|
|
200
|
-
let data;
|
|
201
|
-
try {
|
|
202
|
-
data = JSON.parse(result.body);
|
|
203
|
-
}
|
|
204
|
-
catch (e) {
|
|
205
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
206
|
-
}
|
|
207
|
-
if (!Array.isArray(data.items)) {
|
|
208
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
209
|
-
}
|
|
210
|
-
return data;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Removes all certificates from the store for the given workspace.
|
|
214
|
-
* @param space The parent workspace key
|
|
215
|
-
* @deprecated Use the `files` to store certificates.
|
|
216
|
-
*/
|
|
217
|
-
async empty(space, request = {}) {
|
|
218
|
-
const token = request.token || this.sdk.token;
|
|
219
|
-
const url = this.sdk.getUrl(RouteBuilder.certificatesEmpty(space));
|
|
220
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
221
|
-
this.inspectCommonStatusCodes(result);
|
|
222
|
-
const E_PREFIX = 'Unable to delete the certificate. ';
|
|
223
|
-
if (result.status !== 204) {
|
|
224
|
-
this.logInvalidResponse(result);
|
|
225
|
-
let e = this.createGenericSdkError(result.body);
|
|
226
|
-
if (!e) {
|
|
227
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
228
|
-
e.response = result.body;
|
|
229
|
-
}
|
|
230
|
-
throw e;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
//# sourceMappingURL=CertificatesSdk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CertificatesSdk.js","sourceRoot":"","sources":["../../../../../src/runtime/store/CertificatesSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC1C;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,KAAsB,EAAE,KAAa,EAAE,UAA8B,EAAE;QAC/E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QACzD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,kCAAkC,CAAC;QACpD,IAAI,MAAM,CAAC,MAAM,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G,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACnF,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;aAC1B;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF"}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
|
-
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { ContextChangeRecord, ContextDeleteRecord, ContextListResult, ContextSpaceListOptions, IBulkOperationResult } from '../../events/BaseEvents.js';
|
|
4
|
-
import { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
5
|
-
import { SdkError } from './Errors.js';
|
|
6
|
-
|
|
7
|
-
export class CertificatesSdk extends SdkBase {
|
|
8
|
-
/**
|
|
9
|
-
* Inserts a certificate to the store
|
|
10
|
-
*
|
|
11
|
-
* @param value The value to insert.
|
|
12
|
-
* @param space The parent space of the certificate.
|
|
13
|
-
* @deprecated Use the `files` to store certificates.
|
|
14
|
-
*/
|
|
15
|
-
async add(value: HttpCertificate, space: string, request: ISdkRequestOptions = {}): Promise<ContextChangeRecord<HttpCertificate>> {
|
|
16
|
-
const token = request.token || this.sdk.token;
|
|
17
|
-
const url = this.sdk.getUrl(RouteBuilder.certificates());
|
|
18
|
-
url.searchParams.set('space', space);
|
|
19
|
-
const body = JSON.stringify(value);
|
|
20
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
21
|
-
this.inspectCommonStatusCodes(result);
|
|
22
|
-
const E_PREFIX = 'Unable to create a certificate. ';
|
|
23
|
-
if (result.status !== 200) {
|
|
24
|
-
this.logInvalidResponse(result);
|
|
25
|
-
let e = this.createGenericSdkError(result.body)
|
|
26
|
-
if (!e) {
|
|
27
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
28
|
-
e.response = result.body;
|
|
29
|
-
}
|
|
30
|
-
throw e;
|
|
31
|
-
}
|
|
32
|
-
if (!result.body) {
|
|
33
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
34
|
-
}
|
|
35
|
-
let data: ContextChangeRecord<HttpCertificate>;
|
|
36
|
-
try {
|
|
37
|
-
data = JSON.parse(result.body);
|
|
38
|
-
} catch (e) {
|
|
39
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
40
|
-
}
|
|
41
|
-
if (!data.key) {
|
|
42
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
43
|
-
}
|
|
44
|
-
return data;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Adds certificates in a bulk operation.
|
|
49
|
-
* @param value The lits of certificates to add.
|
|
50
|
-
* @param space The parent workspace
|
|
51
|
-
* @returns The list of inserted certificates. `undefined` when there was an error inserting a certificate.
|
|
52
|
-
* @deprecated Use the `files` to store certificates.
|
|
53
|
-
*/
|
|
54
|
-
async addBulk(values: HttpCertificate[], space: string, request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextChangeRecord<HttpCertificate>>> {
|
|
55
|
-
const token = request.token || this.sdk.token;
|
|
56
|
-
const url = this.sdk.getUrl(RouteBuilder.certificateBatchCreate());
|
|
57
|
-
url.searchParams.set('space', space);
|
|
58
|
-
const body = JSON.stringify(values);
|
|
59
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
60
|
-
this.inspectCommonStatusCodes(result);
|
|
61
|
-
const E_PREFIX = 'Unable to create a bulk certificates. ';
|
|
62
|
-
if (result.status !== 200) {
|
|
63
|
-
this.logInvalidResponse(result);
|
|
64
|
-
let e = this.createGenericSdkError(result.body)
|
|
65
|
-
if (!e) {
|
|
66
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
67
|
-
e.response = result.body;
|
|
68
|
-
}
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
71
|
-
if (!result.body) {
|
|
72
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
73
|
-
}
|
|
74
|
-
let data: IBulkOperationResult<ContextChangeRecord<HttpCertificate>>;
|
|
75
|
-
try {
|
|
76
|
-
data = JSON.parse(result.body);
|
|
77
|
-
} catch (e) {
|
|
78
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
79
|
-
}
|
|
80
|
-
if (!data.items) {
|
|
81
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
82
|
-
}
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @param key The key of the certificate to read.
|
|
88
|
-
* @deprecated Use the `files` to store certificates.
|
|
89
|
-
*/
|
|
90
|
-
async read(key: string, request: ISdkRequestOptions = {}): Promise<HttpCertificate> {
|
|
91
|
-
const token = request.token || this.sdk.token;
|
|
92
|
-
const url = this.sdk.getUrl(RouteBuilder.certificate(key));
|
|
93
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
94
|
-
this.inspectCommonStatusCodes(result);
|
|
95
|
-
const E_PREFIX = 'Unable to read a certificate. ';
|
|
96
|
-
if (result.status !== 200) {
|
|
97
|
-
this.logInvalidResponse(result);
|
|
98
|
-
let e = this.createGenericSdkError(result.body)
|
|
99
|
-
if (!e) {
|
|
100
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
101
|
-
e.response = result.body;
|
|
102
|
-
}
|
|
103
|
-
throw e;
|
|
104
|
-
}
|
|
105
|
-
if (!result.body) {
|
|
106
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
107
|
-
}
|
|
108
|
-
let data: HttpCertificate;
|
|
109
|
-
try {
|
|
110
|
-
data = JSON.parse(result.body);
|
|
111
|
-
} catch (e) {
|
|
112
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
113
|
-
}
|
|
114
|
-
if (!data.kind) {
|
|
115
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
116
|
-
}
|
|
117
|
-
return data;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Lists certificate entires.
|
|
122
|
-
*
|
|
123
|
-
* @param space The parent space of the certificate.
|
|
124
|
-
* @param options The list query options.
|
|
125
|
-
* @deprecated Use the `files` to store certificates.
|
|
126
|
-
*/
|
|
127
|
-
async list(options?: ContextSpaceListOptions, request: ISdkRequestOptions = {}): Promise<ContextListResult<HttpCertificate>> {
|
|
128
|
-
const token = request.token || this.sdk.token;
|
|
129
|
-
const url = this.sdk.getUrl(RouteBuilder.certificates());
|
|
130
|
-
this.sdk.appendListOptions(url, options);
|
|
131
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
132
|
-
this.inspectCommonStatusCodes(result);
|
|
133
|
-
const E_PREFIX = 'Unable to list certificates. ';
|
|
134
|
-
if (result.status !== 200) {
|
|
135
|
-
this.logInvalidResponse(result);
|
|
136
|
-
let e = this.createGenericSdkError(result.body)
|
|
137
|
-
if (!e) {
|
|
138
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
139
|
-
e.response = result.body;
|
|
140
|
-
}
|
|
141
|
-
throw e;
|
|
142
|
-
}
|
|
143
|
-
if (!result.body) {
|
|
144
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
145
|
-
}
|
|
146
|
-
let data: ContextListResult<HttpCertificate>;
|
|
147
|
-
try {
|
|
148
|
-
data = JSON.parse(result.body);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
151
|
-
}
|
|
152
|
-
if (!Array.isArray(data.items)) {
|
|
153
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
154
|
-
}
|
|
155
|
-
return data;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Marks the certificate as deleted.
|
|
160
|
-
*
|
|
161
|
-
* @param key The key of the certificate to delete.
|
|
162
|
-
* @deprecated Use the `files` to store certificates.
|
|
163
|
-
*/
|
|
164
|
-
async delete(key: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
165
|
-
const token = request.token || this.sdk.token;
|
|
166
|
-
const url = this.sdk.getUrl(RouteBuilder.certificate(key));
|
|
167
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
168
|
-
this.inspectCommonStatusCodes(result);
|
|
169
|
-
const E_PREFIX = 'Unable to delete the certificate. ';
|
|
170
|
-
if (result.status !== 204) {
|
|
171
|
-
this.logInvalidResponse(result);
|
|
172
|
-
let e = this.createGenericSdkError(result.body)
|
|
173
|
-
if (!e) {
|
|
174
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
175
|
-
e.response = result.body;
|
|
176
|
-
}
|
|
177
|
-
throw e;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Removed certificates in a bulk operation.
|
|
183
|
-
* @param keys The list of certificate keys to delete.
|
|
184
|
-
* @deprecated Use the `files` to store certificates.
|
|
185
|
-
*/
|
|
186
|
-
async deleteBulk(keys: string[], request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {
|
|
187
|
-
const token = request.token || this.sdk.token;
|
|
188
|
-
const url = this.sdk.getUrl(RouteBuilder.certificateBatchDelete());
|
|
189
|
-
const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) });
|
|
190
|
-
this.inspectCommonStatusCodes(result);
|
|
191
|
-
const E_PREFIX = 'Unable to delete history. ';
|
|
192
|
-
if (result.status !== 200) {
|
|
193
|
-
this.logInvalidResponse(result);
|
|
194
|
-
let e = this.createGenericSdkError(result.body)
|
|
195
|
-
if (!e) {
|
|
196
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
197
|
-
e.response = result.body;
|
|
198
|
-
}
|
|
199
|
-
throw e;
|
|
200
|
-
}
|
|
201
|
-
if (!result.body) {
|
|
202
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
let data: IBulkOperationResult<ContextDeleteRecord>;
|
|
206
|
-
try {
|
|
207
|
-
data = JSON.parse(result.body);
|
|
208
|
-
} catch (e) {
|
|
209
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
210
|
-
}
|
|
211
|
-
if (!Array.isArray(data.items)) {
|
|
212
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
213
|
-
}
|
|
214
|
-
return data;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Removes all certificates from the store for the given workspace.
|
|
219
|
-
* @param space The parent workspace key
|
|
220
|
-
* @deprecated Use the `files` to store certificates.
|
|
221
|
-
*/
|
|
222
|
-
async empty(space: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
223
|
-
const token = request.token || this.sdk.token;
|
|
224
|
-
const url = this.sdk.getUrl(RouteBuilder.certificatesEmpty(space));
|
|
225
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
226
|
-
this.inspectCommonStatusCodes(result);
|
|
227
|
-
const E_PREFIX = 'Unable to delete the certificate. ';
|
|
228
|
-
if (result.status !== 204) {
|
|
229
|
-
this.logInvalidResponse(result);
|
|
230
|
-
let e = this.createGenericSdkError(result.body)
|
|
231
|
-
if (!e) {
|
|
232
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
233
|
-
e.response = result.body;
|
|
234
|
-
}
|
|
235
|
-
throw e;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|