Skip to content

put_geofence

put_geofence(
    collection_name: ResourceName,
    geofence_id: Id,
    geometry: GeofenceGeometry,
    *,
    config_overrides: Optional[LocationClientConfig] = None,
    geofence_properties: Optional[PropertyMap] = None,
) -> PutGeofenceResponse

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.

Parameters:

  • collection_name (ResourceName) –

    The geofence collection to store the geofence in.

  • geofence_id (Id) –

    An identifier for the geofence. For example, ExampleGeofence-1.

  • geometry (GeofenceGeometry) –

    Contains the details to specify the position of the geofence. Can be a circle, a polygon, or a multipolygon. Polygon and MultiPolygon geometries can be defined using their respective parameters, or encoded in Geobuf format using the Geobuf parameter. Including multiple geometry types in the same request will return a validation error.

    The geofence Polygon and MultiPolygon formats support a maximum of 1,000 total vertices. The Geobuf format supports a maximum of 100,000 vertices.

  • geofence_properties (Optional[PropertyMap], default: None ) –

    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: "key" : "value"

Raises:

Source code in docs_src/capo_location/_services/location.py
def put_geofence(
    self,
    collection_name: "capo_location.types.resource_name.ResourceName",
    geofence_id: "capo_location.types.id.Id",
    geometry: "capo_location.types.geofence_geometry.GeofenceGeometry",
    *,
    config_overrides: Optional[LocationClientConfig] = None,
    geofence_properties: Optional[
        "capo_location.types.property_map.PropertyMap"
    ] = None,
) -> "capo_location.types.put_geofence_response.PutGeofenceResponse":
    """<p>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. </p>

    Args:
        collection_name: <p>The geofence collection to store the geofence in.</p>
        geofence_id: <p>An identifier for the geofence. For example, <code>ExampleGeofence-1</code>.</p>
        geometry: <p>Contains the details to specify the position of the geofence. Can be a circle, a polygon, or a multipolygon. <code>Polygon</code> and <code>MultiPolygon</code> geometries can be defined using their respective parameters, or encoded in Geobuf format using the <code>Geobuf</code> parameter. Including multiple geometry types in the same request will return a validation error.</p> <note> <p>The geofence <code>Polygon</code> and <code>MultiPolygon</code> formats support a maximum of 1,000 total vertices. The <code>Geobuf</code> format supports a maximum of 100,000 vertices.</p> </note>
        geofence_properties: <p>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.</p> <p>Format: <code>"key" : "value"</code> </p>

    Raises:
        capo_location.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.</p>
        capo_location.errors.conflict_exception.ConflictException: <p>The request was unsuccessful because of a conflict.</p>
        capo_location.errors.internal_server_exception.InternalServerException: <p>The request has failed to process because of an unknown server error, exception, or failure.</p>
        capo_location.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource that you've entered was not found in your AWS account.</p>
        capo_location.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
        capo_location.errors.validation_exception.ValidationException: <p>The input failed to meet the constraints specified by the AWS service. </p>
        capo_location.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_location.types.put_geofence_request.PutGeofenceRequest]",
    ) -> OperationResponse[
        "capo_location.types.put_geofence_response.PutGeofenceResponse"
    ]:
        import capo_location._operations.location_service.put_geofence

        output, http_response = (
            capo_location._operations.location_service.put_geofence.put_geofence(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_location.types.put_geofence_request.PutGeofenceRequest",
    ) -> dict[str, Any]:
        import capo_location.types.put_geofence_request

        return capo_location.types.put_geofence_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_location.types.put_geofence_response.PutGeofenceResponse",
    ) -> dict[str, Any]:
        import capo_location.types.put_geofence_response

        return capo_location.types.put_geofence_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "PutGeofence", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_location.types.put_geofence_request.PutGeofenceRequest = {
        "collection_name": collection_name,
        "geofence_id": geofence_id,
        "geometry": geometry,
    }
    if geofence_properties is not None:
        input_["geofence_properties"] = geofence_properties

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output