core

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BCE_REQUEST_ID = "x-pf-request-id"
	BCE_DATE       = "x-pf-date"
)

Constants of the HTTP headers for paddleFlow

View Source
const (
	EACCESS_DENIED        = "AccessDenied"
	EINTERNAL_ERROR       = "InternalError"
	EINVALID_HTTP_REQUEST = "InvalidHTTPRequest"
	EMALFORMED_JSON       = "MalformedJSON"
	EPRECONDITION_FAILED  = "PreconditionFailed"
)
View Source
const (
	API_V1_PREFIX = "/api/core/v1"
)

Variables

This section is empty.

Functions

func NewRequestBodyWithStruct

func NewRequestBodyWithStruct(body interface{}) (io.ReadCloser, error)

Types

type Client

type Client interface {
	SendRequest(*PFRequest) (*PFResponse, error)
}

Client is the general interface which can perform sending request. Different service will define its own client in case of specific extension.

type PFRequest

type PFRequest struct {
	http.Request
	// contains filtered or unexported fields
}

func (*PFRequest) BuildHttpRequest

func (b *PFRequest) BuildHttpRequest()

func (*PFRequest) RequestId

func (b *PFRequest) RequestId() string

func (*PFRequest) SetRequestId

func (b *PFRequest) SetRequestId(val string)

func (*PFRequest) String

func (b *PFRequest) String() string

type PFResponse

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

func (*PFResponse) Body

func (r *PFResponse) Body() io.ReadCloser

func (*PFResponse) ElapsedTime

func (r *PFResponse) ElapsedTime() time.Duration

func (*PFResponse) Header

func (r *PFResponse) Header(key string) string

func (*PFResponse) Headers

func (r *PFResponse) Headers() map[string]string

func (*PFResponse) IsFail

func (r *PFResponse) IsFail() bool

func (*PFResponse) ParseJsonBody

func (r *PFResponse) ParseJsonBody(result interface{}) error

func (*PFResponse) ParseResponse

func (r *PFResponse) ParseResponse()

func (*PFResponse) RequestId

func (r *PFResponse) RequestId() string

func (*PFResponse) ServiceError

func (r *PFResponse) ServiceError() *PFServiceError

func (*PFResponse) SetHttpResponse

func (r *PFResponse) SetHttpResponse(response *http.Response)

func (*PFResponse) StatusCode

func (r *PFResponse) StatusCode() int

func (*PFResponse) StatusText

func (r *PFResponse) StatusText() string

type PFServiceError

type PFServiceError struct {
	Code       string
	Message    string
	RequestId  string
	StatusCode int
}

func NewPFServiceError

func NewPFServiceError(code, msg, reqId string, status int) *PFServiceError

func (*PFServiceError) Error

func (b *PFServiceError) Error() string

type PaddleFlowClient

type PaddleFlowClient struct {
	Config *PaddleFlowClientConfiguration
}

func (*PaddleFlowClient) SendRequest

func (c *PaddleFlowClient) SendRequest(req *PFRequest) (*PFResponse, error)

type PaddleFlowClientConfiguration

type PaddleFlowClientConfiguration struct {
	Host                       string
	Port                       int
	ConnectionTimeoutInSeconds int
}

func (*PaddleFlowClientConfiguration) String

type RequestBuilder

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

RequestBuilder holds config data for bce request. Some of fields are required and the others are optional. The builder pattern can simplify the execution of requests.

func NewRequestBuilder

func NewRequestBuilder(client Client) *RequestBuilder

create RequestBuilder with the client.

func (*RequestBuilder) Do

func (b *RequestBuilder) Do() error

Do will send request to core and get result with the builder's parameters.

func (*RequestBuilder) WithBody

func (b *RequestBuilder) WithBody(body interface{}) *RequestBuilder

func (*RequestBuilder) WithHeader

func (b *RequestBuilder) WithHeader(key, value string) *RequestBuilder

func (*RequestBuilder) WithHeaders

func (b *RequestBuilder) WithHeaders(headers map[string]string) *RequestBuilder

func (*RequestBuilder) WithMethod

func (b *RequestBuilder) WithMethod(method string) *RequestBuilder

func (*RequestBuilder) WithQueryParam

func (b *RequestBuilder) WithQueryParam(key, value string) *RequestBuilder

set query param with the key/value directly.

func (*RequestBuilder) WithQueryParamFilter

func (b *RequestBuilder) WithQueryParamFilter(key, value string) *RequestBuilder

set query param with the key/value only when the value is not blank.

func (*RequestBuilder) WithQueryParams

func (b *RequestBuilder) WithQueryParams(params map[string][]string) *RequestBuilder

func (*RequestBuilder) WithResult

func (b *RequestBuilder) WithResult(result interface{}) *RequestBuilder

func (*RequestBuilder) WithURL

func (b *RequestBuilder) WithURL(url string) *RequestBuilder

Jump to

Keyboard shortcuts

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