Skip to content

Commit bc67866

Browse files
authored
fix(location): remove base class from PlaceIndex class (#31287)
### Issue # (if applicable) None ### Reason for this change I implemented the location resources in #30711 and #30682. During the review, it was suggested that it would be better not to have a base class. As a result, the `GeofenceCollection` class and `RouteCalculator` class do not have a base class. #30711 (comment) On the other hand, the `PlaceIndex `class has already been implemented with a base class, which is inconsistent with the current approach. ### Description of changes Remove a unnecessary base class from `PlaceIndex` class. ### Description of how you validated changes Re-run unit tests and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 157c37d commit bc67866

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

packages/@aws-cdk/aws-location-alpha/lib/place-index.ts

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,39 +74,12 @@ export enum IntendedUse {
7474
STORAGE = 'Storage',
7575
}
7676

77-
abstract class PlaceIndexBase extends Resource implements IPlaceIndex {
78-
public abstract readonly placeIndexName: string;
79-
public abstract readonly placeIndexArn: string;
80-
81-
/**
82-
* Grant the given principal identity permissions to perform the actions on this place index.
83-
*/
84-
public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant {
85-
return iam.Grant.addToPrincipal({
86-
grantee: grantee,
87-
actions: actions,
88-
resourceArns: [this.placeIndexArn],
89-
});
90-
}
91-
92-
/**
93-
* Grant the given identity permissions to search using this index
94-
*/
95-
public grantSearch(grantee: iam.IGrantable): iam.Grant {
96-
return this.grant(grantee,
97-
'geo:SearchPlaceIndexForPosition',
98-
'geo:SearchPlaceIndexForSuggestions',
99-
'geo:SearchPlaceIndexForText',
100-
);
101-
}
102-
}
103-
10477
/**
10578
* A Place Index
10679
*
10780
* @see https://docs.aws.amazon.com/location/latest/developerguide/places-concepts.html
10881
*/
109-
export class PlaceIndex extends PlaceIndexBase {
82+
export class PlaceIndex extends Resource implements IPlaceIndex {
11083
/**
11184
* Use an existing place index by name
11285
*/
@@ -130,7 +103,7 @@ export class PlaceIndex extends PlaceIndexBase {
130103
throw new Error(`Place Index Arn ${placeIndexArn} does not have a resource name.`);
131104
}
132105

133-
class Import extends PlaceIndexBase {
106+
class Import extends Resource implements IPlaceIndex {
134107
public readonly placeIndexName = parsedArn.resourceName!;
135108
public readonly placeIndexArn = placeIndexArn;
136109
}
@@ -187,4 +160,25 @@ export class PlaceIndex extends PlaceIndexBase {
187160
this.placeIndexUpdateTime = placeIndex.attrUpdateTime;
188161
}
189162

163+
/**
164+
* Grant the given principal identity permissions to perform the actions on this place index.
165+
*/
166+
public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant {
167+
return iam.Grant.addToPrincipal({
168+
grantee: grantee,
169+
actions: actions,
170+
resourceArns: [this.placeIndexArn],
171+
});
172+
}
173+
174+
/**
175+
* Grant the given identity permissions to search using this index
176+
*/
177+
public grantSearch(grantee: iam.IGrantable): iam.Grant {
178+
return this.grant(grantee,
179+
'geo:SearchPlaceIndexForPosition',
180+
'geo:SearchPlaceIndexForSuggestions',
181+
'geo:SearchPlaceIndexForText',
182+
);
183+
}
190184
}

0 commit comments

Comments
 (0)