Skip to content

Commit

Permalink
Merge pull request #15 from solgenomics/topic/brapi_v2
Browse files Browse the repository at this point in the history
Implement brapi version 2 calls (beta), also compatible with verson 1.3
  • Loading branch information
lukasmueller authored Apr 23, 2021
2 parents d8238eb + b1a9be3 commit 5ab54d3
Show file tree
Hide file tree
Showing 38 changed files with 2,252 additions and 145 deletions.
295 changes: 197 additions & 98 deletions docs/README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/brapi_methods.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export * from "./brapi_methods/allelematrices";
export * from "./brapi_methods/attributes";
export * from "./brapi_methods/attributevalues";
export * from "./brapi_methods/breedingmethods";
export * from "./brapi_methods/calls";
export * from "./brapi_methods/callsets";
export * from "./brapi_methods/commoncropnames";
export * from "./brapi_methods/crosses";
export * from "./brapi_methods/crossingprojects";
export * from "./brapi_methods/events";
export * from "./brapi_methods/germplasm";
export * from "./brapi_methods/images";
export * from "./brapi_methods/lists";
Expand All @@ -11,18 +16,26 @@ export * from "./brapi_methods/maps";
export * from "./brapi_methods/markerprofiles";
export * from "./brapi_methods/markers";
export * from "./brapi_methods/methods";
export * from "./brapi_methods/observations";
export * from "./brapi_methods/observationlevels";
export * from "./brapi_methods/observationunits";
export * from "./brapi_methods/ontologies";
export * from "./brapi_methods/people";
export * from "./brapi_methods/phenotypes";
export * from "./brapi_methods/plannedcrosses";
export * from "./brapi_methods/programs";
export * from "./brapi_methods/references";
export * from "./brapi_methods/referencesets";
export * from "./brapi_methods/samples";
export * from "./brapi_methods/scales";
export * from "./brapi_methods/search";
export * from "./brapi_methods/seasons";
export * from "./brapi_methods/seedlots";
export * from "./brapi_methods/serverinfo";
export * from "./brapi_methods/studies";
export * from "./brapi_methods/traits";
export * from "./brapi_methods/trials";
export * from "./brapi_methods/variables";
export * from "./brapi_methods/variants";
export * from "./brapi_methods/variantsets";
export * from "./brapi_methods/vendor";
75 changes: 75 additions & 0 deletions src/brapi_methods/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,67 @@ export function attributes (params,behavior){
return this.simple_brapi_call(call);
}

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


/** `GET /attributes/{attributeDbId}`
* @alias BrAPINode.prototype.attributes_detail
* @param {Object} params Parameters to provide to the call
* @param {String} params.attributeDbId attributeDbId
* @return {BrAPI_Behavior_Node}
*/
export function attributes_detail (params){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/attributes/{attributeDbId}',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}


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

/** `GET /attributes_categories`
* @alias BrAPINode.prototype.attributes_categories
* @param {Object} params Parameters to provide to the call
Expand All @@ -37,3 +98,17 @@ export function attributes_categories (params,behavior){
});
return this.simple_brapi_call(call);
}


/** `POST /search/attributes -> GET /search/attributes`
* @alias BrAPINode.prototype.search_attributes
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function search_attributes(params,behavior){
this.version.check("POST /search/attributes -> GET /search/attributes",{
introduced:"v2.0"
});
return this.search("attributes",params,behavior);
};
92 changes: 92 additions & 0 deletions src/brapi_methods/attributevalues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/** `GET /attributevalues`
* @alias BrAPINode.prototype.attributevalues
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function attributevalues (params,behavior){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/attributevalues',
'params': params,
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}

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

/** `GET /attributevalues/{attributeValueDbId}`
* @alias BrAPINode.prototype.attributevalues_detail
* @param {Object} params Parameters to provide to the call
* @param {String} params.attributeValueDbId attributeValueDbId
* @return {BrAPI_Behavior_Node}
*/
export function attributevalues_detail (params){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/attributevalues/{attributeValueDbId}',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}

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


/** `POST /search/attributevalues -> GET /search/attributevalues`
* @alias BrAPINode.prototype.search_attributevalues
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function search_attributevalues(params,behavior){
this.version.check("POST /search/attributevalues -> GET /search/attributevalues",{
introduced:"v2.0"
});
return this.search("attributevalues",params,behavior);
};
13 changes: 13 additions & 0 deletions src/brapi_methods/calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ export function calls (params,behavior){
});
return this.simple_brapi_call(call);
}

/** `POST /search/calls -> GET /search/calls`
* @alias BrAPINode.prototype.search_calls
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function search_calls(params,behavior){
this.version.check("POST /search/calls -> GET /search/calls",{
introduced:"v2.0"
});
return this.search("calls",params,behavior);
};
73 changes: 73 additions & 0 deletions src/brapi_methods/callsets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

/** `GET /callsets`
* @alias BrAPINode.prototype.callsets
* @param {Object} params Parameters to provide to the call
* @param {String} params.germplasmDbId germplasmDbId
* @return {BrAPI_Behavior_Node}
*/
export function callsets (params){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/callsets',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}


/** `GET /callsets/{callSetDbId}`
* @alias BrAPINode.prototype.callsets_detail
* @param {Object} params Parameters to provide to the call
* @param {String} params.callSetDbId callSetDbId
* @return {BrAPI_Behavior_Node}
*/
export function callsets_detail (params){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/callsets/{callSetDbId}',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}


/** `GET /callsets/{callSetDbId}/calls`
* @alias BrAPINode.prototype.callsets_calls
* @param {Object} params Parameters to provide to the call
* @param {String} params.callSetDbId callSetDbId
* @return {BrAPI_Behavior_Node}
*/
export function callsets_calls (params){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/callsets/{callSetDbId}/calls',
'params': params,
'behavior': 'map',
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}


/** `POST /search/callsets -> GET /search/callsets`
* @alias BrAPINode.prototype.search_callsets
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function search_callsets(params,behavior){
this.version.check("POST /search/callsets -> GET /search/callsets",{
introduced:"v2.0"
});
return this.search("callsets",params,behavior);
};
9 changes: 5 additions & 4 deletions src/brapi_methods/commoncropnames.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ export function commoncropnames (params,behavior){
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
if (this.version.predates("v1.2")){
if (this.version.predates("v1.3")){
call.urlTemplate = "/crops"
this.version.check(call.urlTemplate,{
introduced:"v1.0",
deprecated:"v1.2"
deprecated:"v1.3",
deprecated:"v2.0"
});
} else {
call.urlTemplate = "/commonCropNames"
call.urlTemplate = "/commoncropnames"
this.version.check(call.urlTemplate,{
introduced:"v1.2"
introduced:"v1.3"
});
}
return this.simple_brapi_call(call);
Expand Down
59 changes: 59 additions & 0 deletions src/brapi_methods/crosses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/** `GET /crosses`
* @alias BrAPINode.prototype.crosses
* @param {Object} params Parameters to provide to the call
* @param {String} [behavior="fork"] Behavior of the node
* @return {BrAPI_Behavior_Node}
*/
export function crosses (params,behavior){
var call = {
'defaultMethod': 'get',
'urlTemplate': '/crosses',
'params': params,
'behaviorOptions': ['fork','map'],
'behavior': behavior,
}
this.version.check(call.urlTemplate,{
introduced:"v2.0"
});
return this.simple_brapi_call(call);
}

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

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

0 comments on commit 5ab54d3

Please sign in to comment.