apiclient

package
v0.0.0-...-2803a0f Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package apiclient provides a client for Dependabot update job API

Index

Constants

View Source
const (

	// UserAgent is the User-Agent sent with requests
	UserAgent = "dependabot-proxy/1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for Dependabot update job API

func New

func New(baseURL, token, jobID string, opts ...ClientOpt) *Client

New returns a new Client instance

func (*Client) ReportMetrics

func (c *Client) ReportMetrics(ctx context.Context, metricsData string) error

ReportMetrics sends metric data to the server.

func (*Client) RequestJITAccess

func (c *Client) RequestJITAccess(ctx *goproxy.ProxyCtx, endpoint string, username string, password string, account string, repo string) (*config.Credential, error)

RequestJITAccess asks the API to create a token with access to the specified repository. If username and password are provided, they are used for basic auth; otherwise the client's default token is used in the Authorization header.

type ClientInterface

type ClientInterface interface {
	ReportMetrics(ctx context.Context, metricsData string) error
}

type ClientOpt

type ClientOpt func(*Client)

ClientOpt is functional configuration.

func WithCircuitBreaker

func WithCircuitBreaker(breaker *circuit.Breaker) ClientOpt

WithCircuitBreaker customizes circuit breaker used by this API client.

func WithRequestBackoff

func WithRequestBackoff(policy backoff.Policy) ClientOpt

WithRequestBackoff customizes the backoff used by the client

func WithTransport

func WithTransport(transport *http.Transport) ClientOpt

WithTransport customizes the HTTP transport used by the API client.

type StatusCodeError

type StatusCodeError struct {
	StatusCode int
	Body       string
}

StatusCodeError is the error returned for non 2xx status code response

func (*StatusCodeError) Error

func (e *StatusCodeError) Error() string

func (*StatusCodeError) IsClientError

func (e *StatusCodeError) IsClientError() bool

IsClientError return true for 4xx responses

func (*StatusCodeError) IsServerError

func (e *StatusCodeError) IsServerError() bool

IsServerError return true for 5xx responses

Jump to

Keyboard shortcuts

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