REST API for the Metering Service
Introduction
This section is an overview of the REST API provided by the metering microservice.
Users
POST /user
Body:
Response: 201 Created
Purpose: Adds a new tenant. Requires the ADMIN role. For more info about tenants please see architecture.
DELETE /user/
Response: 204 No Content
Purpose: Deletes the named tenant. Requires the ADMIN role. For more info about tenants please see architecture.
Recording usage
POST /usage/location
Request Body:
Response: 201 Created
Purpose: Records a single location event for the tenant making the request. Please note, this location event is stored against the tenant making the call. When an admin queries the microservice for usage information they will provide a tenant ID to search against. This is separate from the user entry in the JSON. The user entry in the JSON is the user who is logged into AMP.
Description:
- Requires USER role
- Timestamp format yyyy-MM-dd’T’HH:mm:ssX
- Metadata may contain arbitrary key/value data.
POST /usage/locations
Request body:
Response: 201 Created
Purpose: Record multiple location events.
POST /usage/application
Request body:
Response: 201 Created
Purpose: Record a single application event.
Description:
- Requires TENANT role
- Timestamp format yyyy-MM-dd’T’HH:mm:ssX
- Metadata may contain arbitrary key/value data.
POST /usage/applications
Request body:
Response: 201 Created
Purpose: Record multiple application events.
Retrieving data
GET /usage/location/hour
Query Parameters:
- tenantId
- startTime
- endTime
Response format:
Purpose: Retrieve a summary of the usage data for the named tenant between the given dates. Unlike /usage/location which returns each individual record, this endpoint returns one record per location adding up all periods for which the location was active. This endpoint is often used for calculuate biling information.
Description:
- All parameters are required.
- Requires the ADMIN role.
- Timestamp format yyyy-MM-dd’T’HH:mm:ssX
GET /usage/location-metadata
Query Parameters:
- locId
- startTime
- endTime
Response format:
Purpose: Retrieve a list of all metadata associated with a location over the given time period.
Description:
- All parameters are required
- Requires the ADMIN role
- Timestamp format yyyy-MM-dd’T’HH:mm:ssX
GET /usage/location
Query Parameters:
- tenantId
- ampId
- applicationId
- entityId
- locId
- user
- entityType
- state
- startTime
- endTime
Response format:
Purpose: Retrieve a list of LocationUsage events matching the search criteria. Search criteria are optional, allowing custom queries to be written.
Description:
- All query parameters are optional
- At least one parameter must be given
- Requires the ADMIN role
- Timestamp format yyyy-MM-dd’T’HH:mm:ssX