SIAM::Driver::Simple - a reference implementation of SIAM Driver
The driver does not connect to any external databases. Instead, it reads all the SIAM objects from its YAML data file.
The top level element in the data file is expected to be an array of objects that are contained in the SIAM root. The following object classes are expected to be contained by the root object:
SIAM::Contract
SIAM::AccessScope
SIAM::User
SIAM::Device
SIAM::Attribute
Each object definition may have an entry with the key _contains_ which points to an array of contained objects. For example, an SIAM::Contract object is expected to contain one or more SIAM::Service objects.
_contains_
SIAM::Service
All other keys in the object entry define the object attributes. The values are expected to be strings and numbers. The data file should define all the attributes, including siam.object.id and siam.object.class.
siam.object.id
siam.object.class
See the file t/driver-simple.data.yaml in SIAM package distribution for reference.
The following methods are required by SIAM::Documentation::DriverSpec.
SIAM::Documentation::DriverSpec
Instantiates a new driver object. The method expects a hashref containing the attributes, as follows:
Logger
The logger object is supplied by SIAM.
Datafile
Full path of the YAML data file which defines all the objects for this driver.
Reads the YAML data file
Disconnects the driver from its underlying databases.
$status = $driver->fetch_attributes($attrs);
Retrieve the object by ID and populate the hash with object attributes.
$value = $driver->fetch_computable($id, $key);
Retrieve a computable. Return empty string if unsupported.
$ids = $driver->fetch_contained_object_ids($id, 'SIAM::Contract', { 'match_attribute' => [ 'siam.object.access_scope_id', ['SCOPEID01', 'SCOPEID02'] ] } );
Retrieve the contained object IDs.
$classes = $driver->fetch_contained_classes($id);
Returns arrayref with class names.
$attr = $driver->fetch_container($id);
Retrieve the container ID and class.
$list = $driver->fetch_object_ids_by_attribute($classname, $attr, $value);
Returns a list of object IDs which match the attribute value.
The method does nothing in this driver, but only issues a debug message.
The method returns an arrayref with all known attribute names.
The following methods are not in the Specification.
Prints a debug message to the logger.
Prints an error message to the logger.
Takes an object ID and returns true if such object is present in the database.
$data = SIAM::Driver::Simple->clone_data($siam, $callback);
The method takes a SIAM object and a callback reference. It walks through the SIAM data and produces a clone suitable for storing into a YAML file and re-using with SIAM::Driver::Simple.
SIAM::Driver::Simple
The callback is a sub reference which is supplied with the object ID as an argument. Only the objects which result in true value are being cloned.
The method is usable for producing a test data out of productive system.
SIAM::Documentation::DriverSpec, YAML, Log::Handler
To install SIAM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SIAM
CPAN shell
perl -MCPAN -e shell install SIAM
For more information on module installation, please visit the detailed CPAN module installation guide.