@geek-fun/serverlessinsight 0.6.15 → 0.7.1
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/AGENTS.md +405 -10
- package/README.md +59 -1
- package/README.zh-CN.md +3 -1
- package/dist/package.json +42 -34
- package/dist/src/commands/deploy.js +4 -0
- package/dist/src/commands/destroy.js +4 -0
- package/dist/src/common/aliyunClient/apigwOperations.js +9 -4
- package/dist/src/common/aliyunClient/cdnOperations.js +191 -0
- package/dist/src/common/aliyunClient/ecsOperations.js +2 -2
- package/dist/src/common/aliyunClient/fc3Operations.js +1 -1
- package/dist/src/common/aliyunClient/index.js +8 -0
- package/dist/src/common/aliyunClient/ossOperations.js +62 -2
- package/dist/src/common/aliyunClient/ramOperations.js +1 -1
- package/dist/src/common/credentials.js +12 -0
- package/dist/src/common/hashUtils.js +4 -0
- package/dist/src/common/iacHelper.js +5 -0
- package/dist/src/common/lockManager.js +8 -0
- package/dist/src/common/planFormatter.js +4 -0
- package/dist/src/common/providerEnum.js +1 -0
- package/dist/src/common/retryUtils.js +1 -1
- package/dist/src/common/runtimeMapper.js +24 -3
- package/dist/src/common/stateManager.js +10 -0
- package/dist/src/common/volcengineClient/apigwOperations.js +271 -0
- package/dist/src/common/volcengineClient/iamOperations.js +349 -0
- package/dist/src/common/volcengineClient/index.js +99 -0
- package/dist/src/common/volcengineClient/tlsOperations.js +256 -0
- package/dist/src/common/volcengineClient/tosOperations.js +440 -0
- package/dist/src/common/volcengineClient/types.js +26 -0
- package/dist/src/common/volcengineClient/vefaasOperations.js +386 -0
- package/dist/src/lang/en.js +135 -0
- package/dist/src/lang/zh-CN.js +134 -0
- package/dist/src/parser/bucketParser.js +111 -46
- package/dist/src/stack/aliyunStack/apigwResource.js +310 -47
- package/dist/src/stack/aliyunStack/apigwTypes.js +61 -1
- package/dist/src/stack/aliyunStack/ossResource.js +401 -69
- package/dist/src/stack/aliyunStack/ossTypes.js +58 -16
- package/dist/src/stack/deploy.js +4 -0
- package/dist/src/stack/scfStack/cosTypes.js +3 -6
- package/dist/src/stack/volcengineStack/apigwExecutor.js +87 -0
- package/dist/src/stack/volcengineStack/apigwPlanner.js +110 -0
- package/dist/src/stack/volcengineStack/apigwResource.js +302 -0
- package/dist/src/stack/volcengineStack/apigwTypes.js +106 -0
- package/dist/src/stack/volcengineStack/deployer.js +59 -0
- package/dist/src/stack/volcengineStack/destroyer.js +72 -0
- package/dist/src/stack/volcengineStack/index.js +44 -0
- package/dist/src/stack/volcengineStack/planner.js +27 -0
- package/dist/src/stack/volcengineStack/tosExecutor.js +106 -0
- package/dist/src/stack/volcengineStack/tosPlanner.js +96 -0
- package/dist/src/stack/volcengineStack/tosResource.js +103 -0
- package/dist/src/stack/volcengineStack/tosTypes.js +63 -0
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +102 -0
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +84 -0
- package/dist/src/stack/volcengineStack/vefaasResource.js +513 -0
- package/dist/src/stack/volcengineStack/vefaasTypes.js +75 -0
- package/dist/src/types/domains/state.js +6 -0
- package/dist/src/validator/bucketSchema.js +124 -56
- package/dist/src/validator/eventSchema.js +20 -0
- package/dist/src/validator/functionSchema.js +13 -0
- package/dist/src/validator/rootSchema.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -34
- package/samples/README_TENCENT_COS.md +3 -15
- package/samples/aliyun-poc-bucket-cdn.yml +63 -0
- package/samples/aliyun-poc-bucket.yml +0 -2
- package/samples/aliyun-poc-domain.yml +0 -2
- package/samples/tencent-poc-cos.yml +0 -2
- package/samples/volcengine-poc-advanced.yml +59 -0
- package/samples/volcengine-poc-api.yml +31 -0
- package/samples/volcengine-poc-bucket.yml +16 -0
- package/samples/volcengine-poc-function.yml +19 -0
- package/samples/volcengine-poc-vpc.yml +34 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIamOperations = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
|
+
const lang_1 = require("../../lang");
|
|
6
|
+
const DEFAULT_TRUST_POLICY_SERVICES = ['vefaas.volcengine.com'];
|
|
7
|
+
const buildTrustPolicyDocument = (trustedServices) => {
|
|
8
|
+
return JSON.stringify({
|
|
9
|
+
Statement: [
|
|
10
|
+
{
|
|
11
|
+
Effect: 'Allow',
|
|
12
|
+
Action: ['sts:AssumeRole'],
|
|
13
|
+
Principal: {
|
|
14
|
+
Service: trustedServices,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const VEFAAS_EXECUTION_POLICY = JSON.stringify({
|
|
21
|
+
Statement: [
|
|
22
|
+
{
|
|
23
|
+
Effect: 'Allow',
|
|
24
|
+
Action: ['vefaas:*'],
|
|
25
|
+
Resource: '*',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
Effect: 'Allow',
|
|
29
|
+
Action: ['tos:GetObject', 'tos:PutObject', 'tos:DeleteObject', 'tos:ListBucket'],
|
|
30
|
+
Resource: '*',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
Effect: 'Allow',
|
|
34
|
+
Action: ['vpc:DescribeVpcs', 'vpc:DescribeSubnets', 'vpc:DescribeSecurityGroups'],
|
|
35
|
+
Resource: '*',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
Effect: 'Allow',
|
|
39
|
+
Action: ['tls:CreateProject', 'tls:CreateTopic', 'tls:PutLogs'],
|
|
40
|
+
Resource: '*',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
const createIamOperations = (iamClient) => {
|
|
45
|
+
const createAndAttachPolicy = async (roleName) => {
|
|
46
|
+
const policyName = `${roleName}-policy`;
|
|
47
|
+
try {
|
|
48
|
+
await iamClient.fetchOpenAPI({
|
|
49
|
+
Action: 'CreatePolicy',
|
|
50
|
+
Version: '2024-01-01',
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: { 'content-type': 'application/json' },
|
|
53
|
+
data: {
|
|
54
|
+
PolicyName: policyName,
|
|
55
|
+
PolicyDocument: VEFAAS_EXECUTION_POLICY,
|
|
56
|
+
Description: `veFaaS execution policy for ${roleName}`,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
62
|
+
if (error.code === 'PolicyAlreadyExists' || error.code === 'Conflict') {
|
|
63
|
+
logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ALREADY_EXISTS', { policyName }));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await iamClient.fetchOpenAPI({
|
|
75
|
+
Action: 'AttachRolePolicy',
|
|
76
|
+
Version: '2024-01-01',
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: { 'content-type': 'application/json' },
|
|
79
|
+
data: {
|
|
80
|
+
RoleName: roleName,
|
|
81
|
+
PolicyName: policyName,
|
|
82
|
+
PolicyType: 'Custom',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
88
|
+
if (error.code === 'PolicyAlreadyAttached' || error.code === 'Conflict') {
|
|
89
|
+
logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ALREADY_ATTACHED', { policyName, roleName }));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return policyName;
|
|
100
|
+
};
|
|
101
|
+
const detachAndDeletePolicy = async (roleName) => {
|
|
102
|
+
const policyName = `${roleName}-policy`;
|
|
103
|
+
try {
|
|
104
|
+
await iamClient.fetchOpenAPI({
|
|
105
|
+
Action: 'DetachRolePolicy',
|
|
106
|
+
Version: '2024-01-01',
|
|
107
|
+
method: 'POST',
|
|
108
|
+
headers: { 'content-type': 'application/json' },
|
|
109
|
+
data: {
|
|
110
|
+
RoleName: roleName,
|
|
111
|
+
PolicyName: policyName,
|
|
112
|
+
PolicyType: 'Custom',
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Ignore if policy is not attached
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
await iamClient.fetchOpenAPI({
|
|
121
|
+
Action: 'DeletePolicy',
|
|
122
|
+
Version: '2024-01-01',
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: { 'content-type': 'application/json' },
|
|
125
|
+
data: {
|
|
126
|
+
PolicyName: policyName,
|
|
127
|
+
PolicyType: 'Custom',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Ignore if policy doesn't exist
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
createRole: async (config) => {
|
|
137
|
+
const roleName = config.roleName;
|
|
138
|
+
const trustedServices = config.trustPolicy.Statement[0]?.Principal.Service || DEFAULT_TRUST_POLICY_SERVICES;
|
|
139
|
+
const trustPolicyDocument = buildTrustPolicyDocument(trustedServices);
|
|
140
|
+
try {
|
|
141
|
+
const response = await iamClient.fetchOpenAPI({
|
|
142
|
+
Action: 'CreateRole',
|
|
143
|
+
Version: '2024-01-01',
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers: { 'content-type': 'application/json' },
|
|
146
|
+
data: {
|
|
147
|
+
RoleName: roleName,
|
|
148
|
+
TrustPolicyDocument: trustPolicyDocument,
|
|
149
|
+
DisplayName: config.displayName,
|
|
150
|
+
Description: config.description ?? `ServerlessInsight veFaaS execution role for ${roleName}`,
|
|
151
|
+
MaxSessionDuration: config.maxSessionDuration ?? 3600,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
const data = (response.Result || {});
|
|
155
|
+
const roleData = (data.Role || {});
|
|
156
|
+
const policyName = await createAndAttachPolicy(roleName);
|
|
157
|
+
logger_1.logger.info(lang_1.lang.__('IAM_ROLE_CREATED', { roleName }));
|
|
158
|
+
return {
|
|
159
|
+
roleName: roleData.RoleName,
|
|
160
|
+
roleId: roleData.RoleId,
|
|
161
|
+
trn: roleData.TRN,
|
|
162
|
+
description: roleData.Description,
|
|
163
|
+
createdTime: roleData.CreateTime,
|
|
164
|
+
maxSessionDuration: roleData.MaxSessionDuration,
|
|
165
|
+
trustPolicyDocument,
|
|
166
|
+
policyName,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
171
|
+
if (error.code === 'RoleAlreadyExists' || error.code === 'Conflict') {
|
|
172
|
+
logger_1.logger.info(lang_1.lang.__('IAM_ROLE_ALREADY_EXISTS', { roleName }));
|
|
173
|
+
try {
|
|
174
|
+
const existingRole = await iamClient.fetchOpenAPI({
|
|
175
|
+
Action: 'GetRole',
|
|
176
|
+
Version: '2024-01-01',
|
|
177
|
+
method: 'POST',
|
|
178
|
+
headers: { 'content-type': 'application/json' },
|
|
179
|
+
data: { RoleName: roleName },
|
|
180
|
+
});
|
|
181
|
+
await iamClient.fetchOpenAPI({
|
|
182
|
+
Action: 'UpdateTrustPolicy',
|
|
183
|
+
Version: '2024-01-01',
|
|
184
|
+
method: 'POST',
|
|
185
|
+
headers: { 'content-type': 'application/json' },
|
|
186
|
+
data: {
|
|
187
|
+
RoleName: roleName,
|
|
188
|
+
TrustPolicyDocument: trustPolicyDocument,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
const policyName = await createAndAttachPolicy(roleName);
|
|
192
|
+
const roleData = (existingRole.Result || {})
|
|
193
|
+
.Role;
|
|
194
|
+
return {
|
|
195
|
+
roleName: roleData?.RoleName,
|
|
196
|
+
roleId: roleData?.RoleId,
|
|
197
|
+
trn: roleData?.TRN,
|
|
198
|
+
description: roleData?.Description,
|
|
199
|
+
createdTime: roleData?.CreateTime,
|
|
200
|
+
maxSessionDuration: roleData?.MaxSessionDuration,
|
|
201
|
+
trustPolicyDocument,
|
|
202
|
+
policyName,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
catch (recoveryError) {
|
|
206
|
+
// eslint-disable-next-line preserve-caught-error
|
|
207
|
+
throw new Error(lang_1.lang.__('IAM_ROLE_DRIFT_RECOVERY_FAILED', {
|
|
208
|
+
roleName,
|
|
209
|
+
error: recoveryError instanceof Error ? recoveryError.message : String(recoveryError),
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
getRole: async (roleName) => {
|
|
218
|
+
try {
|
|
219
|
+
const response = await iamClient.fetchOpenAPI({
|
|
220
|
+
Action: 'GetRole',
|
|
221
|
+
Version: '2024-01-01',
|
|
222
|
+
method: 'POST',
|
|
223
|
+
headers: { 'content-type': 'application/json' },
|
|
224
|
+
data: { RoleName: roleName },
|
|
225
|
+
});
|
|
226
|
+
const roleData = (response.Result || {}).Role;
|
|
227
|
+
if (!roleData) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
roleName: roleData.RoleName,
|
|
232
|
+
roleId: roleData.RoleId,
|
|
233
|
+
trn: roleData.TRN,
|
|
234
|
+
description: roleData.Description,
|
|
235
|
+
createdTime: roleData.CreateTime,
|
|
236
|
+
maxSessionDuration: roleData.MaxSessionDuration,
|
|
237
|
+
trustPolicyDocument: roleData.TrustPolicyDocument,
|
|
238
|
+
policyName: `${roleName}-policy`,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
243
|
+
if (error.code === 'RoleNotFound' || error.code === 'NoSuchEntity') {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
updateRoleTrustPolicy: async (roleName, trustPolicy) => {
|
|
251
|
+
const trustPolicyDocument = JSON.stringify(trustPolicy);
|
|
252
|
+
try {
|
|
253
|
+
await iamClient.fetchOpenAPI({
|
|
254
|
+
Action: 'UpdateTrustPolicy',
|
|
255
|
+
Version: '2024-01-01',
|
|
256
|
+
method: 'POST',
|
|
257
|
+
headers: { 'content-type': 'application/json' },
|
|
258
|
+
data: {
|
|
259
|
+
RoleName: roleName,
|
|
260
|
+
TrustPolicyDocument: trustPolicyDocument,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
logger_1.logger.info(lang_1.lang.__('IAM_ROLE_TRUST_POLICY_UPDATED', { roleName }));
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
267
|
+
if (error.code === 'RoleNotFound' || error.code === 'NoSuchEntity') {
|
|
268
|
+
// eslint-disable-next-line preserve-caught-error
|
|
269
|
+
throw new Error(lang_1.lang.__('IAM_ROLE_NOT_FOUND_IN_CLOUD', { roleName }));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
deleteRole: async (roleName) => {
|
|
276
|
+
await detachAndDeletePolicy(roleName);
|
|
277
|
+
try {
|
|
278
|
+
await iamClient.fetchOpenAPI({
|
|
279
|
+
Action: 'DeleteRole',
|
|
280
|
+
Version: '2024-01-01',
|
|
281
|
+
method: 'POST',
|
|
282
|
+
headers: { 'content-type': 'application/json' },
|
|
283
|
+
data: { RoleName: roleName },
|
|
284
|
+
});
|
|
285
|
+
logger_1.logger.info(lang_1.lang.__('IAM_ROLE_DELETED', { roleName }));
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
289
|
+
if (error.code === 'RoleNotFound' || error.code === 'NoSuchEntity') {
|
|
290
|
+
logger_1.logger.warn(lang_1.lang.__('IAM_ROLE_NOT_FOUND_IN_CLOUD', { roleName }));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
attachRolePolicy: async (roleName, policyName, policyType) => {
|
|
298
|
+
try {
|
|
299
|
+
await iamClient.fetchOpenAPI({
|
|
300
|
+
Action: 'AttachRolePolicy',
|
|
301
|
+
Version: '2024-01-01',
|
|
302
|
+
method: 'POST',
|
|
303
|
+
headers: { 'content-type': 'application/json' },
|
|
304
|
+
data: {
|
|
305
|
+
RoleName: roleName,
|
|
306
|
+
PolicyName: policyName,
|
|
307
|
+
PolicyType: policyType,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ATTACHED', { policyName, roleName }));
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (error && typeof error === 'object' && 'code' in error) {
|
|
314
|
+
if (error.code === 'PolicyAlreadyAttached' || error.code === 'Conflict') {
|
|
315
|
+
logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ALREADY_ATTACHED', { policyName, roleName }));
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
detachRolePolicy: async (roleName, policyName) => {
|
|
323
|
+
try {
|
|
324
|
+
await iamClient.fetchOpenAPI({
|
|
325
|
+
Action: 'DetachRolePolicy',
|
|
326
|
+
Version: '2024-01-01',
|
|
327
|
+
method: 'POST',
|
|
328
|
+
headers: { 'content-type': 'application/json' },
|
|
329
|
+
data: {
|
|
330
|
+
RoleName: roleName,
|
|
331
|
+
PolicyName: policyName,
|
|
332
|
+
PolicyType: 'Custom',
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
logger_1.logger.info(lang_1.lang.__('IAM_POLICY_DETACHED', { policyName, roleName }));
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
if (error &&
|
|
339
|
+
typeof error === 'object' &&
|
|
340
|
+
'code' in error &&
|
|
341
|
+
(error.code === 'PolicyNotAttached' || error.code === 'NoSuchEntity')) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
logger_1.logger.warn(lang_1.lang.__('IAM_POLICY_DETACH_FAILED', { policyName, roleName, error: String(error) }));
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
exports.createIamOperations = createIamOperations;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createVolcengineClient = void 0;
|
|
18
|
+
const openapi_1 = require("@volcengine/openapi");
|
|
19
|
+
const vefaasOperations_1 = require("./vefaasOperations");
|
|
20
|
+
const tosOperations_1 = require("./tosOperations");
|
|
21
|
+
const iamOperations_1 = require("./iamOperations");
|
|
22
|
+
const apigwOperations_1 = require("./apigwOperations");
|
|
23
|
+
const tlsOperations_1 = require("./tlsOperations");
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
__exportStar(require("./vefaasOperations"), exports);
|
|
26
|
+
__exportStar(require("./tosOperations"), exports);
|
|
27
|
+
__exportStar(require("./iamOperations"), exports);
|
|
28
|
+
__exportStar(require("./apigwOperations"), exports);
|
|
29
|
+
__exportStar(require("./tlsOperations"), exports);
|
|
30
|
+
const initializeSdkClients = (context) => {
|
|
31
|
+
const vefaasService = new openapi_1.Service({
|
|
32
|
+
serviceName: 'vefaas',
|
|
33
|
+
defaultVersion: '2024-06-06',
|
|
34
|
+
protocol: 'https',
|
|
35
|
+
host: 'vefaas.volcengineapi.com',
|
|
36
|
+
accessKeyId: context.accessKeyId,
|
|
37
|
+
secretKey: context.accessKeySecret,
|
|
38
|
+
region: context.region,
|
|
39
|
+
...(context.securityToken && { sessionToken: context.securityToken }),
|
|
40
|
+
});
|
|
41
|
+
const tosService = new openapi_1.Service({
|
|
42
|
+
serviceName: 'tos',
|
|
43
|
+
defaultVersion: '2018-08-01',
|
|
44
|
+
protocol: 'https',
|
|
45
|
+
host: `tos-${context.region}.volces.com`,
|
|
46
|
+
accessKeyId: context.accessKeyId,
|
|
47
|
+
secretKey: context.accessKeySecret,
|
|
48
|
+
region: context.region,
|
|
49
|
+
...(context.securityToken && { sessionToken: context.securityToken }),
|
|
50
|
+
});
|
|
51
|
+
const iamService = new openapi_1.Service({
|
|
52
|
+
serviceName: 'iam',
|
|
53
|
+
defaultVersion: '2024-01-01',
|
|
54
|
+
protocol: 'https',
|
|
55
|
+
host: 'iam.volcengineapi.com',
|
|
56
|
+
accessKeyId: context.accessKeyId,
|
|
57
|
+
secretKey: context.accessKeySecret,
|
|
58
|
+
region: context.region,
|
|
59
|
+
...(context.securityToken && { sessionToken: context.securityToken }),
|
|
60
|
+
});
|
|
61
|
+
const tlsService = new openapi_1.Service({
|
|
62
|
+
serviceName: 'tls',
|
|
63
|
+
defaultVersion: '2024-01-01',
|
|
64
|
+
protocol: 'https',
|
|
65
|
+
host: `tls.${context.region}.volces.com`,
|
|
66
|
+
accessKeyId: context.accessKeyId,
|
|
67
|
+
secretKey: context.accessKeySecret,
|
|
68
|
+
region: context.region,
|
|
69
|
+
...(context.securityToken && { sessionToken: context.securityToken }),
|
|
70
|
+
});
|
|
71
|
+
const apigwService = new openapi_1.Service({
|
|
72
|
+
serviceName: 'apig',
|
|
73
|
+
defaultVersion: '2021-03-03',
|
|
74
|
+
protocol: 'https',
|
|
75
|
+
host: 'apig.volcengineapi.com',
|
|
76
|
+
accessKeyId: context.accessKeyId,
|
|
77
|
+
secretKey: context.accessKeySecret,
|
|
78
|
+
region: context.region,
|
|
79
|
+
...(context.securityToken && { sessionToken: context.securityToken }),
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
vefaas: vefaasService,
|
|
83
|
+
tos: tosService,
|
|
84
|
+
iam: iamService,
|
|
85
|
+
tls: tlsService,
|
|
86
|
+
apigw: apigwService,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const createVolcengineClient = (context) => {
|
|
90
|
+
const sdkClients = initializeSdkClients(context);
|
|
91
|
+
return {
|
|
92
|
+
vefaas: (0, vefaasOperations_1.createVefaasOperations)(sdkClients.vefaas),
|
|
93
|
+
tos: (0, tosOperations_1.createTosOperations)(sdkClients.tos, context.region),
|
|
94
|
+
iam: (0, iamOperations_1.createIamOperations)(sdkClients.iam),
|
|
95
|
+
tls: (0, tlsOperations_1.createTlsOperations)(sdkClients.tls),
|
|
96
|
+
apigw: (0, apigwOperations_1.createApigwOperations)(sdkClients.apigw),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.createVolcengineClient = createVolcengineClient;
|