Documentation
¶
Index ¶
- func HasStatusErr(err error, codes ...int) bool
- func HasValidStatusCode(code int, acceptStatuses ...int) bool
- func IsNotFoundError(err error) bool
- type APICallType
- type RequestConfiguration
- type Response
- type StatusError
- type UnstructuredClient
- func (u *UnstructuredClient) Call(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration) (Response, error)
- func (u *UnstructuredClient) CallFindBySingle(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration) (Response, error)
- func (u *UnstructuredClient) CallForPagination(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration, ...) (Response, *http.Response, error)
- func (u *UnstructuredClient) FindBy(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration, ...) (Response, error)
- func (u *UnstructuredClient) RequestedBody(httpMethod string, path string) (bodyParams stringset.StringSet, err error)
- func (u *UnstructuredClient) RequestedParams(httpMethod string, path string) (parameters, query, headers, cookies stringset.StringSet, err error)
- func (u *UnstructuredClient) ValidateRequest(httpMethod string, path string, parameters map[string]string, ...) error
- type UnstructuredClientInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasStatusErr ¶
HasStatusErr returns true if err is a ResponseError caused by any of the codes given.
func HasValidStatusCode ¶
func IsNotFoundError ¶
Types ¶
type APICallType ¶
type APICallType string
type RequestConfiguration ¶
type Response ¶
type Response struct {
ResponseBody any
// contains filtered or unexported fields
}
TODO: maybe consider to wrap http.Response in our Response struct to have access to headers, status code, etc. In order to have isPending method attached to a complete response object.
type StatusError ¶
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Unwrap ¶
func (e *StatusError) Unwrap() error
type UnstructuredClient ¶
type UnstructuredClient struct {
IdentifierFields []string
IdentifiersMatchPolicy string
Resource *unstructured.Unstructured
//Doc libopenapi.Document // Parsed OpenAPI document by libopenapi, needed for http request validation. TODO: to be re-enabled when libopenapi-validator is stable
DocScheme *libopenapi.DocumentModel[v3.Document] // OpenAPI document model (high-level)
Server string
Debug bool
SetAuth func(req *http.Request)
}
func BuildClient ¶
func BuildClient(ctx context.Context, kubeclient dynamic.Interface, swaggerPath string) (*UnstructuredClient, error)
BuildClient is a function that builds partial client from a swagger file.
func (*UnstructuredClient) Call ¶
func (u *UnstructuredClient) Call(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration) (Response, error)
func (*UnstructuredClient) CallFindBySingle ¶
func (u *UnstructuredClient) CallFindBySingle(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration) (Response, error)
CallFindBySingle executes a non-paginated FindBy operation.
func (*UnstructuredClient) CallForPagination ¶
func (u *UnstructuredClient) CallForPagination(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration, paginator pagination.Paginator) (Response, *http.Response, error)
CallForPagination builds an `http.Request`, lets the paginator update it, executes it, and returns the response. TODO: to be refactored to avoid code duplication with Call method. Prerequisite for refactor is to change the Response struct to wrap http.Response directly. Differences with Call are mainly the paginator usage and the removal of debug transport setup (otherwise it would be set incrementally on each paginated call).
func (*UnstructuredClient) FindBy ¶
func (u *UnstructuredClient) FindBy(ctx context.Context, cli *http.Client, path string, opts *RequestConfiguration, findByAction *getter.VerbsDescription) (Response, error)
FindBy locates a specific resource within an API response it retrieves. It serves as the primary orchestrator for the `FindBy` action of the Rest Dynamic Controller, delegating response parsing and item matching to helper functions: extractItemsFromResponse, findItemInList, and isItemMatch.
func (*UnstructuredClient) RequestedBody ¶
func (u *UnstructuredClient) RequestedBody(httpMethod string, path string) (bodyParams stringset.StringSet, err error)
RequestedBody is a method that returns the body parameters for a given HTTP method and path.
func (*UnstructuredClient) RequestedParams ¶
func (u *UnstructuredClient) RequestedParams(httpMethod string, path string) (parameters, query, headers, cookies stringset.StringSet, err error)
RequestedParams is a method that returns the parameters and query parameters for a given HTTP method and path.
func (*UnstructuredClient) ValidateRequest ¶
func (u *UnstructuredClient) ValidateRequest(httpMethod string, path string, parameters map[string]string, query map[string]string, headers map[string]string, cookies map[string]string) error
ValidateRequest is a method that validates the request parameters, query, headers, and cookies against the OpenAPI document. It checks if the required parameters are present and returns an error if any required parameter is missing.
type UnstructuredClientInterface ¶
type UnstructuredClientInterface interface {
ValidateRequest(httpMethod string, path string, parameters map[string]string, query map[string]string, headers map[string]string, cookies map[string]string) error
RequestedBody(httpMethod string, path string) (bodys stringset.StringSet, err error)
RequestedParams(httpMethod string, path string) (parameters, query, headers, cookies stringset.StringSet, err error)
FindBy(ctx context.Context, cli *http.Client, path string, conf *RequestConfiguration, findByAction *getter.VerbsDescription) (Response, error)
Call(ctx context.Context, cli *http.Client, path string, conf *RequestConfiguration) (Response, error)
}