Skip to content

Commit

Permalink
add datasource to util
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Aug 29, 2024
1 parent 6c8dff4 commit 5761669
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-location-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To create a route calculator, define a `RouteCalculator`:
```ts
new location.RouteCalculator(this, 'RouteCalculator', {
routeCalculatorName: 'MyRouteCalculator', // optional, defaults to a generated name
dataSource: location.DataSource.HERE, // optional, defaults to Esri
dataSource: location.DataSource.ESRI,
});
```

Expand All @@ -71,6 +71,8 @@ on the route calculator:
```ts
declare const role: iam.Role;

const routeCalculator = new location.RouteCalculator(this, 'RouteCalculator');
const routeCalculator = new location.RouteCalculator(this, 'RouteCalculator', {
dataSource: location.DataSource.ESRI,
});
routeCalculator.grantRead(role);
```
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-location-alpha/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './place-index';
export * from './route-calculator';
export * from './util';

// AWS::Location CloudFormation Resources:
27 changes: 1 addition & 26 deletions packages/@aws-cdk/aws-location-alpha/lib/place-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import { ArnFormat, IResource, Lazy, Names, Resource, Stack, Token } from 'aws-cdk-lib/core';
import { Construct } from 'constructs';
import { CfnPlaceIndex } from 'aws-cdk-lib/aws-location';
import { DataSource } from './util';

/**
* A Place Index
Expand Down Expand Up @@ -58,32 +59,6 @@ export interface PlaceIndexProps {
readonly description?: string;
}

/**
* Data source for a place index
*/
export enum DataSource {
/**
* Esri
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/esri.html
*/
ESRI = 'Esri',

/**
* Grab provides routing functionality for Southeast Asia.
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/grab.html
*/
GRAB = 'Grab',

/**
* HERE
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/HERE.html
*/
HERE = 'Here',
}

/**
* Intend use for the results of an operation
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/@aws-cdk/aws-location-alpha/lib/route-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import { ArnFormat, IResource, Lazy, Resource, Stack, Token } from 'aws-cdk-lib/core';
import { Construct } from 'constructs';
import { CfnRouteCalculator } from 'aws-cdk-lib/aws-location';
import { DataSource } from './place-index';
import { generateUniqueId } from './util';
import { generateUniqueId, DataSource } from './util';

/**
* A Route Calculator
Expand Down
26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-location-alpha/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ export function generateUniqueId(context: IConstruct): string {
}
return name;
}

/**
* Data source for a place index
*/
export enum DataSource {
/**
* Esri
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/esri.html
*/
ESRI = 'Esri',

/**
* Grab provides routing functionality for Southeast Asia.
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/grab.html
*/
GRAB = 'Grab',

/**
* HERE
*
* @see https://docs.aws.amazon.com/location/latest/developerguide/HERE.html
*/
HERE = 'Here',
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Match, Template } from 'aws-cdk-lib/assertions';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Stack } from 'aws-cdk-lib';
import { DataSource, IntendedUse, PlaceIndex } from '../lib/place-index';
import { IntendedUse, PlaceIndex } from '../lib/place-index';
import { DataSource } from '../lib';

let stack: Stack;
beforeEach(() => {
Expand Down

0 comments on commit 5761669

Please sign in to comment.