rename authentification argument
PietrH opened this issue · 2 comments
I'd like to rename the con
argument in etnservice functions to credentials
Why ?
The current functions already implemented to serve the API use the same argument names as the original functions from ETN, this allows us to keep much of the inner workings of the functions and tests the same.
However, on the client side the authentication argument has been renamed to credentials
with a new helper get_credentials()
, currently the pipeline goes:
graph TD;
ETN-->get_acoustic_detections;
ETN-->list_animal_ids;
get_acoustic_detections-->get_credentials;
list_animal_ids-->get_credentials;
get_credentials--->etnservice::con
etnservice::con--->connect_to_etn
Which means that requests to etnservice need to have a con object in their body:
"con": {
"username": "{{userid}}",
"password": "{{pwd}}"
}
So, currently the client side ETN functions still need to pass a con argument internally:
all_api_functions <- function(credentials = get_credentials()){
...
response <-
httr::POST(paste(endpoint, "json", sep = "/"),
body = list(**con** = credentials)
)
...
}
For passing credentials
from get_credentials()
in ETN client to etnservice, it would be convenient to use a credenials
argument instead of con
as all other arguments of the original function can be passed as a named list that is exactly the same as the function arguments.
Summarised, I'd like to do (pseudocode):
credentials = get_credentials(),
start_date = NULL,
end_date = NULL,
acoustic_tag_id = NULL,
animal_project_code = NULL,
scientific_name = NULL,
acoustic_project_code = NULL,
receiver_id = NULL,
station_name = NULL,
limit = FALSE
instead of currently:
con <- credentials = get_credentials(),
start_date = NULL,
end_date = NULL,
acoustic_tag_id = NULL,
animal_project_code = NULL,
scientific_name = NULL,
acoustic_project_code = NULL,
receiver_id = NULL,
station_name = NULL,
limit = FALSE
Additionally
con isn't actually a connection in etnservice, it's an object storing credentials
TODO
check_connection()
- replace in function definition
- replace in assertations
- replace in connect_to_etn()
connect_to_etn()
- leave as is
get_acoustic_detections()
- replace in function definition
- replace in check_connection()
- replace in connect_to_etn()
list_animal_ids()
- replace in function definition
client side
- list_animal_ids_api()
Postman
- get_acoustic_detections request body
- list_acoustic_tag_ids request body
- list_animal_project_codes request body
- list_scientific_names request body
- list_acoustic_project_codes request body
- list_receiver_ids request body
- list_station_names request body
- get_acoustic_detections request body
More functions got ported, so more need to be edited for the new argument name
created new postman collection to test new argument