Package comodit_client :: Package api :: Module entity :: Class Entity

Class Entity


Represents an entity managed by a ComodIT server. An entity instance may be used to create or alter a remote entity. In most situations, this will imply the update of object's state and then a call to respectively create or update in order to 'commit' changes to the server. Note that the renaming of an entity is a particular case of update and should be done by calling rename. Object's state is generally accessed with properties.

An entity instance should always be obtained through a collection, either by calling get or a factory method (generally, new). This ensures that the entity is associated to a collection, which is mandatory in order to interact with a ComodIT server. You may instantiate an entity without collection, in which case you will still be able to alter object's state. However, it will be impossible to commit these changes unless collection field is set.

Instance Methods
 
__init__(self, collection, json_data=None)
Creates an instance of entity.
 
refresh(self, parameters={})
Refreshes the state of this object with data retrieved from ComodIT server.
 
rename(self, new_name)
Renames remote entity.
 
update(self, force=False)
Updates remote entity with this object's state.
 
create(self, parameters={})
Creates a new entity on the server using this object's state for initialization.
 
delete(self, parameters={})
Deletes associated remote entity from the server.
 
show(self, as_json=False, indent=0)
Prints this entity's state to standard output.
 
dump(self, dest_folder)
Dumps the state of this object in given folder.
 
load(self, input_folder)
Loads the state of this object from files contained by given folder.

Inherited from util.json_wrapper.JsonWrapper: dump_json, get_json, get_real_json, load_json, print_json, set_json

Inherited from object: __long__, __native__, __nonzero__, __unicode__, next

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
string url
URL of remote entity on ComodIT server.
Client client
ComodIT client.
string name
Name of this entity.
string uuid
ComodIT's UUID for this entity.
string identifier
Identifier of the entity.
string label
A very short description of the entity.
string description
The description of this entity.

Inherited from object: __class__

Method Details

__init__(self, collection, json_data=None)
(Constructor)

 

Creates an instance of entity. Note that Entity class should never be instantiated directly.

Parameters:
  • collection (Collection) - A collection.
  • json_data (dict) - A JSON representation of entity's state.
Overrides: object.__init__

refresh(self, parameters={})

 

Refreshes the state of this object with data retrieved from ComodIT server.

Parameters:
  • parameters (dict of strings) - Query parameters to transmit to ComodIT server.
Raises:

rename(self, new_name)

 

Renames remote entity. Note that remote entity will be updated if other fields where modified. For example, if you change entity's description and then call this method, description of remote entity will be updated in addition to its name.

Parameters:
  • new_name (string) - Entity's new name.
Raises:

update(self, force=False)

 

Updates remote entity with this object's state.

Parameters:
  • force (bool) - Update is forced (optional)
Raises:

create(self, parameters={})

 

Creates a new entity on the server using this object's state for initialization.

Raises:

delete(self, parameters={})

 

Deletes associated remote entity from the server.

Raises:

show(self, as_json=False, indent=0)

 

Prints this entity's state to standard output. The state may be indented. It can also be displayed directly in JSON representation.

Parameters:
  • as_json (bool) - If True, entity's state is displayed in JSON. Otherwise, it is displayed in a more user-friendly way.
  • indent (int) - The number of spaces to put in front of each displayed line (only if as_json is False).

dump(self, dest_folder)

 

Dumps the state of this object in given folder. Several files may be created in destination folder, as well as sub-folders.

Parameters:
  • dest_folder (string) - The path to destination folder

load(self, input_folder)

 

Loads the state of this object from files contained by given folder.

Parameters:
  • input_folder (string) - Path to source folder

Property Details

url

URL of remote entity on ComodIT server. This URL is relative to ComodIT server's API URL and should not start with a slash.

Get Method:
unreachable.url(self) - URL of remote entity on ComodIT server.
Type:
string

client

ComodIT client.

Get Method:
unreachable.client(self) - ComodIT client.
Type:
Client

name

Name of this entity.

Get Method:
unreachable.name(self) - Name of this entity.
Set Method:
unreachable.name(self, name) - Sets the name of this entity.
Type:
string

uuid

ComodIT's UUID for this entity.

Get Method:
unreachable.uuid(self) - ComodIT's UUID for this entity.
Type:
string

identifier

Identifier of the entity. The identifier is unique in entity's collection and can therefore be used to get the entity. This value is generally entity's name but may also be the UUID or another field depending on entity type.

Get Method:
unreachable.identifier(self) - Identifier of the entity.
Type:
string

label

A very short description of the entity. This value generally includes entity's identifier.

Get Method:
unreachable.label(self) - A very short description of the entity.
Type:
string

description

The description of this entity.

Get Method:
unreachable.description(self) - The description of this entity.
Set Method:
unreachable.description(self, description) - Sets the description of this entity.
Type:
string