Module pyinventory.api.equipment

Functions

def add_equipment(client: SymphonyClient, name: str, equipment_type: str, location: Location, properties_dict: Mapping[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]], external_id: Union[str, NoneType] = None) -> Equipment

Create a new equipment in a given location. The equipment will be of the given equipment_type, with the given name and with the given properties. If equipment with this name already exists in this location, then existing equipment is returned.

Args

name : str
new equipment name
equipment_type : str
equipment type name

location ( Location ): location object could be retrieved from - get_location() - add_location()

properties_dict : Mapping[str, PropertyValue]
dictionary of property name to property value
  • str - property name
  • PropertyValue - new value of the same type for this property
external_id : Optional[str]
equipment external ID

Returns

Equipment: You can use the ID to access the equipment from the UI: https://{}.thesymphony.cloud/inventory/inventory?equipment={}

Raises

AssertionException
location contains more than one equipment with the same name or if property value in properties_dict does not match the property type
FailedOperationException
internal inventory error

Example

from datetime import date
equipment = client.add_equipment(
    name="Router X123",
    equipment_type="Router",
    location=location,
    properties_dict={
        "Date Property": date.today(),
        "Lat/Lng Property": (-1.23,9.232),
        "E-mail Property": "user@fb.com",
        "Number Property": 11,
        "String Property": "aa",
        "Float Property": 1.23
    })
def add_equipment_to_position(client: SymphonyClient, name: str, equipment_type: str, existing_equipment: Equipment, position_name: str, properties_dict: Mapping[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]], external_id: Union[str, NoneType] = None) -> Equipment

Create a new equipment inside a given position_name of the given existing_equipment. The equipment will be of the given equipment_type, with the given name and with the given properties. If equipment with this name already exists in this position, then existing equipment is returned.

Args

name : str
new equipment name
equipment_type : str
equipment type name

existing_equipment ( Equipment ): could be retrieved from - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

position_name : str
position name in the equipment type.
properties_dict : Mapping[str, PropertyValue]
dictionary of property name to property value
  • str - property name
  • PropertyValue - new value of the same type for this property
external_id : Optional[str]
equipment external ID

Returns

Equipment object: You can use the ID to access the equipment from the UI: https://{}.thesymphony.cloud/inventory/inventory?equipment={}

Raises

AssertionException
if parent equipment has more than one position with the given name or if property value in properties_dict does not match the property type
FailedOperationException
for internal inventory error

EntityNotFoundError: if existing_equipment does not exist

Example

from datetime import date
equipment = client.add_equipment_to_position(
    name="Card Y123",
    equipment_type="Card",
    existing_equipment=equipment,
    position_name="Pos 1",
    properties_dict={
        "Date Property": date.today(),
        "Lat/Lng Property": (-1.23,9.232),
        "E-mail Property": "user@fb.com",
        "Number Property": 11,
        "String Property": "aa",
        "Float Property": 1.23
    })
def copy_equipment(client: SymphonyClient, equipment: Equipment, dest_location: Location, new_external_id: Union[str, NoneType] = None) -> Equipment

Copy equipment.

Args

equipment ( Equipment ): equipment object to be copied
dest_location ( Location ): destination locatoin to copy to
new_external_id : Optional[str]
equipment external ID

Returns

Equipment object

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment(name="indProdCpy1_AIO", location=location)
new_location = client.get_location({("Country", "LS_IND_Prod")})
copied_equipment = client.copy_equipment(
    equipment=equipment,
    dest_location=new_location,
)
def copy_equipment_in_position(client: SymphonyClient, equipment: Equipment, dest_parent_equipment: Equipment, dest_position_name: str, new_external_id: Union[str, NoneType] = None) -> Equipment

Copy equipment in position.

Args

equipment ( Equipment ): equipment object to be copied
dest_parent_equipment ( Equipment ): parent equipment, destination to copy to
dest_position_name : str
destination position name
new_external_id : Optional[str]
new external ID for equipment

Returns

Equipment object

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment_to_copy = client.get_equipment(name="indProdCpy1_AIO", location=location)
parent_equipment = client.get_equipment(name="parent", location=location)
copied_equipment = client.copy_equipment_in_position(
    equipment=equipment,
    dest_parent_equipment=parent_equipment,
    dest_position_name="destination position name",
)
def delete_all_equipments(client: SymphonyClient) -> NoneType

This function delete all Equipments.

Example

client.delete_all_equipment()
def delete_equipment(client: SymphonyClient, equipment: Equipment) -> NoneType

This function delete Equipment.

Args

equipment ( Equipment ): equipment object

Example

client.delete_equipment(equipment=equipment)
def edit_equipment(client: SymphonyClient, equipment: Equipment, new_name: Union[str, NoneType] = None, new_properties: Union[Dict[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]], NoneType] = None) -> Equipment

Edit existing equipment.

Args

equipment ( Equipment ): equipment object
new_name : Optional[str]
equipment new name
new_properties : Optional[Dict[str, PropertyValue]]
dictionary of property name to property value str - property name PropertyValue - new value of the same type for this property

Returns

Equipment object

Raises

FailedOperationException
internal inventory error

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment(name="indProdCpy1_AIO", location=location)
edited_equipment = client.edit_equipment(
    equipment=equipment,
    new_name="new_name",
    new_properties={"Z AIO - Number": 123},
)
def get_equipment(client: SymphonyClient, name: str, location: Location) -> Equipment

Get equipment by name in a given location.

Args

name : str
equipment name

location ( Location): location object could be retrieved from - get_location() - add_location()

Returns

Equipment object: You can use the ID to access the equipment from the UI: https://{}.thesymphony.cloud/inventory/inventory?equipment={}

Raises

EquipmentIsNotUniqueException
location contains more than one equipment with the same name
EquipmentNotFoundException
the equipment was not found
FailedOperationException
internal inventory error

Example

location = client.get_location([("Country", "LS_IND_Prod_Copy")])
equipment = client.get_equipment("indProdCpy1_AIO", location)
def get_equipment_by_external_id(client: SymphonyClient, external_id: str) -> Equipment

Get equipment by external ID.

Args

external_id : str
equipment external ID

Returns

Equipment object: You can use the ID to access the equipment from the UI: https://{}.thesymphony.cloud/inventory/inventory?equipment={}

Raises

EquipmentIsNotUniqueException
location contains more than one equipment with the same external ID
EntityNotFoundError: the equipment was not found
FailedOperationException
internal inventory error

Example

equipment = client.get_equipment_by_external_id(external_id="123456")
def get_equipment_in_position(client: SymphonyClient, parent_equipment: Equipment, position_name: str) -> Equipment

Get the equipment attached in a given position_name of a given parent_equipment

Args

parent_equipment ( Equipment ): could be retrieved from - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

position_name : str
position name

Returns

Equipment object: You can use the ID to access the equipment from the UI: https://{}.thesymphony.cloud/inventory/inventory?equipment={}

Raises

AssertionException
if parent equipment has more than one position with the given name, or none with this name or if the position is not occupied.
FailedOperationException
for internal inventory error

EntityNotFoundError: if parent_equipment does not exist

Example

location = client.get_location([("Country", "LS_IND_Prod_Copy")])
p_equipment = client.get_equipment("indProdCpy1_AIO", location)
equipment = client.get_equipment_in_position(p_equipment, "some_position")
def get_equipment_properties(client: SymphonyClient, equipment: Equipment) -> Dict[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]]

Get specific equipment properties.

Args

equipment ( Equipment ): equipment object

Returns

Dict[str, PropertyValue]
dictionary of property name to property value
  • str - property name
  • PropertyValue - new value of the same type for this property

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment("indProdCpy1_AIO", location)
properties = client.get_equipment_properties(equipment=equipment)
def get_equipment_type_of_equipment(client: SymphonyClient, equipment: Equipment) -> EquipmentType

This function returns equipment type object of equipment.

Args

equipment ( Equipment ): equipment object

Returns

EquipmentType object

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment(name="indProdCpy1_AIO", location=location)
equipment_type = client.get_equipment_type_of_equipment(equipment=equipment)
def get_equipments_by_location(client: SymphonyClient, location_id: str) -> List[Equipment]

Get equipments by ID of specific location.

Args

location_id : str
location ID

Returns

List[ pyinventory.common.data_class.Equipment ]: List of found equipments

Raises

EntityNotFoundError: location with this ID does not exist

Example

equipments = client.get_equipments_by_location(location_id="60129542651")
def get_equipments_by_type(client: SymphonyClient, equipment_type_id: str) -> List[Equipment]

Get equipments by ID of specific type.

Args

equipment_type_id : str
equipment type ID

Returns

List[ pyinventory.common.data_class.Equipment ]: List of found equipments

Raises

EntityNotFoundError: equipment type with this ID does not exist

Example

equipments = client.get_equipments_by_type(equipment_type_id="34359738369")
def get_or_create_equipment(client: SymphonyClient, name: str, equipment_type: str, location: Location, properties_dict: Mapping[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]], external_id: Union[str, NoneType] = None) -> Equipment

This function checks equipment existence by name in specific location, in case it is not found by name, creates one.

Args

name : str
equipment name
equipment_type : str
equipment type name

location ( Location ): location object could be retrieved from - get_location() - add_location()

properties_dict : Mapping[str, PropertyValue]
dictionary of property name to property value
  • str - property name
  • PropertyValue - new value of the same type for this property
external_id : Optional[str]
equipment external ID

Returns

Equipment object

Raises

AssertionException
location contains more than one equipment with the same name or if property value in properties_dict does not match the property type
FailedOperationException
internal inventory error

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_or_create_equipment(
    name="indProdCpy1_AIO",
    equipment_type="router",
    location=location,
    properties_dict={
        "Date Property": date.today(),
        "Lat/Lng Property": (-1.23,9.232),
        "E-mail Property": "user@fb.com",
        "Number Property": 11,
        "String Property": "aa",
        "Float Property": 1.23
    })
def get_or_create_equipment_in_position(client: SymphonyClient, name: str, equipment_type: str, existing_equipment: Equipment, position_name: str, properties_dict: Mapping[str, Union[datetime.date, float, int, str, bool, Tuple[float, float]]], external_id: Union[str, NoneType] = None) -> Equipment

This function checks equipment existence by name in specific location, in case it is not found by name, creates one.

Args

name : str
equipment name
equipment_type : str
equipment type name
existing_equipment ( Equipment ): existing equipment
position_name : str
position name
properties_dict : Mapping[str, PropertyValue]
dictionary of property name to property value
  • str - property name
  • PropertyValue - new value of the same type for this property
external_id : Optional[str]
equipment external ID

Returns

Equipment object

Raises

AssertionException
location contains more than one equipment with the same name or if property value in properties_dict does not match the property type
FailedOperationException
internal inventory error

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
e_equipment = client.get_equipment(name="indProdCpy1_AIO", location=location)
equipment_in_position = client.get_or_create_equipment_in_position(
    name="indProdCpy1_AIO",
    equipment_type="router",
    existing_equipment=e_equipment,
    position_name="some_position",
    properties_dict={
        "Date Property": date.today(),
        "Lat/Lng Property": (-1.23,9.232),
        "E-mail Property": "user@fb.com",
        "Number Property": 11,
        "String Property": "aa",
        "Float Property": 1.23
    })
def search_for_equipments(client: SymphonyClient, limit: int) -> Tuple[List[Equipment], int]

Search for equipments.

Args

limit : int
search result limit

Returns

Tuple[List[ pyinventory.common.data_class.Equipment ], int]

Example

client.search_for_equipments(limit=10)