-
Notifications
You must be signed in to change notification settings - Fork 10
ModelSEED Store Private
Base storage interface layer; not for public use.
DO NOT USE Directly! This class has a complete, unauthenticated access to the datastore. While the datastore is designed to limit the visibility of objects to particular users, this class does nothing to prevent people from accessing data. The "user" is passed into each API function, therefore there is no assumption of security when using this interface. Use ModelSEED::Store instead.
my $PStore = ModelSEED::Store::Private->new(\%)
Initialize a private storage interface object. This accepts a hash reference to configuration details. There are no current configuration options.
These functions manipulate user objects within the storage layer. Since a user must be defined for almost every call into the storage interface, these functions are critical to add, remove or inspect user objects.
$PStore->create_user($user);
Creates a user object. $user
is a ModelSEED::MS::User
object.
$PStore->get_user($username);
Returns a ModelSEED::MS::User
object. If no user is found, returns undef
.
$PStore->delete_user($username);
Removes the user object from the storage interface. Not that this has wide-ranging affects; that user will no longer be able to access objects within the Store. This does not delete objects owned by that user, however.
These functions deal with checking for the existence of, getting and saving objects. In most cases, objects are assumed to be instances of classes under the ModelSEED::MS
hierarchy. For each of these functions, $username
is the user's login name, a string. $type
is a string representing the type of the object, e.g. "biochemistry". $alias
is a string, representing a unique pointer to an object in the datastore. These generally have the form "$username/arbitraryString"
.
$ps->has_object($username, $type, $alias);
Returns a boolean, true if the the object exists in the datastore.
$ps->get_object($username, $type, $alias);
Returns a ModelSEED::MS
object of the type $type
or undef
if no object exists.
$ps->save_object($username, $type, $alias, $object);
Saves $object
, a ModelSEED::MS
object of the correct $type
to the datastore at $alias
. Note that if there was an object already at $alias
, this does not overwrite that object, but changes the reference $alias
to point to the new object, $object
.
$ps->delete_object($username, $type, $alias);
Removes the alias pointer $alias
that points to an object in the datastore. This does not actually remove the object, but it will no longer be accessible via that alias.
These methods are like the Object Methods, except that they return raw Perl data-structures instead of ModelSEED::MS
objects.
$ps->get_data($username, $type, $alias);
Same as get_object
except that it is not marshaled into an object.
Getting a specific object is good, but sometimes we need to query what objects are available. These functions allow for different types of queries against the data store.
$ps->get_aliases_for_type($username, $type);
$ps->get_metadata($username, $type, $alias, $selection);
$ps->set_metadata($username, $type, $alias, $selection, $metadata);
$ps->remove_metadata($username, $type, $alias, $selection);
$ps->find_objects($username, $type, $query);
Returns an iterator which allows you to individually access the objects, or gather them all into an array (interface to come)
Permissions are handled via the "alias" attribute and the following functions. As an overview, any object with an alias like $username/aribtraryString
is "owned" by $username
. That user may perform a save_object
call against the alias. No other users may do this. So we have single-user write-access to objects.
For visibility, by default an object is only visible by the owner. However, using the following functions, an owner may extend visibility to other users. Finally, an object may be "public", visible to all users.
$ps->add_viewer($username, $type, $alias, $viewerUsername);
$username
must be the owner of the object of $type
, $alias
. This extends viewing permissions to $viewerUsername
.
$ps->remove_viewer($username, $type, $alias, $viewerUsername);
$username
must be the owner of the object of $type
, $alias
. This retracts viewing permissions to $viewerUsername
.
$ps->set_public($username, $type, $alias, $bool);
$username
must be the owner of the object of $type
, $alias
. This sets the public bit of the object to $bool
.