Skip to main content
Version: v0.2b

Operation Schema

Model

Operation

Ƭ Operation: PlanOptimizationOperation

The operation model.

Description

Every operation model has an unique identifier, a type field and a done field.

Currently, the only supported operation type is plan_optimization.


PlanOptimizationOperation

Ƭ PlanOptimizationOperation: Object

A plan optimization operation.

Description

This operation represents the asynchronous optimization of a plan. It can be cancelled before it is done.

Example

{
"id": "operations/zeOCJaJCzZhpKVCVAC9o",
"done": true,
"type": "plan_optimization",
"result": {
"skippedStops": [
{
"id": "stop/123",
"reason": "impossible_time_window"
}
],
"numOptimizedStops": 20
},
"metadata": {
"startedAt": 1631100800,
"finishedAt": 1631101600,
"canceled": false,
"targetPlanId": "plan/abc",
"startedBy": "api"
}
}

Type declaration

NameTypeDescription
idOperationIdThis is the operation's unique identifier in the API, this can be used directly in the URL to operate on this operation.
donebooleanThis indicates whether the operation is finished or not. Use this field to know when the operation is finished and the results are available.
type"plan_optimization"This is the operation's type, it indicates what kind of operation it is.
resultPlanOptimizationOperationResult | OperationError | nullThis is the operation's result, it is only present if the operation is finished.
metadataPlanOptimizationOperationMetadataThe operation's metadata.

Identifier

OperationId

Ƭ OperationId: `operations/${string}`

An operation id is a string that is unique to an operation. It is used to identify an operation in the API.

Example

"operations/zeOCJaJCzZhpKVCVAC9o"

Fields

OperationError

Ƭ OperationError: Object

An operation error result.

Description

If the operation fails, this is the result model.

Example

{
"code": "ERR001",
"message": "Operation failed due to invalid inputs."
}

Type declaration

NameTypeDescription
codestringA code that identifies the error.
messagestringA human-readable message that describes the error. This message is not intended to be parsed by machines.

PlanOptimizationOperationResult

Ƭ PlanOptimizationOperationResult: Object

The plan optimization operation's result model.

Example

{
"skippedStops": [
{
"id": "plans/zeOCJaJCzZhpKVCVAC9o/stops/rpX5zK2kRFlIfwREp1js",
"reason": "impossible_time_window"
},
{
"id": "plans/zeOCJaJCzZhpKVCVAC9o/stops/2pX5zK2kRFlIfwREp1js",
"reason": "impossible_navigation"
}
],
"numOptimizedStops": 20
}

Type declaration

NameTypeDescription
skippedStopsPlanOptimizationSkippedStop[]All of the skipped stops during the optimization, if any.
numOptimizedStopsnumberThe number of optimized stops considered for optimization for the operation.

PlanOptimizationSkippedStop

Ƭ PlanOptimizationSkippedStop: Object

The representation of the skipped stops in the plan optimization operation's result.

Example

{
"id": "plans/zeOCJaJCzZhpKVCVAC9o/stops/2pX5zK2kRFlIfwREp1js",
"reason": "impossible_time_window"
}

Type declaration

NameTypeDescription
idStopIdThis is the stop's unique identifier in the API.
reason"impossible_time_window" | "impossible_navigation" | stringThis is the reason why the stop was skipped.
  • impossible_time_window: The stop's time window is impossible to satisfy.
  • impossible_navigation: The stop is impossible to reach.
New reasons may be added in the future.

PlanOptimizationOperationMetadata

Ƭ PlanOptimizationOperationMetadata: Object

Metadata about the plan optimization operation.

Example

{
"startedAt": 1631100800,
"finishedAt": 1631101600,
"canceled": false,
"targetPlanId": "plans/zeOCJaJCzZhpKVCVAC9o",
"startedBy": "api"
}

Type declaration

NameTypeDescription
startedAtnumberTimestamp in seconds of when the operation was started.
finishedAtnumber | nullTimestamp in seconds of when the operation was finished, if it is finished.
canceledbooleanWhether the operation was cancelled or not.
targetPlanIdPlanIdThe target plan's unique identifier in the API.
startedBy"api" | "dispatcher" | stringWho started the operation.
  • api: The operation was started by an API call.
  • dispatcher: The operation was started by a dispatcher.
New values may be added in the future.