@@ -262,6 +262,8 @@ class Apigw {
262
262
}
263
263
264
264
async setupApiUsagePlan ( { usagePlan } ) {
265
+ console . log ( 'usagePlan' , usagePlan )
266
+
265
267
const usageInputs = {
266
268
usagePlanName : usagePlan . usagePlanName || '' ,
267
269
usagePlanDesc : usagePlan . usagePlanDesc || '' ,
@@ -271,22 +273,22 @@ class Apigw {
271
273
272
274
const usagePlanOutput = {
273
275
created : usagePlan . created || false ,
274
- id : usagePlan . id
276
+ usagePlanId : usagePlan . usagePlanId
275
277
}
276
278
277
- if ( ! usagePlan . id ) {
279
+ if ( ! usagePlan . usagePlanId ) {
278
280
const createUsagePlan = await this . request ( {
279
281
Action : 'CreateUsagePlan' ,
280
282
...usageInputs
281
283
} )
282
- usagePlanOutput . id = createUsagePlan . usagePlanId
284
+ usagePlanOutput . usagePlanId = createUsagePlan . usagePlanId
283
285
usagePlanOutput . created = true
284
286
console . log ( `Usage plan with ID ${ usagePlanOutput . id } created.` )
285
287
} else {
286
288
console . log ( `Updating usage plan with id ${ usagePlan . usagePlanId } .` )
287
289
await this . request ( {
288
290
Action : 'ModifyUsagePlan' ,
289
- usagePlanId : usagePlanOutput . id ,
291
+ usagePlanId : usagePlanOutput . usagePlanId ,
290
292
...usageInputs
291
293
} )
292
294
}
@@ -407,21 +409,21 @@ class Apigw {
407
409
apiIds : [ apiId ]
408
410
} )
409
411
410
- const oldUsagePlan = usagePlanList . find ( ( item ) => item . usagePlanId === usagePlan . id )
412
+ const oldUsagePlan = usagePlanList . find ( ( item ) => item . usagePlanId === usagePlan . usagePlanId )
411
413
if ( oldUsagePlan ) {
412
414
console . log (
413
- `Usage plan with id ${ usagePlan . id } already bind to api id ${ apiId } path ${ endpoint . method } ${ endpoint . path } .`
415
+ `Usage plan with id ${ usagePlan . usagePlanId } already bind to api id ${ apiId } path ${ endpoint . method } ${ endpoint . path } .`
414
416
)
415
417
} else {
416
418
console . log (
417
- `Binding usage plan with id ${ usagePlan . id } to api id ${ apiId } path ${ endpoint . method } ${ endpoint . path } .`
419
+ `Binding usage plan with id ${ usagePlan . usagePlanId } to api id ${ apiId } path ${ endpoint . method } ${ endpoint . path } .`
418
420
)
419
421
await this . request ( {
420
422
Action : 'BindEnvironment' ,
421
423
serviceId,
422
424
environment,
423
425
bindType : bindType ,
424
- usagePlanIds : [ usagePlan . id ] ,
426
+ usagePlanIds : [ usagePlan . usagePlanId ] ,
425
427
apiIds : [ apiId ]
426
428
} )
427
429
console . log ( 'Binding successed.' )
@@ -477,16 +479,16 @@ class Apigw {
477
479
secretIds
478
480
} )
479
481
const unboundSecretIds = await this . getUnboundSecretIds ( {
480
- usagePlanId : usagePlan . id ,
482
+ usagePlanId : usagePlan . usagePlanId ,
481
483
secretIds : secrets . secretIds
482
484
} )
483
485
if ( unboundSecretIds . length > 0 ) {
484
486
console . log (
485
- `Binding secret key ${ unboundSecretIds } to usage plan with id ${ usagePlan . id } .`
487
+ `Binding secret key ${ unboundSecretIds } to usage plan with id ${ usagePlan . usagePlanId } .`
486
488
)
487
489
await this . request ( {
488
490
Action : 'BindSecretIds' ,
489
- usagePlanId : usagePlan . id ,
491
+ usagePlanId : usagePlan . usagePlanId ,
490
492
secretIds : unboundSecretIds
491
493
} )
492
494
console . log ( 'Binding secret key successed.' )
@@ -557,9 +559,9 @@ class Apigw {
557
559
await this . request ( {
558
560
Action : 'UnBindSecretIds' ,
559
561
secretIds : secrets . secretIds ,
560
- usagePlanId : curApi . usagePlan . id
562
+ usagePlanId : curApi . usagePlan . usagePlanId
561
563
} )
562
- console . log ( `Unbinding secret key to usage plan with ID ${ curApi . usagePlan . id } .` )
564
+ console . log ( `Unbinding secret key to usage plan with ID ${ curApi . usagePlan . usagePlanId } .` )
563
565
564
566
// delelet all created api key
565
567
if ( curApi . usagePlan . secrets . created === true ) {
@@ -582,21 +584,23 @@ class Apigw {
582
584
await this . request ( {
583
585
Action : 'UnBindEnvironment' ,
584
586
serviceId,
585
- usagePlanIds : [ curApi . usagePlan . id ] ,
587
+ usagePlanIds : [ curApi . usagePlan . usagePlanId ] ,
586
588
environment,
587
589
bindType : curApi . bindType ,
588
590
apiIds : [ curApi . apiId ]
589
591
} )
590
592
console . log (
591
- `Unbinding usage plan with ID ${ curApi . usagePlan . id } to service with ID ${ serviceId } .`
593
+ `Unbinding usage plan with ID ${ curApi . usagePlan . usagePlanId } to service with ID ${ serviceId } .`
592
594
)
593
595
594
596
// 1.3 delete created usage plan
595
597
if ( curApi . usagePlan . created === true ) {
596
- console . log ( `Removing any previously deployed usage plan ids ${ curApi . usagePlan . id } ` )
598
+ console . log (
599
+ `Removing any previously deployed usage plan ids ${ curApi . usagePlan . usagePlanId } `
600
+ )
597
601
await this . request ( {
598
602
Action : 'DeleteUsagePlan' ,
599
- usagePlanId : curApi . usagePlan . id
603
+ usagePlanId : curApi . usagePlan . usagePlanId
600
604
} )
601
605
}
602
606
}
0 commit comments