Skip to content

Commit b76b768

Browse files
committed
fix(apigw): add get api detail by apiId
1 parent fbf847e commit b76b768

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/modules/apigw/index.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,15 @@ class Apigw {
574574
return apiDetail;
575575
}
576576

577+
async getApiById({ serviceId, apiId }) {
578+
const apiDetail = await this.request({
579+
Action: 'DescribeApi',
580+
serviceId: serviceId,
581+
apiId: apiId,
582+
});
583+
return apiDetail;
584+
}
585+
577586
async createOrUpdateApi({ serviceId, endpoint, environment, created }) {
578587
// compatibility for secret auth config depends on auth & usagePlan
579588
const authType = endpoint.auth ? 'SECRET' : endpoint.authType || 'NONE';
@@ -615,11 +624,18 @@ class Apigw {
615624

616625
this.marshalApiInput(endpoint, apiInputs);
617626

618-
let apiDetail = await this.getApiByPathAndMethod({
619-
serviceId,
620-
path: endpoint.path,
621-
method: endpoint.method,
622-
});
627+
let apiDetail = null;
628+
if (endpoint.apiId) {
629+
apiDetail = await this.getApiById({ serviceId, apiId: endpoint.apiId });
630+
}
631+
632+
if (!apiDetail) {
633+
apiDetail = await this.getApiByPathAndMethod({
634+
serviceId,
635+
path: endpoint.path,
636+
method: endpoint.method,
637+
});
638+
}
623639

624640
if (apiDetail) {
625641
console.log(`Api method ${endpoint.method}, path ${endpoint.path} already exist`);

0 commit comments

Comments
 (0)