client

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet    = requestMethod("GET")
	MethodPost   = requestMethod("POST")
	MethodPut    = requestMethod("PUT")
	MethodPatch  = requestMethod("PATCH")
	MethodDelete = requestMethod("DELETE")
)

Variables

This section is empty.

Functions

func NormalizeURL

func NormalizeURL(u string) string

Types

type AuthMethod

type AuthMethod string
const (
	IAMOauth2     AuthMethod = "IamOauth2"
	IAMUserOauth2 AuthMethod = "IamUserOauth2"
)

type HTTPClient

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

func NewHTTPClient

func NewHTTPClient() *HTTPClient

func (*HTTPClient) DoRequest

func (hc *HTTPClient) DoRequest(ctx context.Context, url string, preq *Request) (*http.Response, error)

func (*HTTPClient) WithDefaultHeaders

func (hc *HTTPClient) WithDefaultHeaders(kvPairs ...string) *HTTPClient

func (*HTTPClient) WithReauthFunc

func (hc *HTTPClient) WithReauthFunc(authOpt AuthMethod, reauthFunc func(ctx context.Context) (*Token, error)) *HTTPClient

func (*HTTPClient) WithRetryCount

func (hc *HTTPClient) WithRetryCount(retryCount int) *HTTPClient

func (*HTTPClient) WithRetryInterval

func (hc *HTTPClient) WithRetryInterval(interval time.Duration) *HTTPClient

func (*HTTPClient) WithTimeout

func (hc *HTTPClient) WithTimeout(timeout time.Duration) *HTTPClient

func (*HTTPClient) WithTransport

func (hc *HTTPClient) WithTransport(t http.RoundTripper) *HTTPClient

WithTransport sets a custom RoundTripper on the SDK's default http.Client.

func (*HTTPClient) WithUnderlyingClient

func (hc *HTTPClient) WithUnderlyingClient(c *http.Client) *HTTPClient

WithUnderlyingClient replaces the SDK's default http.Client with the provided one. Auth, retry, and header injection still apply on top of it.

type Request

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

func NewRequest

func NewRequest() *Request

func (*Request) WithHeader

func (r *Request) WithHeader(key, value string) *Request

func (*Request) WithJSONBody

func (r *Request) WithJSONBody(jsonBody any) *Request

func (*Request) WithJSONError

func (r *Request) WithJSONError(jsonError any) *Request

func (*Request) WithJSONResponse

func (r *Request) WithJSONResponse(jsonResponse any) *Request

func (*Request) WithOKCodes

func (r *Request) WithOKCodes(okCodes ...int) *Request

func (*Request) WithSkipAuth

func (r *Request) WithSkipAuth(skipAuth bool) *Request

func (*Request) WithUserID

func (r *Request) WithUserID(userID string) *Request

type ServiceClient

type ServiceClient struct {
	Endpoint  string
	ProjectID string
	ZoneID    string
	HTTP      *HTTPClient
}

func (*ServiceClient) Delete

func (sc *ServiceClient) Delete(ctx context.Context, url string, req *Request) (*http.Response, error)

func (*ServiceClient) Get

func (sc *ServiceClient) Get(ctx context.Context, url string, req *Request) (*http.Response, error)

func (*ServiceClient) Patch

func (sc *ServiceClient) Patch(ctx context.Context, url string, req *Request) (*http.Response, error)

func (*ServiceClient) Post

func (sc *ServiceClient) Post(ctx context.Context, url string, req *Request) (*http.Response, error)

func (*ServiceClient) Put

func (sc *ServiceClient) Put(ctx context.Context, url string, req *Request) (*http.Response, error)

func (*ServiceClient) ServiceURL

func (sc *ServiceClient) ServiceURL(parts ...string) string

type Token

type Token struct {
	AccessToken string
	ExpiresAt   int64
}

func (*Token) NeedsReauth

func (t *Token) NeedsReauth() bool

Jump to

Keyboard shortcuts

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