Skip to content
Draft
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
9 changes: 8 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const BrAPI = require('./BrAPI.js');

## How it Works

BrAPI.js has been designed to allow for many simultaneous and interdependent calls to BrAPI to be performed asynchronously. In order to do this, data are managed by a class of objects called **BrAPINodes**. Nodes are organized into a [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph "Directed Acyclic Graph") which represents dependancies. Each node represents a transformation on the data. Basic transformations include [fork](#fork), [join](#join), [map](#map), [reduce](#reduce), and [filter](#filter). BrAPI calls are special transformations. Each BrAPI call can be either a fork (calls returning array data) or a map (calls returning single objects). Data interacts through nodes via tasks. When a task completes, it triggers the creation of new task(s) in all child nodes. With the exception of [reduce](#reduce), the operations can be performed independently on each datum. This means one datum can be transformed across multiple nodes while another moves more slowly.
BrAPI.js has been designed to allow for many simultaneous and interdependent calls to BrAPI to be performed asynchronously. In order to do this, data are managed by a class of objects called **BrAPINodes**. Nodes are organized into a [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph "Directed Acyclic Graph") which represents dependencies. Each node represents a transformation on the data. Basic transformations include [fork](#fork), [join](#join), [map](#map), [reduce](#reduce), and [filter](#filter). BrAPI calls are special transformations. Each BrAPI call can be either a fork (calls returning array data) or a map (calls returning single objects). Data interacts through nodes via tasks. When a task completes, it triggers the creation of new task(s) in all child nodes. With the exception of [reduce](#reduce), the operations can be performed independently on each datum. This means one datum can be transformed across multiple nodes while another moves more slowly.

## Usage Reference

Expand Down Expand Up @@ -206,6 +206,10 @@ This method registers a callback function which is called once a node has loaded
| _node_.attributevalues_modify(_params_,...)||`/attributevalues/{attributeValueDbId}` | `PUT` |
| _node_.attributevalues_store(_params_,...)||`/attributevalues` | `POST` |
| _node_.attributevalues(_params_,...)||`/attributevalues` | `GET` |
| _node_.batchdeletes_modify(_params_,...)||`/batchDeletes/{batchDeleteDbId}` | `PUT` |
| _node_.batchdeletes_store(_params_,...)||`/batchDeletes` | `POST` |
| _node_.batchdeletes_detail(_params_,...)||`/batchDeletes/{batchDeleteDbId}` | `GET` |
| _node_.batchdeletes_delete(_params_,...)||`/batchDeletes/{batchDeleteDbId}?hardDelete=true` | `DELETE` |
| _node_.breedingmethods_detail(_params_,...) | `/breedingmethods/{breedingMethodDbId}` | `/breedingmethods/{breedingMethodDbId}` | `GET` |
| _node_.breedingmethods(_params_,...) | `/breedingmethods` | `/breedingmethods` | `GET` |
| _node_.calls(_params_,...) | `/calls` (server info) | | `GET` |
Expand Down Expand Up @@ -241,6 +245,7 @@ This method registers a callback function which is called once a node has loaded
| _node_.images(_params_,...) | `/images` | `/images` | `GET` |
| _node_.lists_detail(_params_,...) | `/lists/{listDbId}` | `/lists/{listDbId}` | `GET` |
| _node_.lists_modify(_params_,...)||`/lists/{listDbId}` | `PUT` |
| _node_.lists_delete(_params_,...)||`/lists/{listDbId}?hardDelete=true` | `DELETE` |
| _node_.lists_items_store(_params_,...)||`/lists/{listDbId}/items` | `POST` |
| _node_.lists_store(_params_,...)||`/lists` | `POST` |
| _node_.lists(_params_,...) | `/lists` | `/lists` | `GET` |
Expand Down Expand Up @@ -301,6 +306,7 @@ This method registers a callback function which is called once a node has loaded
| _node_.referencesets(_params_,...)||`/referencesets` | `GET` |
| _node_.samples_detail(_params_,...) | `/samples/{sampleId}` | `/samples/{sampleDbId}` | `GET` |
| _node_.samples_modify(_params_,...)||`/samples/{sampleDbId}` | `PUT` |
| _node_.samples_delete(_params_,...)||`/samples/{sampleDbId}?hardDelete=true` | `DELETE` |
| _node_.samples_store(_params_,...)||`/samples` | `POST` |
| _node_.samples(_params_,...) | `/samples` | `/samples` | `GET` |
| _node_.scales_detail(_params_,...) | `/scales/{scaleDbId}` | `/scales/{scaleDbId}` | `GET` |
Expand Down Expand Up @@ -362,6 +368,7 @@ This method registers a callback function which is called once a node has loaded
| _node_.traits(_params_,...) | `/traits` | `/traits` | `GET` |
| _node_.trials_detail(_params_,...) | `/trials/{trialDbId}` | `/trials/{trialDbId}` | `GET` |
| _node_.trials_modify(_params_,...)||`/trials/{trialDbId}` | `PUT` |
| _node_.trials_delete(_params_,...) | `/trials/{trialDbId}` | `/trials/{trialDbId}?hardDelete=true` | `DELETE` |
| _node_.trials_store(_params_,...)||`/trials` | `POST` |
| _node_.trials(_params_,...) | `/trials` | `/trials` | `GET` |
| _node_.variables_datatypes(_params_,...) | `/variables/datatypes` | | `GET` |
Expand Down
1 change: 1 addition & 0 deletions src/brapi_methods.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./brapi_methods/allelematrices";
export * from "./brapi_methods/attributes";
export * from "./brapi_methods/attributevalues";
export * from "./brapi_methods/batchdeletes";
export * from "./brapi_methods/breedingmethods";
export * from "./brapi_methods/calls";
export * from "./brapi_methods/callsets";
Expand Down
79 changes: 79 additions & 0 deletions src/brapi_methods/batchdeletes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/** `GET /batchDeletes/{batchDeleteDbId}`
* @alias BrAPINode.prototype.batchDeletes
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function batchdeletes_detail (params,behavior){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/batchDeletes/{batchDeleteDbId}',
'params': params,
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
}

/** `PUT /batchDeletes/{batchDeleteDbId} `
* @alias BrAPINode.prototype.batchDeletes_modify
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function batchdeletes_modify (params,behavior){
var call = {
'defaultMethod': 'put',
'urlTemplate': '/batchDeletes/{batchDeleteDbId}',
'params': params,
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
}

/** `POST /batchDeletes`
* @alias BrAPINode.prototype.batchdeletes_store
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function batchdeletes_store (params,behavior){
var call = {
'defaultMethod': 'post',
'urlTemplate': '/batchDeletes',
'params': params,
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
}

/** `DELETE /batchDeletes/{batchDeleteDbId}?hardDelete=true`
* @alias BrAPINode.prototype.batchdeletes_delete
* @param {Object} params Parameters to provide to the call
* @param {String} params.batchDeleteDbId batchDeleteDbId
* @param {hardDelete} params.hardDelete=true whether is a hard or soft delete
* @return {BrAPI_Behavior_Node}
*/
export function batchdeletes_delete(params){
var call = {
'defaultMethod': 'delete',
'urlTemplate': '/batchDeletes/{batchDeleteDbId}?hardDelete=true',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
};
24 changes: 22 additions & 2 deletions src/brapi_methods/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function lists_items_store (params){
*/
export function lists_search(params,behavior){
return this.search_lists(params,behavior,true);
};
}

/** `POST /search/lists -> GET /search/lists`
* @alias BrAPINode.prototype.search_lists
Expand All @@ -119,4 +119,24 @@ export function search_lists(params,behavior){
introduced:"v2.0"
});
return this.search("lists",params,behavior);
};
}

/** `DELETE /lists/{listDbId}?hardDelete=true`
* @alias BrAPINode.prototype.lists_delete
* @param {Object} params Parameters to provide to the call
* @param {String} params.listDbId listDbId
* @param {hardDelete} params.hardDelete=true whether is a hard or soft delete
* @return {BrAPI_Behavior_Node}
*/
export function lists_delete (params){
var call = {
'defaultMethod': 'delete',
'urlTemplate': '/lists/{listDbId}?hardDelete=true',
'params': params,
'behavior': 'map', //delete returns empty response, so behavior doesn't matter
}
this.version.check(call.urlTemplate,{
introduced:"v2.1" //using the highest version number for now
});
return this.simple_brapi_call(call);
};
22 changes: 21 additions & 1 deletion src/brapi_methods/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,24 @@ export function search_samples(params,behavior,useOld){
});
return this.search("samples",params,behavior);
}
};
}

/** `DELETE /samples/{sampleDbId}?hardDelete=true`
* @alias BrAPINode.prototype.samples_delete
* @param {Object} params Parameters to provide to the call
* @param {String} params.sampleDbId sampleDbId
* @param {hardDelete} params.hardDelete=true whether is a hard or soft delete
* @return {BrAPI_Behavior_Node}
*/
export function samples_delete (params){
var call = {
'defaultMethod': 'delete',
'urlTemplate': '/samples/{sampleDbId}?hardDelete=true',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
}
20 changes: 20 additions & 0 deletions src/brapi_methods/trials.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,24 @@ export function search_trials(params,behavior){
introduced:"v2.0"
});
return this.search("trials",params,behavior);
}

/** `DELETE /trials/{trialDbId}?hardDelete=true`
* @alias BrAPINode.prototype.trials_delete
* @param {Object} params Parameters to provide to the call
* @param {String} params.trialDbId trialDbId
* @param {hardDelete} params.hardDelete=true whether is a hard or soft delete
* @return {BrAPI_Behavior_Node}
*/
export function trials_delete (params){
var call = {
'defaultMethod': 'delete',
'urlTemplate': '/trials/{trialDbId}?hardDelete=true',
'params': params,
'behavior': 'map'
}
this.version.check(call.urlTemplate,{
introduced:"v2.1"
});
return this.simple_brapi_call(call);
};