Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(location): remove base class from PlaceIndex class #31287

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions packages/@aws-cdk/aws-location-alpha/lib/place-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,12 @@ export enum IntendedUse {
STORAGE = 'Storage',
}

abstract class PlaceIndexBase extends Resource implements IPlaceIndex {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mazyu36 - just to double clarify here, you don't forsee adding an additional class anywhere that would need to extend the base class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumupitchayan

I don't think we'll need to add other classes, since there are no resources similar to placeindex.

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
*/
Expand All @@ -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;
}
Expand Down Expand Up @@ -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',
);
}
}
Loading