Documentation ¶
Index ¶
- type HTTPClient
- type Request
- func (r *Request) AbsPath(segments ...string) *Request
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do() Result
- func (r *Request) DoRaw() ([]byte, error)
- func (r *Request) FieldsSelectorParam(s fields.Selector) *Request
- func (r *Request) LabelsSelectorParam(s labels.Selector) *Request
- func (r *Request) Name(resourceName string) *Request
- func (r *Request) Namespace(namespace string) *Request
- func (r *Request) NamespaceIfScoped(namespace string, scoped bool) *Request
- func (r *Request) Param(paramName, s string) *Request
- func (r *Request) Prefix(segments ...string) *Request
- func (r *Request) RequestURI(uri string) *Request
- func (r *Request) Resource(resource string) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) Stream() (io.ReadCloser, error)
- func (r *Request) SubResource(subresources ...string) *Request
- func (r *Request) Suffix(segments ...string) *Request
- func (r *Request) Timeout(d time.Duration) *Request
- func (r *Request) URL() *url.URL
- func (r *Request) UintParam(paramName string, u uint64) *Request
- func (r *Request) VersionedParams(obj runtime.Object, codec runtime.ParameterCodec) *Request
- func (r *Request) Watch() (watch.Interface, error)
- type RequestConstructionError
- type ResponseWrapper
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPClient ¶
HTTPClient is an interface for testing a request object.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.
func NewRequest ¶
func NewRequest(client HTTPClient, verb string, baseURL *url.URL, versionedAPIPath string, content ContentConfig, serializers Serializers, backoff BackoffManager, throttle flowcontrol.RateLimiter) *Request
NewRequest creates a new request helper object for accessing runtime.Objects on a server.
func (*Request) AbsPath ¶
AbsPath overwrites an existing path with the segments provided. Trailing slashes are preserved when a single segment is passed.
func (*Request) Body ¶
Body makes the request use obj as the body. Optional. If obj is a string, try to read a file of that name. If obj is a []byte, send it directly. If obj is an io.Reader, use it directly. If obj is a runtime.Object, marshal it correctly, and set Content-Type header. If obj is a runtime.Object and nil, do nothing. Otherwise, set an error.
func (*Request) Do ¶
Do formats and executes the request. Returns a Result object for easy response processing.
Error type:
- If the request can't be constructed, or an error happened earlier while building its arguments: *RequestConstructionError
- If the server responds with a status: *errors.StatusError or *errors.UnexpectedObjectError
- http.Client.Do errors are returned directly.
func (*Request) FieldsSelectorParam ¶
FieldsSelectorParam adds the given selector as a query parameter with the name paramName.
func (*Request) LabelsSelectorParam ¶
LabelsSelectorParam adds the given selector as a query parameter
func (*Request) Name ¶
Name sets the name of a resource to access (<resource>/[ns/<namespace>/]<name>)
func (*Request) Namespace ¶
Namespace applies the namespace scope to a request (<resource>/[ns/<namespace>/]<name>)
func (*Request) NamespaceIfScoped ¶
NamespaceIfScoped is a convenience function to set a namespace if scoped is true
func (*Request) Prefix ¶
Prefix adds segments to the relative beginning to the request path. These items will be placed before the optional Namespace, Resource, or Name sections. Setting AbsPath will clear any previously set Prefix segments
func (*Request) RequestURI ¶
RequestURI overwrites existing path and parameters with the value of the provided server relative URI. Some parameters (those in specialParameters) cannot be overwritten.
func (*Request) Resource ¶
Resource sets the resource to access (<resource>/[ns/<namespace>/]<name>)
func (*Request) Stream ¶
func (r *Request) Stream() (io.ReadCloser, error)
Stream formats and executes the request, and offers streaming of the response. Returns io.ReadCloser which could be used for streaming of the response, or an error Any non-2xx http status code causes an error. If we get a non-2xx code, we try to convert the body into an APIStatus object. If we can, we return that as an error. Otherwise, we create an error that lists the http status and the content of the response.
func (*Request) SubResource ¶
SubResource sets a sub-resource path which can be multiple segments segment after the resource name but before the suffix.
func (*Request) Suffix ¶
Suffix appends segments to the end of the path. These items will be placed after the prefix and optional Namespace, Resource, or Name sections.
func (*Request) Timeout ¶
Timeout makes the request use the given duration as a timeout. Sets the "timeout" parameter.
func (*Request) VersionedParams ¶
VersionedParams will take the provided object, serialize it to a map[string][]string using the implicit RESTClient API version and the default parameter codec, and then add those as parameters to the request. Use this to provide versioned query parameters from client libraries.
type RequestConstructionError ¶
type RequestConstructionError struct {
Err error
}
RequestConstructionError is returned when there's an error assembling a request.
func (*RequestConstructionError) Error ¶
func (r *RequestConstructionError) Error() string
Error returns a textual description of 'r'.
type ResponseWrapper ¶
type ResponseWrapper interface { DoRaw() ([]byte, error) Stream() (io.ReadCloser, error) }
ResponseWrapper is an interface for getting a response. The response may be either accessed as a raw data (the whole output is put into memory) or as a stream.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result contains the result of calling Request.Do().
func (Result) Error ¶
Error returns the error executing the request, nil if no error occurred. See the Request.Do() comment for what errors you might get.
func (Result) StatusCode ¶
StatusCode returns the HTTP status code of the request. (Only valid if no error was returned.)
func (Result) WasCreated ¶
WasCreated updates the provided bool pointer to whether the server returned 201 created or a different response.