client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

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

View Source
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.

View Source
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.

View Source
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

func NewClient(baseURL string, c *http.Client, opts ...Opt) (*Client, error)

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.

type Opt

type Opt func(*Client) error

Opt is a function that configures A Client.

Jump to

Keyboard shortcuts

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