Skip to main content

API Reference

Resources

State

Key/value in-memory state for the simulator.

Use the preflight method token(key) to obtain a token that can be used to reference the value of the state at runtime.

During deployment (i.e. cloud.OnDeploy or cloud.Service startup), you must call the inflight method set(key, value) to set the runtime value. The value will be available at runtime through the inflight method get(key) (or resolved as a token).

See tests for examples.

Initializers

bring sim;

new sim.State();
NameTypeDescription

Methods

Preflight Methods
NameDescription
tokenReturns a token that can be used to retrieve the value of the state after the simulation has run.
toSimulatorConvert this resource to a resource schema for the simulator.
Inflight Methods
NameDescription
getGets the runtime state of this object.
setSets the state of runtime a runtime object.
tryGetChecks if runtime state exists for this object and returns it's value.

token
token(key: str): str

Returns a token that can be used to retrieve the value of the state after the simulation has run.

keyRequired
  • Type: str

The object key retrieved through the inflight state.get().


toSimulator
toSimulator(): BaseResourceSchema

Convert this resource to a resource schema for the simulator.

get
get(key: str): Json

Gets the runtime state of this object.

Throws if there is no value for the given key.

keyRequired
  • Type: str

The object's key.


set
set(key: str, value: Json): void

Sets the state of runtime a runtime object.

keyRequired
  • Type: str

The object's key.


valueRequired

The object's value.


tryGet
tryGet(key: str): Json

Checks if runtime state exists for this object and returns it's value.

If no value exists, returns nil.

keyRequired
  • Type: str

The object's key.


Properties

NameTypeDescription
nodeconstructs.NodeThe tree node.

nodeRequired
node: Node;
  • Type: constructs.Node

The tree node.


Protocols

ISimulatorResource

Interfaces shared by all polycon implementations (preflight classes) targeting the simulator.

Methods

NameDescription
toSimulatorConvert this resource to a resource schema for the simulator.

toSimulator
toSimulator(): BaseResourceSchema

Convert this resource to a resource schema for the simulator.

Properties

NameTypeDescription
nodeconstructs.NodeThe tree node.

nodeRequired
node: Node;
  • Type: constructs.Node

The tree node.