- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
PutGeofenceCommand
Stores a geofence geometry in a given geofence collection, or updates the geometry of an existing geofence if a geofence ID is included in the request.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { LocationClient, PutGeofenceCommand } from "@aws-sdk/client-location"; // ES Modules import
// const { LocationClient, PutGeofenceCommand } = require("@aws-sdk/client-location"); // CommonJS import
const client = new LocationClient(config);
const input = { // PutGeofenceRequest
CollectionName: "STRING_VALUE", // required
GeofenceId: "STRING_VALUE", // required
Geometry: { // GeofenceGeometry
Polygon: [ // LinearRings
[ // LinearRing
[ // Position
Number("double"),
],
],
],
Circle: { // Circle
Center: [ // required
Number("double"),
],
Radius: Number("double"), // required
},
Geobuf: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
},
GeofenceProperties: { // PropertyMap
"<keys>": "STRING_VALUE",
},
};
const command = new PutGeofenceCommand(input);
const response = await client.send(command);
// { // PutGeofenceResponse
// GeofenceId: "STRING_VALUE", // required
// CreateTime: new Date("TIMESTAMP"), // required
// UpdateTime: new Date("TIMESTAMP"), // required
// };
PutGeofenceCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
CollectionName Required | string | undefined | The geofence collection to store the geofence in. |
GeofenceId Required | string | undefined | An identifier for the geofence. For example, |
Geometry Required | GeofenceGeometry | undefined | Contains the details to specify the position of the geofence. Can be a polygon, a circle or a polygon encoded in Geobuf format. Including multiple selections will return a validation error. The geofence polygon format supports a maximum of 1,000 vertices. The Geofence Geobuf format supports a maximum of 100,000 vertices. |
GeofenceProperties | Record<string, string> | undefined | Associates one of more properties with the geofence. A property is a key-value pair stored with the geofence and added to any geofence event triggered with that geofence. Format: |
PutGeofenceCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
CreateTime Required | Date | undefined | The timestamp for when the geofence was created in ISO 8601 format: |
GeofenceId Required | string | undefined | The geofence identifier entered in the request. |
UpdateTime Required | Date | undefined | The timestamp for when the geofence was last updated in ISO 8601 format: |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions. |
ConflictException | client | The request was unsuccessful because of a conflict. |
InternalServerException | server | The request has failed to process because of an unknown server error, exception, or failure. |
ResourceNotFoundException | client | The resource that you've entered was not found in your AWS account. |
ThrottlingException | client | The request was denied because of request throttling. |
ValidationException | client | The input failed to meet the constraints specified by the AWS service. |
LocationServiceException | Base exception class for all service exceptions from Location service. |