modify_endpoint: Modify a DHIS2 endpoint

Description Usage Arguments Details Value Examples

View source: R/build_endpoint.R

Description

Short hand to modify a 'DHIS2 like' resource endpoint or an API link from R. This is useful when defining or modifying a DHIS2 API link.

Usage

1
2
3
4
5
6
7
8
modify_endpoint(
  endpoint = NULL,
  id = NULL,
  ref = NULL,
  ref_id = NULL,
  version = NULL,
  ...
)

Arguments

endpoint

A DHIS2 resource or on an API endpoint link, for example 'dataElements' or 'api/dataElements'.

id

The unique identifier of an object in the endpoint, a character string of size 11.

ref

An endpoint reference, a character string.

ref_id

The unique identifier of an object in the referenced endpoint, a character string of size 11.

version

A version of the web API.

...

Additional parameters passed to the api_query.

Details

modify_endpoint defines or modifies an API link from an endpoint or API params. It parses the API parameters first into a list before building the API link.

Value

A URL, a DHIS2 web API link.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
modify_endpoint() # default api link
modify_endpoint(endpoint = "dataElements") # point to dataElements endpoint
# refer to a specific dataElement object
modify_endpoint(endpoint = "dataElements", id = "ID")
# modify an object ID of an API link, `api/dataElements/ID`
modify_endpoint(endpoint = "api/dataElements/ID", id = "ID2")
# modify the version of an API link, `api/dataElements/ID`
version <- 29L
modify_endpoint(endpoint = "api/dataElements/ID", version = version)
# select data elements name, id and shortNames
modify_endpoint(endpoint = "dataElements", fields = c("name", "id", "shortNames"))
# arrange the data elements name in ascending order
modify_endpoint(
  endpoint = "dataElements", fields = c("name", "id", "shortNames"),
  order = api_order("name", by = "asc")
)

INyabuto/dhis2r documentation built on June 14, 2021, 1:15 a.m.