client

package
v14.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package client provides a client for interacting with GitLab API

Package client provides functionality for interacting with HTTP clients

Index

Constants

This section is empty.

Variables

View Source
var ErrCafileNotFound = errors.New("cafile not found")

ErrCafileNotFound indicates that the specified CA file was not found

Functions

func DefaultTransport added in v14.21.0

func DefaultTransport() http.RoundTripper

func NewTransport added in v14.21.0

func NewTransport(next http.RoundTripper) http.RoundTripper

Types

type APIError added in v14.36.0

type APIError struct {
	Msg string
}

APIError represents an API error

func (*APIError) Error added in v14.36.0

func (e *APIError) Error() string

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse represents an error response from the API

type GitlabNetClient

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

GitlabNetClient is a client for interacting with GitLab API

func NewGitlabNetClient

func NewGitlabNetClient(
	user,
	password,
	secret string,
	httpClient *HTTPClient,
) (*GitlabNetClient, error)

NewGitlabNetClient creates a new GitlabNetClient instance

func (*GitlabNetClient) Do added in v14.18.0

func (c *GitlabNetClient) Do(request *http.Request) (*http.Response, error)

Do executes a request

func (*GitlabNetClient) DoRequest

func (c *GitlabNetClient) DoRequest(ctx context.Context, method, path string, data interface{}) (*http.Response, error)

DoRequest executes a request with the given method, path, and data

func (*GitlabNetClient) Get

func (c *GitlabNetClient) Get(ctx context.Context, path string) (*http.Response, error)

Get makes a GET request

func (*GitlabNetClient) Post

func (c *GitlabNetClient) Post(ctx context.Context, path string, data interface{}) (*http.Response, error)

Post makes a POST request

func (*GitlabNetClient) SetUserAgent

func (c *GitlabNetClient) SetUserAgent(ua string)

SetUserAgent overrides the default user agent for the User-Agent header field for subsequent requests for the GitlabNetClient

type HTTPClient added in v14.36.0

type HTTPClient struct {
	RetryableHTTP *retryablehttp.Client
	Host          string
}

HTTPClient provides an HTTP client with retry capabilities

func NewHTTPClientWithOpts

func NewHTTPClientWithOpts(gitlabURL, gitlabRelativeURLRoot, caFile, caPath string, readTimeoutSeconds uint64, opts []HTTPClientOpt) (*HTTPClient, error)

NewHTTPClientWithOpts builds an HTTP client using the provided options

type HTTPClientOpt

type HTTPClientOpt func(*httpClientCfg)

HTTPClientOpt provides options for configuring an HttpClient

func WithClientCert

func WithClientCert(certPath, keyPath string) HTTPClientOpt

WithClientCert will configure the HttpClient to provide client certificates when connecting to a server.

func WithHTTPRetryOpts added in v14.16.0

func WithHTTPRetryOpts(waitMin, waitMax time.Duration, maxAttempts int) HTTPClientOpt

WithHTTPRetryOpts configures HTTP retry options for the HttpClient

type OriginalRemoteIPContextKey

type OriginalRemoteIPContextKey struct{}

OriginalRemoteIPContextKey is used as the key in a Context to set an X-Forwarded-For header in a request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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