Documentation
¶
Index ¶
- Constants
- func NormalizeURL(u string) string
- type AuthMethod
- type HTTPClient
- func (hc *HTTPClient) DoRequest(ctx context.Context, url string, preq *Request) (*http.Response, error)
- func (hc *HTTPClient) WithDefaultHeaders(kvPairs ...string) *HTTPClient
- func (hc *HTTPClient) WithReauthFunc(authOpt AuthMethod, reauthFunc func(ctx context.Context) (*Token, error)) *HTTPClient
- func (hc *HTTPClient) WithRetryCount(retryCount int) *HTTPClient
- func (hc *HTTPClient) WithRetryInterval(interval time.Duration) *HTTPClient
- func (hc *HTTPClient) WithTimeout(timeout time.Duration) *HTTPClient
- func (hc *HTTPClient) WithTransport(t http.RoundTripper) *HTTPClient
- func (hc *HTTPClient) WithUnderlyingClient(c *http.Client) *HTTPClient
- type Request
- func (r *Request) WithHeader(key, value string) *Request
- func (r *Request) WithJSONBody(jsonBody any) *Request
- func (r *Request) WithJSONError(jsonError any) *Request
- func (r *Request) WithJSONResponse(jsonResponse any) *Request
- func (r *Request) WithOKCodes(okCodes ...int) *Request
- func (r *Request) WithSkipAuth(skipAuth bool) *Request
- func (r *Request) WithUserID(userID string) *Request
- type ServiceClient
- func (sc *ServiceClient) Delete(ctx context.Context, url string, req *Request) (*http.Response, error)
- func (sc *ServiceClient) Get(ctx context.Context, url string, req *Request) (*http.Response, error)
- func (sc *ServiceClient) Patch(ctx context.Context, url string, req *Request) (*http.Response, error)
- func (sc *ServiceClient) Post(ctx context.Context, url string, req *Request) (*http.Response, error)
- func (sc *ServiceClient) Put(ctx context.Context, url string, req *Request) (*http.Response, error)
- func (sc *ServiceClient) ServiceURL(parts ...string) string
- type Token
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 ¶
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) 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 (*Request) WithJSONBody ¶
func (*Request) WithJSONError ¶
func (*Request) WithJSONResponse ¶
func (*Request) WithOKCodes ¶
func (*Request) WithSkipAuth ¶
func (*Request) WithUserID ¶
type ServiceClient ¶
type ServiceClient struct {
Endpoint string
ProjectID string
ZoneID string
HTTP *HTTPClient
}
func (*ServiceClient) ServiceURL ¶
func (sc *ServiceClient) ServiceURL(parts ...string) string
Click to show internal directories.
Click to hide internal directories.