Core Application Resources¶
While there are a number of tangential api calls that the application makes, the above description of the BaseModeLReource should give a good idea as to how to handle them.
However, when it comes to making the application work, we have a number of core requests that allow us to provide data for our core functionaliy.
These endpoints are listed in relative importance to the application.
/api/v1/all_meta/¶
- 
class 
rhizome.api.resources.all_meta.AllMetaResource(api_name=None)[source]¶ - GET Request Returns all camapaigns, charts, dashboards, indicators,indicator_tags, locations and offices in the database.
 - Required Parameters:
 none
Response Format¶
{
  meta: {...},
  objects: [{
    campaigns: <List>,
    charts: <List>,
    dashboards: <List>,
    indicators: <List>,
    indicator_tags: <List>,
    indicator_to_tags: <List>,
    locations: <List>,
    offices: <List>,
    is_supeuser: <Boolean>
  }],
  errors: {...}
}
/api/v1/geo/¶
- 
class 
rhizome.api.resources.geo.GeoResource(api_name=None)[source]¶ - GET Request A non model resource that allows us to query for shapefiles
 based on a colletion of parameters. - Required Parameters:
‘location_id__in’ the location of the shape file that we wish to retrieve- Optional Parameters:
 ‘location_depth’ the recursive depth in relation to the location_id parameter. For instance, a depth of 1 would get all children of that
location. 2 would return all “grandchildren”
- ‘location_type’ return the descendants of the location_id param that
 have the given location_type id.
Response Format¶
{
  meta: {...},
  objects: [{
    location_id: <Integer>,
    type: <String>,
    properties <Dictionary>,
    geometry: <Dictionary>,
    parent_location_id: <Integer>
  }],
  errors: {...}
}
/api/v1/campaign/¶
- 
class 
rhizome.api.resources.campaign.CampaignResource(api_name=None)[source]¶ - GET Request Returns campaigns from the database
 - Optional Parameters:
 ‘id’: a comma delimited list of campaign ids. If the parameter is not set, the API will return all campaigns
- Errors:
 if an invalid id is provided, the API returns a 200 code with an empty list of campaigns.
GET Request: Request Detail Another way to query for campaigns using the format: /api/v1/campaign/<campaign_id>/
- Errors:
 if an id is invalid, the API returns a 500 error code.
- POST Reguest: Create a camapaign
 - -Required Parameters:
 - ‘name’,’top_lvl_location_id’, ‘campaign_type_id’, #’start_date’,’end_date’,
 - -Errors:
 - If any of the fields are missing, the system returns a 500 error.
 
Response Format¶
{
   meta: {},
   objects: [
     campaign_type_id: <Integer>,
     created_at: <Date>,
     start_date: <Date>,
     end_date: <Date>,
     id: <Integer>,
     name: <String>,
     office_id: <Integer>,
     pct_complete: <Float>,
     top_lvl_indicator_tag_id: <Integer>,
     top_lvl_location_id: <Integer>,
   ],
   errors: {}
}
/api/v1/custom_chart/¶
- 
class 
rhizome.api.resources.custom_chart.CustomChartResource(api_name=None)[source]¶ GET Requests: returns charts from the API. If no parameters are given, returns all the charts
- Optional Parameters:
 ‘id’ – returns the chart with the given id ‘dashboard_id’ – returns a chart associated with the given
dashboard id
- Errors:
 If an invalid id is passed, the API returns an empty list of objects and a status code of 200
- DELETE Requests:
 - Required Parameters:
 ‘id’
- POST Requests:
 - Required Parameters:
 ‘uuid’, ‘title’, ‘chart_json’
- Errors:
 If any of the required parameters are missing, the API returns a 500 error
Response Format¶
{
  meta: {...},
  objects: [{
    id: <Number>,
    uuid: <String>,
    title: <String>,
    chart_json: <JSON>
  }],
  errors: {...}
}
/api/v1/custom_dashboard/¶
- 
class 
rhizome.api.resources.custom_dashboard.CustomDashboardResource(api_name=None)[source]¶ - GET Requests: Get a dashboard. If no params are passed, returns all the dashboards
 - Optional Parameters:
 ‘id’
- GET Request get detail:
 - to access a specific chart, send a get request to /api/v1/custom_dashboard/<dashboard_id>/
 
- POST Requests: Create a dashboard
 - Required Parameters:
 ‘title’
- Optional Parameters:
 ‘chart_uuids’: this associates the given chart() with a dashboard
- Errors:
 If a title is not supplied. The API will return a 500 error.
- DELETE Requests: There are two ways to submit a delete request to API
 - to delete a resource, HTTP delete request to /api/v1/custom_dashboard/<dashboard_id>/
 
Response Format¶
{
   meta: {},
   objects: [
     id: <Integer>,
     title: <String>,
     description: <String>,
     layout: <Integer>,
     rows: <JSON>,
   ],
   errors: {}
}
/api/v1/location/¶
- 
class 
rhizome.api.resources.location.LocationResource(api_name=None)[source]¶ - GET Request Returns locations objects. All location objects will be returned if an optional parameter is not set.
 - Optional Parameters:
 ‘location_depth’ the recursive depth in relation to the location_id parameter. For instance, a depth of 1 would get all children of that location. 2 would return all “grandchildren” ‘location_type’ return the descendants of the location_id param that have the given location_type id.
Response Format¶
{
  meta: {...},
  objects: [{
    id: <Number>,
    name: <String>,
    latitude: <Number>,
    longitude: <Number>,
    location_code: <String>,
    location_type: <String>,
    office_id: <Number>,
    parent_location_id: <Number>,
    resource_uri: <String>,
    created_at: "YYYY-MM-DDTHH:MM:SS.sss",
  }],
  errors: {...}
}
``/api/v1/indicator/``
++++++++++++++++++++++
.. autoclass:: rhizome.api.resources.indicator.IndicatorResource
Response Format
~~~~~~~~~~~~~~~
.. code-block:: json
   {
      meta: {},
      objects: [
        short_name: <String>,
        name: <String>,
        description: <String>,
        is_reported: <Boolean>,
        data_format: <String>,
        created_at: <Date>,
        bound_json: <JSON>,
        tag_json: <JSON>,
        office_id: <JSON>,
        good_bound: <Float>,
        bad_bound: <Float>,
        source_name: <String>
      ],
      errors: {}
   }
``/api/v1/indicator_tag/``
++++++++++++++++++++++++++
.. autoclass:: rhizome.api.resources.indicator_tag.IndicatorTagResource
.. code-block:: json
  {
    meta: {...},
    objects: [{
      id: <Number>,
      tag_name:<String>,
      parent_tag_id:<Number>
    }],
    errors: {...}
  }
``/api/v1/indicator_to_tag/``
+++++++++++++++++++++++++++++
.. autoclass:: rhizome.api.resources.indicator_to_tag.IndicatorToTagResource
{"id": 146, "indicator__short_name": "Polio From Saliva", "indicator_id": 123, "indicator_tag__tag_name": "Perceived Threat", "indicator_tag_id": 19
Response Format
~~~~~~~~~~~~~~~
.. code-block:: json
  {
    meta: {...},
    objects: [{
      id: <Integer>,
      indicator_short_name: <String>,
      indicator_id: <Integer>,
      indicator_tag_name: <String>,
      indicator_tag_id: <Integer>,
    }],
    errors: {...}
  }
/api/v1/refresh_master/¶
- 
class 
rhizome.api.resources.refresh_master.RefreshMasterResource(api_name=None)[source]¶ - GET Request Runs refresh master, and agg refresh for a given document
 - Required Parameters:
 ‘document_id’
- Errors:
 returns 500 error if no document id is provided
Response Format¶
{
  meta: {...},
  objects: [{
    docfile: <String>,
    doc_title: <String>,
    file_header: <JSON>,
    guid: <String>,
    created_at: <Date>,
    id: <Integer>,
    resource_uri: <String>
  }],
  errors: {...}
}
/api/v1/source_doc/¶
- 
class 
rhizome.api.resources.document.DocumentResource(api_name=None)[source]¶ - POST Request uploads a document to the rhizome server.
 - Required Parameters:
 ‘docfile’ the base64 encoded file: csv, xls, xlsx file format ‘doc_title’ the title of the document
- Optional Parameters:
 ‘doc_id’ an id for the document
- Errors:
 returns 500 error of the document is empty returns 500 error if a required parameter is not supplied
Response Format¶
{
  meta: {...},
  objects: [{
    docfile: <String>,
    doc_title: <String>,
    file_header: <JSON>,
    guid: <String>,
    created_at: <Date>,
    id: <Integer>,
    resource_uri: <String>
  }],
  errors: {...}
}
/api/v1/source_submission/¶
- 
class 
rhizome.api.resources.source_submission.SourceSubmissionResource(api_name=None)[source]¶ - GET Request Returns all SourceSubmissions unless an optional parameter is specified
 - Optional Parameters:
 ‘document_id’: return only the source submissions with the specified document ids
- Errors:
 if an incorrect document id is provided, returns an empty object list
Response Format¶
{
  meta: {...},
  objects: [{
    document_id: <Integer>,
    instance_guid: <String>,
    row_number: <Integer>,
    data_date: <Date>,
    location_code: <String>,
    campaign_code: <String>,
    location_display: <String>,
    submission_json: <JSON>,
    created_at: <Date>,
    process_status: <String>
  }],
  errors: {...}
}
/api/v1/transform_upload/¶
- 
class 
rhizome.api.resources.doc_trans_form.DocTransFormResource(api_name=None)[source]¶ - GET Request Runs document transform, refresh master, and agg refresh
 for a given document - Required Parameters:
‘document_id’- Errors:
 returns 500 error if no document id is provided
Response Format¶
{
  meta: {...},
  objects: [{
    docfile: <String>,
    doc_title: <String>,
    file_header: <JSON>,
    guid: <String>,
    created_at: <Date>,
    id: <Integer>,
    resource_uri: <String>
  }],
  errors: {...}
}