Skip to contents

Checks whether and which endpoints are correctly defined, reachable, and/or valid. Iterates through all endpoints defined in o311_endpoints and returns their status along with a reason, if applicable.

Usage

validate_endpoints(
  idx = NULL,
  checks = c("discovery", "services", "requests"),
  methods = c("formal", "down", "valid")
)

Arguments

idx

[integer]

Index numbers of endpoints to check. Index numbers follow row numbers in o311_endpoints.

checks

[character]

Which open311 method to check. By default, checks all methods.

methods

[character]

Which checks to apply. formal checks whether an endpoint is uniquely identifiable through given names and jurisdictions in o311_endpoints. down checks whether an endpoint is reachable and ready for requests. valid checks whether a method returns a valid output, i.e. a list or dataframe with more than 0 rows/elements. By default, applies all methods.

Value

A dataframe containing the name of the endpoint, one to three columns on check results, and one to three columns on reasons if a check turned out to be negative.

Examples

# \donttest{
# check the first three endpoints in o311_endpoints()
validate_endpoints(1:3)
#> Receiving endpoint 1 out of 3...
Receiving endpoint 2 out of 3...
Receiving endpoint 3 out of 3...

#> # A tibble: 3 × 7
#>   name              discovery services requests reason_discovery reason_services
#>   <chr>             <lgl>     <lgl>    <lgl>    <chr>            <lgl>          
#> 1 Annaberg-Buchhol… TRUE      TRUE     TRUE     NA               NA             
#> 2 Bloomington, IN   FALSE     TRUE     TRUE     API not reachab… NA             
#> 3 Bonn, DE          FALSE     TRUE     TRUE     API not reachab… NA             
#> # ℹ 1 more variable: reason_requests <lgl>

# check only requests
validate_endpoints(1:3, checks = "requests")
#> Receiving endpoint 1 out of 3...
Receiving endpoint 2 out of 3...
Receiving endpoint 3 out of 3...

#> # A tibble: 3 × 3
#>   name                  requests reason_requests
#>   <chr>                 <lgl>    <lgl>          
#> 1 Annaberg-Buchholz, DE TRUE     NA             
#> 2 Bloomington, IN       TRUE     NA             
#> 3 Bonn, DE              TRUE     NA             

# check only whether an endpoint is down
validate_endpoints(1:3, methods = "down")
#> Receiving endpoint 1 out of 3...
Receiving endpoint 2 out of 3...
Receiving endpoint 3 out of 3...

#> # A tibble: 3 × 7
#>   name              discovery services requests reason_discovery reason_services
#>   <chr>             <lgl>     <lgl>    <lgl>    <lgl>            <lgl>          
#> 1 Annaberg-Buchhol… TRUE      TRUE     TRUE     NA               NA             
#> 2 Bloomington, IN   TRUE      TRUE     TRUE     NA               NA             
#> 3 Bonn, DE          TRUE      TRUE     TRUE     NA               NA             
#> # ℹ 1 more variable: reason_requests <lgl>
# }