namc_api | R Documentation |
R6 class for handling NAMC GraphQL queries
a namc_api
class (R6 class)
NAMCr::base_class
-> namc_api
is_configured
shows the configured state of the namc_api object
URL
is the API URL endpoint
top_level_key
is the top level key returned in the graphql JSON return for data
top_level_key_error
is the top level key returned in the graphql JSON return for errors
schema
is a list of endpoints and fields for the API
pagination_limit
is the max number of records returned without pagination
tpl_pagination_first
is the numeric first record to return
tpl_pagination_offset
is the numeric offset of the return
tpl_pagination_cursor
is the numeric cursor of the return
required_kind
is string value of required argument kind Configure parameters
Retrieves authentication and schema information via unauthenticated API queries
configure()
namc_api$configure(force = FALSE)
force
is a boolean TRUE/FALSE to force a reconfiguration
namc_api An R6 class.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$configure() Graphql client retrieval Configures a graphql client with proper authentication and connection settings
get_connection()
namc_api$get_connection(authenticate = TRUE)
authenticate
boolean A logical TRUE/FALSE representing the required authentication state.
ghql::GraphqlClient A preconfigured graphql R6 class.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$get_connection(authenticate = TRUE) Introspect the API schema type Retrieves the raw schema return from introspecting the API schema type
get_api_types()
namc_api$get_api_types()
namc_api An R6 class.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$get_api_types() Builds a graphql schema Builds a graphql schema structure via introspection of the API. For all Query and Mutation graphql types the built structure stores all associated fields and dependent sub-types. This is used for the automated query builder as a convenience function.
build_schema()
namc_api$build_schema()
namc_api An R6 class.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$build_schema() schema = api$schema Query the API Executes a given graphql query against the API. If errors are returned execution is stopped.
query()
namc_api$query(query, authenticate = TRUE, name = "query")
query
string Text containing a graphql query
authenticate
boolean A logical TRUE/FALSE representing the required authentication state.
name
string A name for the query.
data.frame A dataframe contained the query result.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) data = api$query("graphql_query", ...) Authentication information retrieval Retrieves the clientId and domain required for authentication from the auth graphql endpoint.
get_auth_info()
namc_api$get_auth_info()
list A list containing the clientId and domain required for authentication.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) auth = api$get_auth_info() clientId = auth$clientId domain = auth$domain Get the authentication object Access method for the oAuth2 authentication object stored within this namc_api object.
get_auth_provider()
namc_api$get_auth_provider()
namc_api An R6 authentication class.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) auth = api$get_auth_provider() Authentication check Provides a logical depicting the state of the current authentication
is_authenticated()
namc_api$is_authenticated()
logical A logical TRUE/FALSE.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) authenticated = api$is_authenticated() Retrieve API endpoints Retrieves the API endpoint names from the schema
get_endpoints()
namc_api$get_endpoints()
vector A character vector.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) endpoints = api$get_endpoints() Retrieve fields Retrieves the fields associated with an API endpoint from the schema
get_endpoint_fields()
namc_api$get_endpoint_fields(api_endpoint)
api_endpoint
The name of an API endpoint.
vector A character vector of fields.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$get_endpoint_fields(api_endpoint = 'sites') Retrieve arguments Retrieves the arguments associated with an API endpoint from the schema
get_endpoint_args()
namc_api$get_endpoint_args(api_endpoint, no_paging = FALSE)
api_endpoint
The name of an API endpoint.
no_paging
Logical that omits the paging arguments by default
vector A character vector of arguments.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$get_endpoint_args(api_endpoint = 'sites') Retrieve fields Retrieves the fields associated with an API endpoint from the schema
is_endpoint()
namc_api$is_endpoint(api_endpoint, stop_if_not = FALSE)
api_endpoint
The name of an API endpoint.
stop_if_not
Logical TRUE/FALSE switch giving stop control to caller functions
vector A character vector.
api_config = list(...) # namc_api public or private variables api = namc_api$new(argList = api_config) api$get_endpoint_fields(api_endpoint = 'sites')
clone()
The objects of this class are cloneable with this method.
namc_api$clone(deep = FALSE)
deep
Whether to make a deep clone.
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
## ------------------------------------------------
## Method `namc_api$configure`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$configure()
Graphql client retrieval
Configures a graphql client with proper authentication and connection settings
## ------------------------------------------------
## Method `namc_api$get_connection`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_connection(authenticate = TRUE)
Introspect the API schema type
Retrieves the raw schema return from introspecting the API schema type
## ------------------------------------------------
## Method `namc_api$get_api_types`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_api_types()
Builds a graphql schema
Builds a graphql schema structure via introspection of the API.
For all Query and Mutation graphql types the built structure stores
all associated fields and dependent sub-types. This is used for the
automated query builder as a convenience function.
## ------------------------------------------------
## Method `namc_api$build_schema`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$build_schema()
schema = api$schema
Query the API
Executes a given graphql query against the API. If errors are returned execution is stopped.
## ------------------------------------------------
## Method `namc_api$query`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
data = api$query("graphql_query", ...)
Authentication information retrieval
Retrieves the clientId and domain required for authentication from the auth
graphql endpoint.
## ------------------------------------------------
## Method `namc_api$get_auth_info`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
auth = api$get_auth_info()
clientId = auth$clientId
domain = auth$domain
Get the authentication object
Access method for the oAuth2 authentication object stored within this namc_api object.
## ------------------------------------------------
## Method `namc_api$get_auth_provider`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
auth = api$get_auth_provider()
Authentication check
Provides a logical depicting the state of the current authentication
## ------------------------------------------------
## Method `namc_api$is_authenticated`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
authenticated = api$is_authenticated()
Retrieve API endpoints
Retrieves the API endpoint names from the schema
## ------------------------------------------------
## Method `namc_api$get_endpoints`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
endpoints = api$get_endpoints()
Retrieve fields
Retrieves the fields associated with an API endpoint from the schema
## ------------------------------------------------
## Method `namc_api$get_endpoint_fields`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_endpoint_fields(api_endpoint = 'sites')
Retrieve arguments
Retrieves the arguments associated with an API endpoint from the schema
## ------------------------------------------------
## Method `namc_api$get_endpoint_args`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_endpoint_args(api_endpoint = 'sites')
Retrieve fields
Retrieves the fields associated with an API endpoint from the schema
## ------------------------------------------------
## Method `namc_api$is_endpoint`
## ------------------------------------------------
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_endpoint_fields(api_endpoint = 'sites')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.