Documentation
¶
Overview ¶
Package client contains functions of client side library. It provides helper functions to write a client program to:
- Format query to catalog server.
- Receive and parse responses into go structs.
Index ¶
Constants ¶
const (
JSONFieldName = `Data` // Name of field in response containing json data.
)
Variables ¶
This section is empty.
Functions ¶
func ParseModule ¶
func ParseModule(resp string, queryName string) ([]oc.OpenconfigModuleCatalog_Organizations_Organization_Modules_Module, error)
ParseModule parses query results into slice of ygot go structs of Module. To use this function, graphQL query should always include raw JSON data field. It takes in two parameters: * resp: query response string in json format. * queryName: name of query users want to extract response from as GraphQL supports composing multiple queries into one request.
func ReadAuthToken ¶
ReadAuthToken takes in *filepath* of token file, reads token and returns token string. This token is used when server is deployed on Google Cloud Run and only avaiable to permitted users. In this case, users need to include a header with identity token to get access to catalog server. This token can be obtained via the command `glcoud auth print-identity-token`. Reference: https://cloud.google.com/sdk/gcloud/reference/auth/print-identity-token.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is struct of client containing token string. User should always use `NewClient` to initialize a Client struct.
func NewClient ¶
NewClient returns a new client pointer with filepath of `authentication token`. If filepath is "", then it means no filepath is given, set Client.token to "".
func (*Client) QueryServer ¶
QueryServer first generates a HTTP request that can be used to query catalog server. It then sends formatted query request (*req*) to catalog server and returns string of body if no errors encountered. It takes in query string, example query looks like: HOST_ADDR/query?query=GRAPHQL_QUERY.