Commit bd7affcc authored by Pauline Maury Laribière's avatar Pauline Maury Laribière
Browse files

after big removal

parent 8474ec6a
Pipeline #270122 passed with stage
in 22 seconds
......@@ -32,27 +32,6 @@ get_codelist(identifier='CL_NOGA_SECTION')
```
## Content Creation
```{r content_creation, echo=FALSE}
get_content_configuration()
```
```{r content_creation_identifier, echo=FALSE}
get_identifier_content(identifier='HCL_CH_ISCO_19_PROF')
```
## Dataset
```{r , echo=FALSE}
res <- get_dataset_description(identifier='HCL_NOGA', language='de')
res
```
```{r , echo=FALSE}
get_dataset_information(identifier='HCL_NOGA', language='de')
```
## Data Structure
```{r , echo=FALSE}
......@@ -68,10 +47,6 @@ my_filters <- hash::hash(
```
```{r , echo=FALSE}
get_nomenclature_path_nodes(identifier='HCL_CH_ISCO_19_PROF', path='.', filters=my_filters)
```
```{r , echo=FALSE}
get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_number=2)
```
......@@ -79,53 +54,3 @@ get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters,
```{r , echo=FALSE}
get_nomenclature_multiple_levels(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_from=2, level_to=5)
```
```{r , echo=FALSE}
query_nomenclature(identifier='HCL_CH_ISCO_19_PROF', query='SELECT *', page_number=5, page_size=2, filters=my_filters)
```
# Available only internally (Intern to confederation or via VPN)
## Agent
```{r , echo=FALSE}
dcat_list_all_agents()
```
```{r , echo=FALSE}
dcat_get_agent_from_id(agent_id='xx')
```
## Dataset
```{r , echo=FALSE}
dcat_list_all_datasets()
```
```{r , echo=FALSE}
dcat_get_distributions_from_dataset_id(dataset_id='xx')
```
```{r , echo=FALSE}
dcat_get_dataset_from_id(dataset_id='xx')
```
```{r , echo=FALSE}
dcat_get_dataset_from_identifier(identifier='xx')
```
```{r , echo=FALSE}
dcat_get_distributions_from_dataset_identifier(identifier='xx')
```
## Distributions
```{r , echo=FALSE}
dcat_list_all_distributions()
```
```{r , echo=FALSE}
dcat_get_distribution_from_id(distribution_id='xx')
```
\ No newline at end of file
# Generated by roxygen2: do not edit by hand
export(dcat_get_agent_from_id)
export(dcat_get_dataset_from_id)
export(dcat_get_dataset_from_identifier)
export(dcat_get_distribution_from_id)
export(dcat_get_distributions_from_dataset_id)
export(dcat_get_distributions_from_dataset_identifier)
export(dcat_list_all_agents)
export(dcat_list_all_datasets)
export(dcat_list_all_distributions)
export(get_codelist)
export(get_content_configuration)
export(get_data_structure)
export(get_dataset_description)
export(get_dataset_information)
export(get_identifier_content)
export(get_nomenclature_multiple_levels)
export(get_nomenclature_one_level)
export(get_nomenclature_path_nodes)
export(query_nomenclature)
importFrom(methods,new)
importFrom(utils,read.csv)
......@@ -30,84 +30,6 @@ get_codelist <- function(identifier,
}
#' Get the display information for the available configured content
#'
#' @return the configured content's display information
#' @export
#'
#' @examples
#' get_content_configuration()
get_content_configuration <- function() {
api <- api_class(api_type = "content_configuration")
api$get_response()
}
#' Get a nomenclature information based on its identifier
#'
#' @param identifier the nomenclature's identifier
#'
#' @return the nomenclature's information
#' @export
#'
#' @examples
#' get_identifier_content(identifier='HCL_CH_ISCO_19_PROF')
get_identifier_content <- function(identifier) {
api <- api_class(
api_type = "content_configuration_identifier",
id = identifier
)
api$get_response()
}
#' Get the dcat dataset description
#'
#' @param identifier the dataset's identifier
#' @param language the language of the response data
#' Available are 'fr', 'de', 'it', 'en'.
#'
#' @return dataset description
#' @export
#'
#' @examples
#' get_dataset_description(identifier='HCL_NOGA', language='de')
get_dataset_description <- function(identifier, language = "fr") {
api <- api_class(
api_type = "dcat_dataset_description",
id = identifier,
language = language
)
api$get_response()
}
#' Get the dcat dataset information
#'
#' @param identifier the dataset's identifier
#' @param language the language of the response data
#' Available are 'fr', 'de', 'it', 'en'.
#'
#' @return dataset's information
#' @export
#'
#' @examples
#' get_dataset_information(identifier='HCL_NOGA', language='de')
get_dataset_information <- function(identifier, language = "en") {
api <- api_class(
api_type = "dcat_dataset_information",
id = identifier,
language = language
)
api$get_response()
}
#' Get the data structure
#'
#' @param identifier the dataset's identifier
......@@ -129,36 +51,6 @@ get_data_structure <- function(identifier, language = "en") {
}
#' Get the nodes of a path within a nomenclature
#'
#' @param identifier the nomenclature's identifier
#' @param path the path leading to the nodes
#' @param filters the filters to apply
#' @param language the language of the response data
#' Available are 'fr', 'de', 'it', 'en'.
#'
#' @return nodes and their metadata
#' @export
#'
#' @examples
#' get_nomenclature_path_nodes(identifier='HCL_CH_ISCO_19_PROF', path='.',
#' filters=my_filters)
get_nomenclature_path_nodes <- function(identifier,
path = ".",
filters = "",
language = "en") {
api <- api_class(
api_type = "nomenclature_path_nodes",
id = identifier,
path = path,
parameters = hash_to_string(filters),
language = language
)
api$get_response()
}
#' Get one level of a nomenclature
#'
#' @param identifier nomenclature's identifier
......@@ -236,204 +128,3 @@ get_nomenclature_multiple_levels <- function(identifier,
res
}
#' Search query within a nomenclature
#'
#' @param identifier nomenclature's identifier
#' @param query the search query
#' @param page_number the number of the result page to return
#' @param page_size the size of each page result
#' @param filters additionnal filters
#' @param language the language of the response data
#' Available are 'fr', 'de', 'it', 'en'.
#'
#' @return the query result
#' @export
#'
#' @examples
#' query_nomenclature(identifier='HCL_CH_ISCO_19_PROF', query='SELECT *',
#' page_number=5, page_size=2, filters=my_filters)
query_nomenclature <- function(identifier,
query,
page_number,
page_size,
filters,
language = "en") {
parameters <- glue::glue("query={URLencode(query)}&page={page_number}&pageSize={page_size}&language={language}&{hash_to_string(filters)}")
api <- api_class(
api_type = "nomenclature_search",
id = identifier,
parameters = parameters
)
api$get_response()
}
###############################################################
########################## dcat APIs ##########################
###############################################################
#' List all agents
#'
#' @return all agents
#' @export
#'
#' @examples
#' dcat_list_all_agents()
dcat_list_all_agents <- function() {
api <- api_class(
api_type = "agents_list",
root_url = DCAT_URL
)
api$get_response()
}
#' Get the agent with the corresponding agent id
#'
#' @param agent_id agent's id
#'
#' @return agent with this id
#' @export
#'
#' @examples
#' dcat_get_agent_from_id(agent_id='xx')
dcat_get_agent_from_id <- function(agent_id) {
api <- api_class(
api_type = "agent_id",
root_url = DCAT_URL,
id = agent_id
)
api$get_response()
}
#' List all datasets
#'
#' @return all datasets
#' @export
#'
#' @examples
#' dcat_list_all_datasets()
dcat_list_all_datasets <- function() {
api <- api_class(
api_type = "dataset_list",
root_url = DCAT_URL
)
api$get_response()
}
#' Get all distributions for the dataset with the corresponding dataset id
#'
#' @param dataset_id dataset's id
#'
#' @return distributions for the dataset with dataset's id
#' @export
#'
#' @examples
#' dcat_get_distributions_from_dataset_id(dataset_id='xx')
dcat_get_distributions_from_dataset_id <- function(dataset_id) {
api <- api_class(
api_type = "dataset_id_distributions",
root_url = DCAT_URL,
id = dataset_id
)
api$get_response()
}
#' Get the dataset with the corresponding id
#'
#' @param dataset_id dataset's id
#'
#' @return the dataset
#' @export
#'
#' @examples
#' dcat_get_dataset_from_id(dataset_id='xx')
dcat_get_dataset_from_id <- function(dataset_id) {
api <- api_class(
api_type = "dataset_id",
root_url = DCAT_URL,
id = dataset_id
)
api$get_response()
}
#' Get the dataset with the corresponding identifier
#'
#' @param identifier dataset's identifier
#'
#' @return the dataset
#' @export
#'
#' @examples
#' dcat_get_dataset_from_identifier(identifier='xx')
dcat_get_dataset_from_identifier <- function(identifier) {
api <- api_class(
api_type = "dataset_identifier",
root_url = DCAT_URL,
id = identifier
)
api$get_response()
}
#' Get all distributions for the dataset with the corresponding identifier.
#'
#' @param identifier dataset's identifier
#'
#' @return all distributions for the dataset with
#' the corresponding dataset identifier
#' @export
#'
#' @examples
#' dcat_get_distributions_from_dataset_identifier(identifier='xx')
dcat_get_distributions_from_dataset_identifier <- function(identifier) {
api <- api_class(
api_type = "dataset_identifier_distributions",
root_url = DCAT_URL,
id = identifier
)
api$get_response()
}
#' List all distributions
#'
#' @return all distributions
#' @export
#'
#' @examples
#' dcat_list_all_distributions()
dcat_list_all_distributions <- function() {
api <- api_class(
api_type = "distributions_list",
root_url = DCAT_URL
)
api$get_response()
}
#' Get the distribution with the corresponding id
#'
#' @param distribution_id distribution's id
#'
#' @return the distribution
#' @export
#'
#' @examples
#' dcat_get_distribution_from_id(distribution_id='xx')
dcat_get_distribution_from_id <- function(distribution_id) {
api <- api_class(
api_type = "distribution_id",
root_url = DCAT_URL,
id = distribution_id
)
api$get_response()
}
......@@ -4,7 +4,6 @@
#' @field api_type character. The name of the api to call (see url_mapping)
#' @field export_format character (default = "JSON"). The export's format
#' Available are CSV, XLSX, SDMX-ML and JSON
#' @field root_url character (default = "BASE_URL"). Root url to call (for i14y or dcat)
#' @field parameters character. Additional request parameters
#' @field id character. The identifier or id of the request's object
#' @field language character (default = "en"). The language of the response data.
......@@ -12,8 +11,6 @@
#' @field version_format numeric (default = 2.1). The export format's version
#' (2.0 or 2.1 when format is SDMX-ML)
#' (for 'codelist')
#' @field path character. The path leading to the nodes
#' (for 'nomenclature_search')
#' @field api_url character. The url to make the request to.
#'
#' @importFrom methods new
......@@ -26,7 +23,6 @@ api_class <- setRefClass(
fields = list(
api_type = "character",
export_format = "character",
root_url = "character",
parameters = "character",
id = "character",
language = "character",
......@@ -37,7 +33,6 @@ api_class <- setRefClass(
methods = list(
initialize = function(...,
export_format = "JSON",
root_url = BASE_URL,
parameters = "",
id = "",
language = "en",
......@@ -46,7 +41,6 @@ api_class <- setRefClass(
callSuper(
...,
export_format = export_format,
root_url = root_url,
parameters = parameters,
id = id,
language = language,
......@@ -58,9 +52,9 @@ api_class <- setRefClass(
get_response = function() {
request_function <- REQUEST_FUNCTION_MAPPING[[export_format]]
if (parameters == "") {
url <- glue::glue("{root_url}/api/{api_url}")
url <- glue::glue("{BASE_URL}/api/{api_url}")
} else {
url <- glue::glue("{root_url}/api/{api_url}?{parameters}")
url <- glue::glue("{BASE_URL}/api/{api_url}?{parameters}")
}
request_function(url)
},
......@@ -69,44 +63,12 @@ api_class <- setRefClass(
# i14y
"codelist" =
glue::glue("CodeLists/{id}/exports/{export_format}/{version_format}"),
"content_configuration" =
glue::glue("ContentConfigurations"),
"content_configuration_identifier" =
glue::glue("ContentConfigurations/{id}"),
"dcat_data_structure" =
glue::glue("DataStructures/{id}/{language}"),
"dcat_dataset_description" =
glue::glue("Datasets/{id}/{language}/description"),
"dcat_dataset_information" =
glue::glue("Datasets/{id}/{language}/distributions"),
"nomenclature_path_nodes" =
glue::glue("Nomenclatures/Childnodes/{id}/{language}/{path}"),
"nomenclature_one_level" =
glue::glue("Nomenclatures/{id}/levelexport/CSV"),
"nomenclature_multiple_levels" =
glue::glue("Nomenclatures/{id}/multiplelevels/CSV"),
"nomenclature_search" =
glue::glue("Nomenclatures/{id}/search"),
# dcat
"agents_list" =
glue::glue("Agent"),
"agent_id" =
glue::glue("Agent/{id}"),
"dataset_list" =
glue::glue("Dataset"),
"dataset_id_distributions" =
glue::glue("Dataset/{id}/distributions"),
"dataset_id" =
glue::glue("Dataset/{id}"),
"dataset_identifier" =
glue::glue("Datataset/identifier/{id}"),
"dataset_identifier_distributions" =
glue::glue("Datataset/identifier/{id}/distributions"),
"distributions_list" =
glue::glue("Distribution"),
"distribution_id" =
glue::glue("Distribution/{id}")
)
api_url <<- url_mapping[[api_type]]
}
......
# Root URL constants
BASE_URL <- "https://www.i14y.admin.ch"
DCAT_URL <- "https://dcat.app.cfap02.atlantica.admin.ch"
......@@ -16,8 +16,6 @@ Api class to make appropriate request based on parameters
\item{\code{export_format}}{character (default = "JSON"). The export's format
Available are CSV, XLSX, SDMX-ML and JSON}
\item{\code{root_url}}{character (default = "BASE_URL"). Root url to call (for i14y or dcat)}
\item{\code{parameters}}{character. Additional request parameters}
\item{\code{id}}{character. The identifier or id of the request's object}
......@@ -29,9 +27,6 @@ Available are 'fr', 'de', 'it', 'en'}
(2.0 or 2.1 when format is SDMX-ML)
(for 'codelist')}
\item{\code{path}}{character. The path leading to the nodes
(for 'nomenclature_search')}
\item{\code{api_url}}{character. The url to make the request to.}
}}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api_call.R
\name{dcat_get_agent_from_id}
\alias{dcat_get_agent_from_id}
\title{Get the agent with the corresponding agent id}
\usage{
dcat_get_agent_from_id(agent_id)
}
\arguments{
\item{agent_id}{agent's id}
}
\value{
agent with this id
}
\description{
Get the agent with the corresponding agent id
}
\examples{
dcat_get_agent_from_id(agent_id='xx')
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api_call.R
\name{dcat_get_dataset_from_id}
\alias{dcat_get_dataset_from_id}
\title{Get the dataset with the corresponding id}
\usage{
dcat_get_dataset_from_id(dataset_id)
}
\arguments{
\item{dataset_id}{dataset's id}
}
\value{
the dataset
}
\description{
Get the dataset with the corresponding id
}
\examples{
dcat_get_dataset_from_id(dataset_id='xx')
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api_call.R
\name{dcat_get_dataset_from_identifier}
\alias{dcat_get_dataset_from_identifier}
\title{Get the dataset with the corresponding identifier}
\usage{
dcat_get_dataset_from_identifier(identifier)
}
\arguments{
\item{identifier}{dataset's identifier}
}
\value{
the dataset
}
\description{
Get the dataset with the corresponding identifier
}
\examples{
dcat_get_dataset_from_identifier(identifier='xx')
}
% Generated by roxygen2: do not edit by hand