Resources#
Resources
Represents the collection of resources stored in a vessel, stage or part.
Created by calling GET /space-center/vessel/(id)/resources,
POST /space-center/stage/(id)/resources, GET /space-center/editor-vessel/(id)/resources
or GET /space-center/part/(id)/resources.
A Resources object is passed and returned as its identifier, a number. A path that acts on
an object takes it as (id).
- GET /space-center/resources/(id)/all#
All the individual resources that can be stored.
- Parameters:
id – The identifier of the Resources object.
- Response JSON Object:
value (list<SpaceCenter.Resource>)
- POST /space-center/resources/(id)/with-resource#
All the individual resources with the given name that can be stored.
- Parameters:
id – The identifier of the Resources object.
- Request JSON Object:
name (string)
- Response JSON Object:
value (list<SpaceCenter.Resource>)
- GET /space-center/resources/(id)/names#
A list of resource names that can be stored.
- Parameters:
id – The identifier of the Resources object.
- Response JSON Object:
value (list<string>)
- POST /space-center/resources/(id)/has-resource#
Check whether the named resource can be stored.
- Parameters:
id – The identifier of the Resources object.
- Request JSON Object:
name (string) – The name of the resource.
- Response JSON Object:
value (bool)
- POST /space-center/resources/(id)/amount#
Returns the amount of a resource that is currently stored.
- Parameters:
id – The identifier of the Resources object.
- Request JSON Object:
name (string) – The name of the resource.
- Response JSON Object:
value (float)
- POST /space-center/resources/(id)/max#
Returns the amount of a resource that can be stored.
- Parameters:
id – The identifier of the Resources object.
- Request JSON Object:
name (string) – The name of the resource.
- Response JSON Object:
value (float)
- POST /space-center/resources/density#
Returns the density of a resource, in \(\mathrm{kg/l}\).
- Request JSON Object:
name (string) – The name of the resource.
- Response JSON Object:
value (float)
- POST /space-center/resources/flow-mode#
Returns the flow mode of a resource.
- Request JSON Object:
name (string) – The name of the resource.
- Response JSON Object:
value (SpaceCenter.ResourceFlowMode)
- GET /space-center/resources/(id)/enabled#
Whether use of all the resources are enabled.
Note
This is
trueif all of the resources are enabled. If any of the resources are not enabled, this isfalse.- Parameters:
id – The identifier of the Resources object.
- Response JSON Object:
value (bool)
- PUT /space-center/resources/(id)/enabled#
Whether use of all the resources are enabled.
Note
This is
trueif all of the resources are enabled. If any of the resources are not enabled, this isfalse.- Parameters:
id – The identifier of the Resources object.
- Request JSON Object:
value (bool) – The new value.
Resource
An individual resource stored within a part. Created using methods in the Resources class.
A Resource object is passed and returned as its identifier, a number. A path that acts on
an object takes it as (id).
- GET /space-center/resource/(id)/name#
The name of the resource.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (string)
- GET /space-center/resource/(id)/part#
The part containing the resource.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (SpaceCenter.Part)
- GET /space-center/resource/(id)/amount#
The amount of the resource that is currently stored in the part.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (float)
- GET /space-center/resource/(id)/max#
The total amount of the resource that can be stored in the part.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (float)
- GET /space-center/resource/(id)/density#
The density of the resource, in \(\mathrm{kg/l}\).
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (float)
- GET /space-center/resource/(id)/flow-mode#
The flow mode of the resource.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (SpaceCenter.ResourceFlowMode)
- GET /space-center/resource/(id)/enabled#
Whether use of this resource is enabled.
- Parameters:
id – The identifier of the Resource object.
- Response JSON Object:
value (bool)
- PUT /space-center/resource/(id)/enabled#
Whether use of this resource is enabled.
- Parameters:
id – The identifier of the Resource object.
- Request JSON Object:
value (bool) – The new value.
ResourceTransfer
Transfer resources between parts.
A ResourceTransfer object is passed and returned as its identifier, a number. A path that acts on
an object takes it as (id).
- POST /space-center/resource-transfer/start#
Start transferring a resource transfer between a pair of parts. The transfer will move at most max_amount units of the resource, depending on how much of the resource is available in the source part and how much storage is available in the destination part. Use
GET /space-center/resource-transfer/(id)/completeto check if the transfer is complete. UseGET /space-center/resource-transfer/(id)/amountto see how much of the resource has been transferred.Note
Use
POST /space-center/resource-transfer/(id)/cancelto stop the transfer before it finishes; a canceled transfer is marked as complete. UsePOST /space-center/resource-transfer/(id)/removeto release the memory the server holds for a transfer that is done with. A transfer is stopped and removed if the client that started it disconnects, or if the flight it runs in is left.- Request JSON Object:
from_part (SpaceCenter.Part) – The part to transfer to.
to_part (SpaceCenter.Part) – The part to transfer from.
resource (string) – The name of the resource to transfer.
max_amount (float) – The maximum amount of resource to transfer.
- Response JSON Object:
value (SpaceCenter.ResourceTransfer)
- POST /space-center/resource-transfer/(id)/cancel#
Cancel the transfer. No more of the resource is moved and
GET /space-center/resource-transfer/(id)/completebecomes true.- Parameters:
id – The identifier of the ResourceTransfer object.
- POST /space-center/resource-transfer/(id)/remove#
Remove the transfer, releasing the memory the server holds for it. The transfer is canceled if it has not finished.
Note
Any further use of this object throws an exception. A transfer that is left is held until the parts it runs between are gone, the flight it runs in is left, or the client that started it disconnects, whichever comes first; the first of those may be the rest of the flight away.
- Parameters:
id – The identifier of the ResourceTransfer object.
- GET /space-center/resource-transfer/(id)/amount#
The amount of the resource that has been transferred.
- Parameters:
id – The identifier of the ResourceTransfer object.
- Response JSON Object:
value (float)
- GET /space-center/resource-transfer/(id)/complete#
Whether the transfer has completed. Also becomes true if the transfer is canceled by calling
POST /space-center/resource-transfer/(id)/cancel.- Parameters:
id – The identifier of the ResourceTransfer object.
- Response JSON Object:
value (bool)
ResourceFlowMode
The way in which a resource flows between parts. See POST /space-center/resources/flow-mode.
Passed and returned as the name of one of its values:
"vessel"The resource flows to any part in the vessel. For example, electric charge.
"stage"The resource flows from parts in the first stage, followed by the second, and so on. For example, mono-propellant.
"adjacent"The resource flows between adjacent parts within the vessel. For example, liquid fuel or oxidizer.
"none"The resource does not flow. For example, solid fuel.