Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SampleService.html

Large diffs are not rendered by default.

61 changes: 35 additions & 26 deletions SampleService.spec
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,46 @@ module SampleService {
user as_user;
} CreateDataLinkParams;

/* A data link from a KBase workspace object to a sample.

upa - the workspace UPA of the linked object.
dataid - the dataid of the linked data, if any, within the object. If omitted the
entire object is linked to the sample.
id - the sample id.
version - the sample version.
node - the sample node.
createdby - the user that created the link.
created - the time the link was created.
expiredby - the user that expired the link, if any.
expired - the time the link was expired, if at all.
*/
typedef structure {
ws_upa upa;
data_id dataid;
sample_id id;
version version;
node_id node;
user createdby;
timestamp created;
user expiredby;
timestamp expired;
} DataLink;

/* create_data_link results.

new_link - the new link.
*/
typedef structure {
DataLink new_link;
} CreateDataLinkResults;

/* Create a link from a KBase Workspace object to a sample.

The user must have admin permissions for the sample and write permissions for the
Workspace object.
*/
funcdef create_data_link(CreateDataLinkParams params) returns() authentication required;
funcdef create_data_link(CreateDataLinkParams params) returns(CreateDataLinkResults results)
authentication required;

/* expire_data_link parameters.

Expand Down Expand Up @@ -307,31 +341,6 @@ module SampleService {
boolean as_admin;
} GetDataLinksFromSampleParams;

/* A data link from a KBase workspace object to a sample.

upa - the workspace UPA of the linked object.
dataid - the dataid of the linked data, if any, within the object. If omitted the
entire object is linked to the sample.
id - the sample id.
version - the sample version.
node - the sample node.
createdby - the user that created the link.
created - the time the link was created.
expiredby - the user that expired the link, if any.
expired - the time the link was expired, if at all.
*/
typedef structure {
ws_upa upa;
data_id dataid;
sample_id id;
version version;
node_id node;
user createdby;
timestamp created;
user expiredby;
timestamp expired;
} DataLink;

/* get_data_links_from_sample results.

links - the links.
Expand Down
26 changes: 26 additions & 0 deletions lib/SampleService/SampleServiceClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ def create_data_link(self, params, context=None):
(A boolean value, 0 for false, 1 for true.), parameter "as_admin"
of type "boolean" (A boolean value, 0 for false, 1 for true.),
parameter "as_user" of type "user" (A user's username.)
:returns: instance of type "CreateDataLinkResults" (create_data_link
results. new_link - the new link.) -> structure: parameter
"new_link" of type "DataLink" (A data link from a KBase workspace
object to a sample. upa - the workspace UPA of the linked object.
dataid - the dataid of the linked data, if any, within the object.
If omitted the entire object is linked to the sample. id - the
sample id. version - the sample version. node - the sample node.
createdby - the user that created the link. created - the time the
link was created. expiredby - the user that expired the link, if
any. expired - the time the link was expired, if at all.) ->
structure: parameter "upa" of type "ws_upa" (A KBase Workspace
service Unique Permanent Address (UPA). E.g. 5/6/7 where 5 is the
workspace ID, 6 the object ID, and 7 the object version.),
parameter "dataid" of type "data_id" (An id for a unit of data
within a KBase Workspace object. A single object may contain many
data units. A dataid is expected to be unique within a single
object. Must be less than 255 characters.), parameter "id" of type
"sample_id" (A Sample ID. Must be globally unique. Always assigned
by the Sample service.), parameter "version" of type "version"
(The version of a sample. Always > 0.), parameter "node" of type
"node_id" (A SampleNode ID. Must be unique within a Sample and be
less than 255 characters.), parameter "createdby" of type "user"
(A user's username.), parameter "created" of type "timestamp" (A
timestamp in epoch milliseconds.), parameter "expiredby" of type
"user" (A user's username.), parameter "expired" of type
"timestamp" (A timestamp in epoch milliseconds.)
"""
return self._client.call_method('SampleService.create_data_link',
[params], self._service_ver, context)
Expand Down
39 changes: 37 additions & 2 deletions lib/SampleService/SampleServiceImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SampleService:
######################################### noqa
VERSION = "0.1.0-alpha14"
GIT_URL = "https://github.com/mrcreosote/sample_service.git"
GIT_COMMIT_HASH = "6a9a9f940e9da95ef926485b7a94555657ceb94e"
GIT_COMMIT_HASH = "645eb0a62d2435761d74ab348adc0ac51eb69ef7"

#BEGIN_CLASS_HEADER
#END_CLASS_HEADER
Expand Down Expand Up @@ -387,23 +387,58 @@ def create_data_link(self, ctx, params):
(A boolean value, 0 for false, 1 for true.), parameter "as_admin"
of type "boolean" (A boolean value, 0 for false, 1 for true.),
parameter "as_user" of type "user" (A user's username.)
:returns: instance of type "CreateDataLinkResults" (create_data_link
results. new_link - the new link.) -> structure: parameter
"new_link" of type "DataLink" (A data link from a KBase workspace
object to a sample. upa - the workspace UPA of the linked object.
dataid - the dataid of the linked data, if any, within the object.
If omitted the entire object is linked to the sample. id - the
sample id. version - the sample version. node - the sample node.
createdby - the user that created the link. created - the time the
link was created. expiredby - the user that expired the link, if
any. expired - the time the link was expired, if at all.) ->
structure: parameter "upa" of type "ws_upa" (A KBase Workspace
service Unique Permanent Address (UPA). E.g. 5/6/7 where 5 is the
workspace ID, 6 the object ID, and 7 the object version.),
parameter "dataid" of type "data_id" (An id for a unit of data
within a KBase Workspace object. A single object may contain many
data units. A dataid is expected to be unique within a single
object. Must be less than 255 characters.), parameter "id" of type
"sample_id" (A Sample ID. Must be globally unique. Always assigned
by the Sample service.), parameter "version" of type "version"
(The version of a sample. Always > 0.), parameter "node" of type
"node_id" (A SampleNode ID. Must be unique within a Sample and be
less than 255 characters.), parameter "createdby" of type "user"
(A user's username.), parameter "created" of type "timestamp" (A
timestamp in epoch milliseconds.), parameter "expiredby" of type
"user" (A user's username.), parameter "expired" of type
"timestamp" (A timestamp in epoch milliseconds.)
"""
# ctx is the context object
# return variables are: results
#BEGIN create_data_link
duid, sna, update = _create_data_link_params(params)
as_admin, user = _get_admin_request_from_object(params, 'as_admin', 'as_user')
_check_admin(
self._user_lookup, ctx[_CTX_TOKEN], _AdminPermission.FULL,
# pretty annoying to test ctx.log_info is working, do it manually
'create_data_link', ctx.log_info, as_user=user, skip_check=not as_admin)
self._samples.create_data_link(
link = self._samples.create_data_link(
user if user else _UserID(ctx[_CTX_USER]),
duid,
sna,
update,
as_admin=as_admin)
results = {'new_link': _links_to_dicts([link])[0]}
#END create_data_link

# At some point might do deeper type checking...
if not isinstance(results, dict):
raise ValueError('Method create_data_link return value ' +
'results is not type dict as required.')
# return the results
return [results]

def expire_data_link(self, ctx, params):
"""
Expire a link from a KBase Workspace object.
Expand Down
Loading