client

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package client implements some interfaces and convenience methods to interact with Vercel APIs and Remote Cache

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyFailures = errors.New("skipping HTTP Request, too many failures have occurred")

ErrTooManyFailures is returned from remote cache API methods after `maxRemoteFailCount` errors have occurred

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	HTTPClient *retryablehttp.Client
	// contains filtered or unexported fields
}

APIClient is the main interface for making network requests to Vercel

func NewClient

func NewClient(config turbostate.APIClientConfig, logger hclog.Logger, turboVersion string) *APIClient

NewClient creates a new APIClient

func (*APIClient) ArtifactExists

func (c *APIClient) ArtifactExists(hash string) (*http.Response, error)

ArtifactExists attempts to determine if the build artifact with the given hash exists in the Remote Caching server

func (*APIClient) FetchArtifact

func (c *APIClient) FetchArtifact(hash string) (*http.Response, error)

FetchArtifact attempts to retrieve the build artifact with the given hash from the remote cache

func (*APIClient) GetTeamID

func (c *APIClient) GetTeamID() string

GetTeamID returns the currently configured team id

func (*APIClient) IsLinked

func (c *APIClient) IsLinked() bool

IsLinked returns true if we have a user and linked team

func (*APIClient) JSONPatch

func (c *APIClient) JSONPatch(ctx context.Context, endpoint string, body []byte) ([]byte, error)

JSONPatch sends a byte array (json.marshalled payload) to a given endpoint with PATCH

func (*APIClient) JSONPost

func (c *APIClient) JSONPost(ctx context.Context, endpoint string, body []byte) ([]byte, error)

JSONPost sends a byte array (json.marshalled payload) to a given endpoint with POST

func (*APIClient) PutArtifact

func (c *APIClient) PutArtifact(hash string, artifactBody []byte, duration int, tag string) error

PutArtifact uploads an artifact associated with a given hash string to the remote cache

func (*APIClient) RecordAnalyticsEvents

func (c *APIClient) RecordAnalyticsEvents(ctx context.Context, events []map[string]interface{}) error

RecordAnalyticsEvents is a specific method for POSTing events to Vercel

func (*APIClient) SetToken

func (c *APIClient) SetToken(token string)

SetToken updates the APIClient's Token

Jump to

Keyboard shortcuts

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