Blueprints
Definiton
API Payload
Class
class Blueprint:
"""
A class used to represent a blueprint on the platform
...
Attributes
----------
id : str
The unique identifier of the blueprint, automatically generated by the platform
name : str
The name of the blueprint
category : Category
The category of the blueprint, each category is of type Category class
image : Image
The image of the blueprint
parameters : List[Parameter]
The list of parameters of the blueprint, each parameter is of type Parameter class
interfaces : List[Interface]
The list of interfaces of the blueprint, each interface is of type Interface class
created_by : str
The unique identifier of the user who created the blueprint
property_models : List[PropertyModel]
The list of property models of the blueprint
sensors : List[Sensor]
The list of sensors of the blueprint
created_at : datetime
The date and time when the blueprint was created
updated_at : datetime
The date and time when the blueprint was last updated
"""
id: Optional[str] = None
name: Optional[str] = None
category: Optional[Category] = None
image: Optional[Image] = None
parameters: Optional[List[Parameter]] = None
interfaces: Optional[List[Interface]] = None
created_by: Optional[str] = None
property_models: Optional[List[Any]] = None
sensors: Optional[List[Sensor]] = None
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
Setup
#Altergo parameters to connect with Client
ALTERGO_FACTORY_API= 'https://altergo.io/' #Default Factory API
ALTERGO_IOT_API= 'https://iot.altergo.io/' #Default IOT API
apiKey = "Your API KEY" #API key of the client
model_name='KB Demo' #Blueprint from which assset is made
serial_number='KB Demo_1'#Unique serial number to identify asset
info
API keys are user bound
from altergo_sdk.models.v2 import Blueprint,Parameter
altergoApiKey = apiKey
_client = {
"apiKey": altergoApiKey,
"factory_api": ALTERGO_FACTORY_API,
"iot_api":ALTERGO_IOT_API
}
altergoApi = Client(**_client)
Create
There are no mandatory fields for blueprints appart for the Category. to create a new blueprint on the platform you can use createBlueprint()
#Create a Category, or retrieve one
categoryToCreate = Category
categoryToCreate.name = "New Category"
createdCategory = altergoApi.createCategory(newCategory=categoryToCreate)
blueprintToCreate = Blueprint()
blueprintToCreate.name = "New blueprint"
blueprintToCreate.category = createdCategory
createdBlueprint = altergoApi.createBlueprint(
newBlueprint=blueprintToCreate
)
Get
To get a SIUnit you can use the getBluerpints()
method with a filterBy
argument. In the following snippet we are retrieving the previously created Blueprint.
retrievedBlueprints = getBlueprints(filterBy={"name": "New blueprint"})
caution
This method returns a list
Update
To update an SiUnit you will first need to get it via the getBlueprints()
method and then update it with updateSiUnit()
# Retrieve blueprint to update
retrievedBlueprints = getBlueprints(filterBy={"name": "New blueprint"})
blueprintToUpdate =retrievedBluprints[0]
blueprintToUpdate.name = "Updated blueprint"
#Update blueprint
updatedBlueprint = updateBlueprint(updatedBlueprint = blueprintToUpdate)
Delete
To delete a SiUnit you will first need to get it via the getBlueprints()
method and then delete it with deleteBlueprint()
retrievedBlueprints = getBlueprints(filterBy={"name": "New blueprint"})
blueprintToDelete =retrievedBluprints[0]
response = deleteBlueprint(existingBlueprint = blueprintToDelete)