| Title: | Pockethost for R |
|---|---|
| Description: | This package provides an R API for pockethost app instances. |
| Authors: | Enrico Spinielli [aut, cre] (ORCID: <https://orcid.org/0000-0001-8584-9131>) |
| Maintainer: | Enrico Spinielli <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1.0 |
| Built: | 2026-12-05 20:32:13 UTC |
| Source: | https://github.com/euctrl-pru/pockethostr |
authenticate
ph_authenticate_admin_username_password(app, api, username, password)ph_authenticate_admin_username_password(app, api, username, password)
app |
the app name |
api |
the api to hit |
username |
the username to use |
password |
the password to use |
a json
## Not run: ph_authenticate_admin_username_password <- function( "eurocontrol-data", "/api/admins/auth-with-password", username, password) ## End(Not run)## Not run: ph_authenticate_admin_username_password <- function( "eurocontrol-data", "/api/admins/auth-with-password", username, password) ## End(Not run)
create record
ph_create_record(app, api, collection, body, token = NULL, ...)ph_create_record(app, api, collection, body, token = NULL, ...)
app |
the app |
api |
the api |
collection |
the collection name or id |
body |
the body |
token |
the authentication token, depending on collection's |
... |
extra params |
a response
## Not run: adm <- ph_authenticate_admin_username_password( "eurocontrol-data", "/api/admins/auth-with-password", username, password) bd <- list( AVG_ROLLING_WEEK= 22065.4285714286, DAY_DIFF_PREV_YEAR_PERC= 0.035235526043, DAY_TFC= 24944, DAY_TFC_DIFF_2019_PERC= -0.11967531322, DIFF_ROLLING_WEEK_2019_PERC= -0.13323232323, DIFF_WEEK_PREV_YEAR_PERC= 0.027945081493, FLIGHT_DATE= "2024-01-01 00:00:00.000Z", Y2D_AVG_TFC_YEAR= 23172.4210526316, Y2D_DIFF_2019_PERC= -0.087499533673, Y2D_DIFF_PREV_YEAR_PERC= 0.051857514872, Y2D_TFC_YEAR= 440276 ) ph_create_record( app = "eurocontrol-data", api = "/api/collections", collection = "nw_traffic", token = adm$token, body = bd) ## End(Not run)## Not run: adm <- ph_authenticate_admin_username_password( "eurocontrol-data", "/api/admins/auth-with-password", username, password) bd <- list( AVG_ROLLING_WEEK= 22065.4285714286, DAY_DIFF_PREV_YEAR_PERC= 0.035235526043, DAY_TFC= 24944, DAY_TFC_DIFF_2019_PERC= -0.11967531322, DIFF_ROLLING_WEEK_2019_PERC= -0.13323232323, DIFF_WEEK_PREV_YEAR_PERC= 0.027945081493, FLIGHT_DATE= "2024-01-01 00:00:00.000Z", Y2D_AVG_TFC_YEAR= 23172.4210526316, Y2D_DIFF_2019_PERC= -0.087499533673, Y2D_DIFF_PREV_YEAR_PERC= 0.051857514872, Y2D_TFC_YEAR= 440276 ) ph_create_record( app = "eurocontrol-data", api = "/api/collections", collection = "nw_traffic", token = adm$token, body = bd) ## End(Not run)
Delete record
ph_delete_record(app, api, collection, id, token = NULL)ph_delete_record(app, api, collection, id, token = NULL)
app |
the app name |
api |
the api |
collection |
the collection name or id |
id |
the record id |
token |
the authentication token, depending on collection's |
a response
## Not run: ph_delete_record(app, api, id, token) ## End(Not run)## Not run: ph_delete_record(app, api, id, token) ## End(Not run)
list records
ph_list_records(app, api, collection, ...)ph_list_records(app, api, collection, ...)
app |
the application name |
api |
the api to hit |
collection |
the collection name or id |
... |
the query params as supported by PocketBase List/Search API |
a tibble
## Not run: ph_list_records( app, "/api/collections/", collection = "nw_traffic", perPage = 1, sort = "-FLIGHT_DATE", skipTotal = 1) # get only subset of columns ph_list_records( app, "/api/collections/", collection = "nw_traffic", sort = "-FLIGHT_DATE", fields = "id,FLIGHT_DATE,DAY_TFC" ) ## End(Not run)## Not run: ph_list_records( app, "/api/collections/", collection = "nw_traffic", perPage = 1, sort = "-FLIGHT_DATE", skipTotal = 1) # get only subset of columns ph_list_records( app, "/api/collections/", collection = "nw_traffic", sort = "-FLIGHT_DATE", fields = "id,FLIGHT_DATE,DAY_TFC" ) ## End(Not run)
Update record
ph_update_record(app, api, collection, id, body, token = NULL, ...)ph_update_record(app, api, collection, id, body, token = NULL, ...)
app |
the app name |
api |
the api |
collection |
the collection name or id |
id |
the record id |
body |
the body |
token |
the authentication token, depending on collection's |
... |
the query params as supported by PocketBase View API |
a response
## Not run: adm <- ph_authenticate_admin_username_password( "eurocontrol-data-test", "/api/admins/auth-with-password", username, password) bd <- list( DAY_TFC= 121, FLIGHT_DATE= "2024-05-01 00:00:00.000Z" ) id <- "lufkj3346ygx9a2" ph_update_record( app = "eurocontrol-data-test", api = "/api/collections", collection = "nw_traffic", token = adm$token, body = bd) ## End(Not run)## Not run: adm <- ph_authenticate_admin_username_password( "eurocontrol-data-test", "/api/admins/auth-with-password", username, password) bd <- list( DAY_TFC= 121, FLIGHT_DATE= "2024-05-01 00:00:00.000Z" ) id <- "lufkj3346ygx9a2" ph_update_record( app = "eurocontrol-data-test", api = "/api/collections", collection = "nw_traffic", token = adm$token, body = bd) ## End(Not run)
View record
ph_view_record(app, api, collection, id, ...)ph_view_record(app, api, collection, id, ...)
app |
the app name |
api |
the api |
collection |
the collection name or id |
id |
the record id |
... |
the query params as supported by PocketBase View API |
a response
## Not run: app <- "eurocontrol-data-test" collection <- "nw_traffic" id <- "lufkj3346ygx9a2" ph_view_record(app = app, api = "/api/collections", id = id, collection = collection, fields = "FLIGHT_DATE,DAY_TFC") ## End(Not run)## Not run: app <- "eurocontrol-data-test" collection <- "nw_traffic" id <- "lufkj3346ygx9a2" ph_view_record(app = app, api = "/api/collections", id = id, collection = collection, fields = "FLIGHT_DATE,DAY_TFC") ## End(Not run)