api

package
v0.79.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package api defines the HTTP interface for the remote config backend

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized is the error that will be logged for the customer to see in case of a 401. We make it as
	// descriptive as possible (while not leaking data) to make RC onboarding easier
	ErrUnauthorized = errors.New("unauthorized. Please make sure your API key is valid and has the Remote Config scope")
	// ErrProxy is the error that will be logged if we suspect that there is a wrong proxy setup for remote-config.
	// It is displayed for any 4XX status code except 401
	ErrProxy = errors.New("4XX status code. This might be related to the proxy settings. " +
		"Please make sure the agent can reach Remote Configuration with the proxy setup",
	)
	// ErrGatewayTimeout is the error that will be logged if there is a gateway timeout
	ErrGatewayTimeout = errors.New("non-200 response code: 504")
	// ErrServiceUnavailable is the error that will be logged if there is the service is unavailable
	ErrServiceUnavailable = errors.New("non-200 response code: 503")
)

Functions

This section is empty.

Types

type API

type API interface {
	Fetch(context.Context, *pbgo.LatestConfigsRequest) (*pbgo.LatestConfigsResponse, error)
	FetchOrgData(context.Context) (*pbgo.OrgDataResponse, error)
	FetchOrgStatus(context.Context) (*pbgo.OrgStatusResponse, error)
	UpdatePARJWT(string)
	UpdateAPIKey(string)
}

API is the interface to implement for a configuration fetcher

type Auth

type Auth struct {
	APIKey    string
	PARJWT    string
	AppKey    string
	UseAppKey bool
}

Auth defines the possible Authentication data to access the RC backend

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

HTTPClient fetches configurations using HTTP requests

func NewHTTPClient

func NewHTTPClient(auth Auth, cfg model.Reader, baseURL *url.URL) (*HTTPClient, error)

NewHTTPClient returns a new HTTP configuration client

func (*HTTPClient) Fetch

Fetch remote configuration

func (*HTTPClient) FetchOrgData

func (c *HTTPClient) FetchOrgData(ctx context.Context) (*pbgo.OrgDataResponse, error)

FetchOrgData org data

func (*HTTPClient) FetchOrgStatus

func (c *HTTPClient) FetchOrgStatus(ctx context.Context) (*pbgo.OrgStatusResponse, error)

FetchOrgStatus returns the org and key status

func (*HTTPClient) NewWebSocket added in v0.70.0

func (c *HTTPClient) NewWebSocket(ctx context.Context, endpointPath string, extraHeaders http.Header) (*websocket.Conn, error)

NewWebSocket connects to the RC WebSocket backend and returns a new WebSocket connection or a connection / handshake error.

The "endpointPath" specifies the resource path to connect to, which is appended to the client baseURL. Any headers in "extraHeaders" are added into the handshake request after the standard auth headers

func (*HTTPClient) UpdateAPIKey added in v0.65.0

func (c *HTTPClient) UpdateAPIKey(apiKey string)

UpdateAPIKey allows for dynamic setting of a Private Action Runners JWT Token for authentication to the RC backend.

func (*HTTPClient) UpdatePARJWT added in v0.62.0

func (c *HTTPClient) UpdatePARJWT(jwt string)

UpdatePARJWT allows for dynamic setting of a Private Action Runners JWT Token for authentication to the RC backend.

Jump to

Keyboard shortcuts

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