Documentation
¶
Overview ¶
Package client is a package that provides a client for making HTTP requests to the Ocular API. It handles authentication and token management. See the default crawler command for examples on how to use it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StaticTokenOpt = func(token string) Opt { return func(c *Client) error { c.client.Transport = &tokenFileTransport{ base: c.client.Transport, retriever: staticToken{ token: token, }, } return nil } }
StaticTokenOpt sets a static token for the client. The token is used for authentication in requests. The token is not refreshed.
var TokenFileOpt = func(tokenFile string, refreshDuration time.Duration) Opt { return func(c *Client) error { c.client.Transport = &tokenFileTransport{ base: c.client.Transport, retriever: tokenFileRetriever{ file: tokenFile, refresh: refreshDuration, }, } return nil } }
TokenFileOpt sets the token file for the client. The token is retrieved from the contents of the file, located at tokenFile. The token file is refreshed every refreshDuration.
var WithContextName = func(ctx string) Opt { return func(c *Client) error { c.client.Transport = &contextTransport{ base: c.client.Transport, ctx: ctx, } return nil } }
WithContextName sets the context name for the client in requests.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a struct that represents a client for making HTTP requests to the Ocular API.
func NewClient ¶
NewClient creates a new client for making HTTP requests to the Ocular API. baseURL is the base URL of the API server. c is an optional http.Client. Additional options are specified as a list of Opt
func (*Client) CreatePipeline ¶
func (c *Client) CreatePipeline( ctx context.Context, profile string, target schemas.Target, ) (schemas.Pipeline, error)
CreatePipeline creates a new pipeline in the Ocular server. It will return a [responses.Pipeline] object on success or an error if the request fails.