rest

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: GPL-3.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBody added in v2.1.9

func CopyBody(req *http.Request) ([]byte, error)

func Decode

func Decode(body io.ReadCloser, v interface{}) error

func ExponentialBackoff added in v2.1.9

func ExponentialBackoff(retry int)

func IsClosedConnectionErr added in v2.1.9

func IsClosedConnectionErr(err error) bool

func NewClientAssertion

func NewClientAssertion(tokenUrl string, clientId string, clientCert string, signingKey string, keyPassphrase string) (string, error)

func NewHTTPClient

func NewHTTPClient(proxyUrl string) (*http.Client, error)

func NewRequest

func NewRequest(
	ctx context.Context,
	verb string,
	endpoint *url.URL,
	body interface{},
	params map[string]string,
	headers map[string]string,
) (*http.Request, error)

func ParseAud

func ParseAud(accessToken string) (string, error)

func ParseBody

func ParseBody(accessToken string) (map[string]interface{}, error)

Types

type AuthStrategy added in v2.3.0

type AuthStrategy interface {
	// contains filtered or unexported methods
}

AuthStrategy is an interface that defines the methods that an authentication strategy must implement

type Authenticator added in v2.3.0

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

Authenticator manages the authentication process, using a specific AuthStrategy

func NewGenericAuthenticator added in v2.3.0

func NewGenericAuthenticator(config config.Config, auth *url.URL, api *url.URL) *Authenticator

NewGenericAuthenticator creates a new Authenticator using the GenericAuthStrategy (The collection of pre-existing authentication methods)

func NewManagedIdentityAuthenticator added in v2.3.0

func NewManagedIdentityAuthenticator(config config.Config, auth *url.URL, api *url.URL, http *http.Client) *Authenticator

NewManagedIdentityAuthenticator creates a new Authenticator using the ManagedIdentityAuthStrategy

func (*Authenticator) AddAuthenticationToRequest added in v2.3.0

func (s *Authenticator) AddAuthenticationToRequest(restClient *restClient, req *http.Request) (*http.Request, error)

Authenticate if needed and add authentication to the request

type GenericAuthStrategy added in v2.3.0

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

GenericAuthStrategy is an authentication strategy that uses a bunch of pre-existing authentication methods (TODO: Break this up)

type IntOrStringInt added in v2.3.0

type IntOrStringInt int

Authentication response expires_in may be a string of digits or just an int

func (*IntOrStringInt) UnmarshalJSON added in v2.3.0

func (ios *IntOrStringInt) UnmarshalJSON(data []byte) error

type ManagedIdentityAuthStrategy added in v2.3.0

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

ManagedIdentityAuthStrategy is an authentication strategy that uses Azure Managed Identity

type RestClient

type RestClient interface {
	Delete(ctx context.Context, path string, body interface{}, params query.Params, headers map[string]string) (*http.Response, error)
	Get(ctx context.Context, path string, params query.Params, headers map[string]string) (*http.Response, error)
	Patch(ctx context.Context, path string, body interface{}, params query.Params, headers map[string]string) (*http.Response, error)
	Post(ctx context.Context, path string, body interface{}, params query.Params, headers map[string]string) (*http.Response, error)
	Put(ctx context.Context, path string, body interface{}, params query.Params, headers map[string]string) (*http.Response, error)
	Send(req *http.Request) (*http.Response, error)
	AddAuthenticationToRequest(req *http.Request) (*http.Request, error)
	CloseIdleConnections()
}

func NewRestClient

func NewRestClient(apiUrl string, config config.Config) (RestClient, error)

type Token

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

func (Token) IsExpired

func (s Token) IsExpired() bool

func (Token) String

func (s Token) String() string

func (*Token) UnmarshalJSON

func (s *Token) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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