Documentation ¶
Overview ¶
client package contains the primiteves to create a new http client for connecting to Mia-Platform Console using the connection options passed to it.
It also manage the authentication, renewal and re authentication if necessary.
Index ¶
- func RegisterAuthProvider(ap AuthProviderCreator) error
- type APIClient
- type AuthCacheReadWriter
- type AuthConfig
- type AuthProvider
- type AuthProviderCreator
- type Config
- type Interface
- type Request
- func (r *Request) APIPath(apiPath string) *Request
- func (r *Request) Body(bodyBytes []byte) *Request
- func (r *Request) Do(ctx context.Context) (*Response, error)
- func (r *Request) Error() error
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetParam(key string, values ...string) *Request
- func (r *Request) SetVerb(verb string) *Request
- func (r *Request) Stream(ctx context.Context) (io.ReadCloser, error)
- func (r *Request) URL() *url.URL
- type Response
- type ResponseError
- type TLSClientConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAuthProvider ¶
func RegisterAuthProvider(ap AuthProviderCreator) error
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient wrap an http.Client that can connect to Mia-Platform Console
func APIClientForConfig ¶
APIClientForConfig create a APIClient with config
func (*APIClient) Delete ¶ added in v0.8.0
Delete return a new Request object for a DELETE http request
func (*APIClient) HTTPClient ¶ added in v0.6.1
type AuthCacheReadWriter ¶
type AuthConfig ¶
type AuthConfig struct { ClientID string ClientSecret string JWTKeyID string JWTPrivateKeyData string }
AuthConfig contains settings for settign up authentication for the http requests
type AuthProvider ¶
type AuthProvider interface { // Wrap allow the AuthProvider to add authorization functionality on // a modified RoundTripper and to add the appropriate Authorization header to the request Wrap(http.RoundTripper) http.RoundTripper }
type AuthProviderCreator ¶
type AuthProviderCreator func(*Config, AuthCacheReadWriter, AuthConfig) AuthProvider
AuthProviderCreator is a function that return an AuthProvider
type Config ¶
type Config struct { // Host must be a host string, a host:port pair, or a URL to the base of the server. // If a URL is given then the (optional) Path of that URL represents a prefix that must // be appended to all request URIs used to access the server. This allows a frontend // proxy to easily relocate all of the server endpoints. Host string // TLSClientConfig contains settings to enable transport layer security TLSClientConfig // UserAgent is an optional field that specifies the caller of this request. UserAgent string // Transport add a custom transport instead of creating a new one. Wrappers will be added to it Transport http.RoundTripper // AuthConfig contains settings for settign up authentication for the http requests AuthConfig // AuthCacheReadWriter provides access to authorization cache AuthCacheReadWriter // CompanyID contains the company id that can be used for filtering requests CompanyID string // ProjectID contains the project id that can be used for filtering requests ProjectID string // Environment contains the environment scope that can be used for filtering requests Environment string // The maximum length of time to wait before giving up on a server request. A value of zero means no timeout. Timeout time.Duration }
Config holds the common attributes that can be passed to a client on initialization
type Interface ¶
type Interface interface { Delete() *Request Get() *Request Post() *Request Patch() *Request HTTPClient() *http.Client }
Interface captures the set of operations for interacting with REST apis
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request wrap the http.Request configuration providing functions for configure it in an easier and contained way
func NewRequest ¶
NewRequest creates a new request helper object for calling Mia-Platform Console API
func (*Request) APIPath ¶
APIPath set the apiPath for the request, if apiPath cannot be parse as a valid path an error can be found with the Error function. It will be ensured that the path will always end with /.
func (*Request) Body ¶
Body set the body of the request if no error has been found in the request construction
func (*Request) SetHeader ¶
SetHeader add the passed value for the header key, if the key aldready exists, it will be removed
func (*Request) SetParam ¶
SetParam set the HTTP query params key to value if no error has been found in the request construction
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response wrap an http.Response and provide functions to operate safely on it
func (*Response) ParseResponse ¶
ParseResponse will parse the underlying body inside the obj passed
func (*Response) RawRequest ¶
RawRequest return the original request if you need to access things not exposed by the other functions
func (*Response) StatusCode ¶
Error return the response status code
type ResponseError ¶
type ResponseError struct {
// contains filtered or unexported fields
}
ResponseError represent an error from an api call
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
Error return the message of the api call error
type TLSClientConfig ¶
type TLSClientConfig struct { // Server should be accessed without verifying the TLS certificate. For testing only. Insecure bool // Trusted root certificates for server CAFile string }
TLSClientConfig contains settings to enable transport layer security