diff --git a/README.md b/README.md
index bf64839..a25659f 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ Implementation of the BRAPI standard for TERRA-REF instance of the BETYdb databa
| /germplasm | cultivars. | |
| /observations | traits | |
| /variables | variables | |
+| /methods | methods| |
# Currently implemented endpoints & parameters
@@ -91,7 +92,12 @@ See [Swagger documentation](http://terraref.org/brapi/v1/ui) for more details
name
observationVariableName
observationVariableDbID
- scale
+ scale
+ /methods
+ description
+ name
+ observationVariableDbId
+ observationVariableName
```
diff --git a/api/calls.py b/api/calls.py
index 2745769..e2a67f2 100644
--- a/api/calls.py
+++ b/api/calls.py
@@ -30,7 +30,8 @@ def search(datatype=None, dataType=None, pageSize=None, page=None):
calls_get_helper('studies/{studyDbId}/germplasm', versions=VERSIONS_1_23),
calls_get_helper('studies/{studyDbId}/layouts', versions=VERSIONS_1_23),
calls_get_helper('trials', versions=VERSIONS_1_23),
- calls_get_helper('variables', versions=VERSIONS_1_23)
+ calls_get_helper('variables', versions=VERSIONS_1_23),
+ calls_get_helper('methods', versions=VERSIONS_1_23)
]
# filter on datatype
diff --git a/api/methods.py b/api/methods.py
new file mode 100644
index 0000000..92f5b9b
--- /dev/null
+++ b/api/methods.py
@@ -0,0 +1,49 @@
+import helper
+
+
+def search(observationVariableDbId=None, traitClass=None, pageSize=None, page=None):
+ """Returns information on methods
+ Arguments:
+ observationVariableDbId: specific variable to return information on
+ traitClass: not implemented
+ pageSize: the desired size of return pages
+ page: the number of the page to return (starting at zero)
+ """
+ query = "SELECT id, name, description FROM methods AS m"
+
+ params = []
+
+ where_clause = " WHERE"
+
+ # add a filter on the variable ID
+ if observationVariableDbId:
+ query += where_clause + " m.id = %s "
+ params.append(observationVariableDbId)
+ where_clause = " AND"
+
+ # add a filter on the trait class - not implemented at this time
+ #if traitClass:
+ # NOTE: this code is invalid for filtering on traitClass, it's just a placeholder
+ # query += where_clause + " s.id = %s "
+ # params.append(traitClass)
+ # where_clause = " AND"
+
+ query += " ORDER BY m.id"
+
+ # count first
+ count = helper.query_count(query, params)
+
+ # execute query
+ result = helper.query_result(query, params, pageSize, page)
+
+ # wrap result
+ data = list()
+ for row in result:
+ data.append({
+ "name": row["name"],
+ "observationVariableName": row["name"],
+ "observationVariableDbId": str(row["id"]),
+ "description": row["description"]
+ })
+
+ return helper.create_result({"data": data}, count, pageSize, page)
diff --git a/brapi.yaml b/brapi.yaml
index a39ac8c..0c1628c 100644
--- a/brapi.yaml
+++ b/brapi.yaml
@@ -1181,6 +1181,391 @@ paths:
example: ERROR - 2018-10-08T20:15:11Z - User does not have permission
to perform this action
+ /methods:
+ get:
+ tags:
+ - Observation Variables
+ summary: Get the Methods
+ description: |-
+ Returns a list of Methods available on a server.
+
+ An Observation Variable has 3 critical parts: A Trait being observed, a Method for making the observation, and a Scale on which the observation can be measured and compared with other observations.
+ parameters:
+ - name: page
+ in: query
+ description: Which result page is requested. The page indexing starts at 0
+ (the first page is 'page'= 0). Default is `0`.
+ required: false
+ style: form
+ explode: true
+ schema:
+ type: integer
+ example: "0"
+ - name: pageSize
+ in: query
+ description: The size of the pages to be returned. Default is `1000`.
+ required: false
+ style: form
+ explode: true
+ schema:
+ type: integer
+ example: 1000
+ - name: Authorization
+ in: header
+ description: "HTTP HEADER - Token used for Authorization \n\nBearer\
+ \ {token_string} "
+ required: false
+ style: simple
+ explode: false
+ schema:
+ pattern: ^Bearer .*$
+ type: string
+ example: Bearer XXXX
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/MethodsResponse'
+ example:
+ metadata:
+ datafiles: []
+ pagination:
+ currentPage: 0
+ pageSize: 2
+ totalCount: 4
+ totalPages: 2
+ status: []
+ result:
+ data:
+ - class: Numeric
+ description: Standard rolled measuring tape
+ formula: a^2 + b^2 = c^2
+ methodDbId: m1
+ methodName: Tape Measure
+ name: Tape Measure
+ ontologyReference:
+ documentationLinks:
+ - URL: https://ontology.org/m1
+ type: RDF
+ url: https://ontology.org/m1
+ ontologyDbId: MO_123
+ ontologyName: Ontology.org
+ version: "17"
+ reference: google.com
+ - class: Numeric
+ description: Dried sample on electric scale
+ formula: NA
+ methodDbId: m2
+ methodName: Dry Electric Scale
+ name: Dry Electric Scale
+ ontologyReference:
+ documentationLinks:
+ - URL: https://ontology.org/m2
+ type: WEBPAGE
+ url: https://ontology.org/m2
+ ontologyDbId: MO_123
+ ontologyName: Ontology.org
+ version: "17"
+ reference: google.com
+ 400:
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ type: string
+ example: |-
+ ERROR - 2018-10-08T20:15:11Z - Malformed JSON Request Object
+ ERROR - 2018-10-08T20:15:11Z - Invalid query parameter
+ ERROR - 2018-10-08T20:15:11Z - Required parameter is missing
+ 401:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - Missing or expired authorization
+ token
+ 403:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - User does not have permission
+ to perform this action
+ post:
+ tags:
+ - Observation Variables
+ summary: Add a new Method
+ description: Create a new method object in the database
+ parameters:
+ - name: Authorization
+ in: header
+ description: "HTTP HEADER - Token used for Authorization \n\nBearer\
+ \ {token_string} "
+ required: false
+ style: simple
+ explode: false
+ schema:
+ pattern: ^Bearer .*$
+ type: string
+ example: Bearer XXXX
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/newMethodRequest'
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/MethodResponse'
+ example:
+ metadata:
+ datafiles: []
+ pagination:
+ currentPage: 0
+ pageSize: 0
+ totalCount: 0
+ totalPages: 0
+ status: []
+ result:
+ class: string
+ description: string
+ formula: string
+ methodDbId: 8175d7ac-6221-4e1d-8023-91ddb8b30fd8
+ methodName: string
+ name: string
+ ontologyReference:
+ documentationLinks:
+ - URL: string
+ type: OBO
+ url: string
+ ontologyDbId: MO_123
+ ontologyName: Ontology.org
+ version: "17"
+ reference: string
+ 400:
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ type: string
+ example: |-
+ ERROR - 2018-10-08T20:15:11Z - Malformed JSON Request Object
+ ERROR - 2018-10-08T20:15:11Z - Invalid query parameter
+ ERROR - 2018-10-08T20:15:11Z - Required parameter is missing
+ 401:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - Missing or expired authorization
+ token
+ 403:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - User does not have permission
+ to perform this action
+ /methods/{methodDbId}:
+ get:
+ tags:
+ - Observation Variables
+ summary: Get the details for a specific Method
+ description: |-
+ Retrieve details about a specific method
+
+ An Observation Variable has 3 critical parts: A Trait being observed, a Method for making the observation, and a Scale on which the observation can be measured and compared with other observations.
+ parameters:
+ - name: methodDbId
+ in: path
+ description: Id of the method to retrieve details of.
+ required: true
+ style: simple
+ explode: false
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ description: "HTTP HEADER - Token used for Authorization \n\nBearer\
+ \ {token_string} "
+ required: false
+ style: simple
+ explode: false
+ schema:
+ pattern: ^Bearer .*$
+ type: string
+ example: Bearer XXXX
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/MethodResponse'
+ example:
+ metadata:
+ datafiles: []
+ pagination:
+ currentPage: 0
+ pageSize: 0
+ totalCount: 0
+ totalPages: 0
+ status: []
+ result:
+ class: Numeric
+ description: Standard rolled measuring tape
+ formula: a^2 + b^2 = c^2
+ methodDbId: m1
+ methodName: Tape Measure
+ name: Tape Measure
+ ontologyReference:
+ documentationLinks:
+ - URL: https://ontology.org/m1
+ type: RDF
+ url: https://ontology.org/m1
+ ontologyDbId: MO_123
+ ontologyName: Ontology.org
+ version: "17"
+ reference: google.com
+ 400:
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ type: string
+ example: |-
+ ERROR - 2018-10-08T20:15:11Z - Malformed JSON Request Object
+ ERROR - 2018-10-08T20:15:11Z - Invalid query parameter
+ ERROR - 2018-10-08T20:15:11Z - Required parameter is missing
+ 401:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - Missing or expired authorization
+ token
+ 403:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - User does not have permission
+ to perform this action
+ 404:
+ description: Not Found
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - The requested object DbId is
+ not found
+ put:
+ tags:
+ - Observation Variables
+ summary: Update an existing Method
+ description: Update the details of an existing method
+ parameters:
+ - name: methodDbId
+ in: path
+ description: Id of the method to retrieve details of.
+ required: true
+ style: simple
+ explode: false
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ description: "HTTP HEADER - Token used for Authorization \n\nBearer\
+ \ {token_string} "
+ required: false
+ style: simple
+ explode: false
+ schema:
+ pattern: ^Bearer .*$
+ type: string
+ example: Bearer XXXX
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/newMethodRequest'
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/MethodResponse'
+ example:
+ metadata:
+ datafiles: []
+ pagination:
+ currentPage: 0
+ pageSize: 0
+ totalCount: 0
+ totalPages: 0
+ status: []
+ result:
+ class: string
+ description: string
+ formula: string
+ methodDbId: m1
+ methodName: string
+ name: string
+ ontologyReference:
+ documentationLinks:
+ - URL: string
+ type: OBO
+ url: string
+ ontologyDbId: MO_123
+ ontologyName: Ontology.org
+ version: "17"
+ reference: string
+ 400:
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ type: string
+ example: |-
+ ERROR - 2018-10-08T20:15:11Z - Malformed JSON Request Object
+ ERROR - 2018-10-08T20:15:11Z - Invalid query parameter
+ ERROR - 2018-10-08T20:15:11Z - Required parameter is missing
+ 401:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - Missing or expired authorization
+ token
+ 403:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - User does not have permission
+ to perform this action
+ 404:
+ description: Not Found
+ content:
+ application/json:
+ schema:
+ type: string
+ example: ERROR - 2018-10-08T20:15:11Z - The requested object DbId is
+ not found
/phenotypes-search:
get:
tags: