client

package
v0.0.0-...-b66c160 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

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

View Source
const (
	JSONFieldName = `Data` // Name of field in response containing json data.
)

Variables

This section is empty.

Functions

func ParseModule

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

func ReadAuthToken(filepath string) (string, error)

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

func NewClient(filepath string) (*Client, error)

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

func (c *Client) QueryServer(query string) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL