...
An asset is metadata plus content (content is the file) and namespaces are a virtual hierarchy of assets.
Authentication and Delegation
If you are doing a lot of scripting connecting to a Mediaflux remote, it is undesirable to populate lots of plain text files with your login details. This is where delegation becomes useful. Delegate credentials are binary tokens that reside in the home directory of the user that creates them. These credentials automatically perform a login on your behalf when interacting with Pawsey data storage. Here's an example of creating a delegate credential that lasts for approximately one month:
Code Block |
---|
pawsey:/projects>delegate 30
Delegating until: 01-Jun-2016 14:13:15
pawsey:/projects>exit |
From now on, until the delegate expires, there is no need to login to data storage on the machine where this was run. Any pshell sessions that are run will automatically use the delegate to login.
Finally, to destroy all delegate credentials, use:
Code Block |
---|
pawsey:/projects>delegate off
Delegate credentials removed. |
...
title | Renewing the delegate token before it expires |
---|
...
for assets.
Asset metadata
Standard metadata
...
To restrict the search to look only in /projects/Data Teammyproject, use:
Code Block |
---|
asset.query :where "namespace='/projects/myproject' and name='*.PNG'" |
...
If you wish to search /projects/Data Team myproject and all folders underneath it, use:
...
For example, to count all PNG files stored in the entire Data Team project or and then to sum their sizes you would run, respectively:
Code Block |
---|
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action count asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action sum :xpath content/size |
...
For example, suppose we wanted to move all PNG files to a new location /projects/Data Teammyproject/png-files we would use:
Code Block |
---|
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action pipe :service -name asset.move < :namespace /projects/Data Teammyproject/png-files > |
Here our action is to pipe the results to another service call, in this case an asset.move, which is a service call that takes the required destination namespace argument in a shorthand XML document.
Naturally, similar constructions could be used to simply delete these files instead:
Code Block |
---|
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action pipe :service -name asset.destroy |
...
To change the name of the sean folder1 namespace to sean2 folder2 use:
Code Block |
---|
asset.namespace.rename :namespace /projects/Data Teammyproject/seanfolder1 :name sean2folder2 |
To move the namespace sean to folder1 to a new parent location use:
Code Block |
---|
asset.namespace.move :namespace /projects/Data Teammyproject/seanfolder1 :to /projects/Data Teammyproject/adminsnewparent |
To delete a namespace entirely, use:
Code Block |
---|
asset.namespace.destroy :namespace /projects/Data Teammyproject/seanfolder1 |