From 3bc64482e4fb98f96541199e2c1411e7e7a156f4 Mon Sep 17 00:00:00 2001 From: maz Date: Mon, 2 Sep 2024 20:39:00 +0900 Subject: [PATCH] remove base class --- .../aws-location-alpha/lib/place-index.ts | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts b/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts index 026d8c5268a68..c1554300c33aa 100644 --- a/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts +++ b/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts @@ -74,39 +74,12 @@ export enum IntendedUse { STORAGE = 'Storage', } -abstract class PlaceIndexBase extends Resource implements IPlaceIndex { - public abstract readonly placeIndexName: string; - public abstract readonly placeIndexArn: string; - - /** - * Grant the given principal identity permissions to perform the actions on this place index. - */ - public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant { - return iam.Grant.addToPrincipal({ - grantee: grantee, - actions: actions, - resourceArns: [this.placeIndexArn], - }); - } - - /** - * Grant the given identity permissions to search using this index - */ - public grantSearch(grantee: iam.IGrantable): iam.Grant { - return this.grant(grantee, - 'geo:SearchPlaceIndexForPosition', - 'geo:SearchPlaceIndexForSuggestions', - 'geo:SearchPlaceIndexForText', - ); - } -} - /** * A Place Index * * @see https://docs.aws.amazon.com/location/latest/developerguide/places-concepts.html */ -export class PlaceIndex extends PlaceIndexBase { +export class PlaceIndex extends Resource implements IPlaceIndex { /** * Use an existing place index by name */ @@ -130,7 +103,7 @@ export class PlaceIndex extends PlaceIndexBase { throw new Error(`Place Index Arn ${placeIndexArn} does not have a resource name.`); } - class Import extends PlaceIndexBase { + class Import extends Resource implements IPlaceIndex { public readonly placeIndexName = parsedArn.resourceName!; public readonly placeIndexArn = placeIndexArn; } @@ -187,4 +160,25 @@ export class PlaceIndex extends PlaceIndexBase { this.placeIndexUpdateTime = placeIndex.attrUpdateTime; } + /** + * Grant the given principal identity permissions to perform the actions on this place index. + */ + public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant { + return iam.Grant.addToPrincipal({ + grantee: grantee, + actions: actions, + resourceArns: [this.placeIndexArn], + }); + } + + /** + * Grant the given identity permissions to search using this index + */ + public grantSearch(grantee: iam.IGrantable): iam.Grant { + return this.grant(grantee, + 'geo:SearchPlaceIndexForPosition', + 'geo:SearchPlaceIndexForSuggestions', + 'geo:SearchPlaceIndexForText', + ); + } }