namc_api: namc_api

namc_apiR Documentation

namc_api

Description

R6 class for handling NAMC GraphQL queries

Value

a namc_api class (R6 class)

Super class

NAMCr::base_class -> namc_api

Public fields

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

Methods

Public methods

Inherited methods

Method configure()

Usage
namc_api$configure(force = FALSE)
Arguments
force

is a boolean TRUE/FALSE to force a reconfiguration

Returns

namc_api An R6 class.

Examples
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 get_connection()

Usage
namc_api$get_connection(authenticate = TRUE)
Arguments
authenticate

boolean A logical TRUE/FALSE representing the required authentication state.

Returns

ghql::GraphqlClient A preconfigured graphql R6 class.

Examples
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 get_api_types()

Usage
namc_api$get_api_types()
Returns

namc_api An R6 class.

Examples
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 build_schema()

Usage
namc_api$build_schema()
Returns

namc_api An R6 class.

Examples
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 query()

Usage
namc_api$query(query, authenticate = TRUE, name = "query")
Arguments
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.

Returns

data.frame A dataframe contained the query result.

Examples
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 get_auth_info()

Usage
namc_api$get_auth_info()
Returns

list A list containing the clientId and domain required for authentication.

Examples
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 get_auth_provider()

Usage
namc_api$get_auth_provider()
Returns

namc_api An R6 authentication class.

Examples
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 is_authenticated()

Usage
namc_api$is_authenticated()
Returns

logical A logical TRUE/FALSE.

Examples
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 get_endpoints()

Usage
namc_api$get_endpoints()
Returns

vector A character vector.

Examples
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 get_endpoint_fields()

Usage
namc_api$get_endpoint_fields(api_endpoint)
Arguments
api_endpoint

The name of an API endpoint.

Returns

vector A character vector of fields.

Examples
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 get_endpoint_args()

Usage
namc_api$get_endpoint_args(api_endpoint, no_paging = FALSE)
Arguments
api_endpoint

The name of an API endpoint.

no_paging

Logical that omits the paging arguments by default

Returns

vector A character vector of arguments.

Examples
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 is_endpoint()

Usage
namc_api$is_endpoint(api_endpoint, stop_if_not = FALSE)
Arguments
api_endpoint

The name of an API endpoint.

stop_if_not

Logical TRUE/FALSE switch giving stop control to caller functions

Returns

vector A character vector.

Examples
api_config = list(...) # namc_api public or private variables
api = namc_api$new(argList = api_config)
api$get_endpoint_fields(api_endpoint = 'sites')


Method clone()

The objects of this class are cloneable with this method.

Usage
namc_api$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


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')


namc-utah/NAMCr documentation built on Feb. 12, 2024, 4:29 a.m.