MCPcopy
hub / github.com/agent-infra/sandbox / getApigTrigger

Method getApigTrigger

sdk/js/src/providers/volcengine.ts:327–367  ·  view source on GitHub ↗

* Get the UpstreamId from APIG triggers for a given function. * * @param functionId - The function ID to get triggers for * @returns The UpstreamId from the first APIG trigger found, or null

(functionId: string)

Source from the content-addressed store, hash-verified

325 * @returns The UpstreamId from the first APIG trigger found, or null
326 */
327 private async getApigTrigger(functionId: string): Promise<string | null> {
328 const body = JSON.stringify({
329 FunctionId: functionId,
330 });
331
332 const response = await request(
333 'POST',
334 new Date(),
335 {},
336 {},
337 this.accessKey,
338 this.secretKey,
339 '',
340 'ListTriggers',
341 body,
342 this.region,
343 );
344
345 if (response && typeof response === 'object') {
346 const result = response.Result || {};
347 const items = result.Items || [];
348
349 for (const item of items) {
350 if (item.Type === 'apig') {
351 const detailedConfig = item.DetailedConfig || '{}';
352 try {
353 const config = JSON.parse(detailedConfig);
354 const upstreamId = config.UpstreamId;
355 if (upstreamId) {
356 return upstreamId;
357 }
358 } catch (error) {
359 console.error(`Failed to parse DetailedConfig: ${detailedConfig}`);
360 continue;
361 }
362 }
363 }
364 }
365
366 return null;
367 }
368
369 /**
370 * Get structured domains from APIG routes using the upstream ID.

Callers 1

getApigDomainsMethod · 0.95

Calls 3

requestFunction · 0.90
errorMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected