Documentation
¶
Index ¶
- Constants
- Variables
- func MaskString(input string) string
- func UnwrapNullableType(input schema.Type) (schema.TypeEncoder, bool, error)
- type DataURI
- type DistributedError
- type DistributedResponse
- type DistributedResult
- type Doer
- type HTTPClient
- type Key
- type Keys
- type MetadataCollection
- type MultipartWriter
- type ParameterItem
- func (ssp *ParameterItem) Add(key Key, value string)
- func (ssp *ParameterItem) AddKey(key Key)
- func (ssp *ParameterItem) AddKeys(keys []Key)
- func (ssp *ParameterItem) AddValue(value string)
- func (ssp *ParameterItem) AddValues(values []string)
- func (ssp ParameterItem) Keys() Keys
- func (ssp *ParameterItem) PrependKey(key Key)
- func (ssp *ParameterItem) PrependKeys(keys []Key)
- func (ssp *ParameterItem) PrependValue(value string)
- func (ssp *ParameterItem) PrependValues(values []string)
- func (ssp ParameterItem) String() string
- func (ssp ParameterItem) Values() []string
- type ParameterItems
- type RESTOptions
- type RequestBuilder
- type RetryableRequest
Constants ¶
const ( // EncodingBase64 is base64 encoding for the data url EncodingBase64 = "base64" // EncodingASCII is ascii encoding for the data url EncodingASCII = "ascii" )
Variables ¶
var DistributedObjectType rest.ObjectType = rest.ObjectType{ Description: utils.ToPtr("Distributed execution options for REST requests to multiple servers"), Fields: map[string]rest.ObjectField{ "servers": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Specify remote servers to receive the request"), Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(RESTServerIDScalarName))).Encode(), }, }, "parallel": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Execute requests to remote servers in parallel"), Type: schema.NewNullableNamedType(string(rest.ScalarBoolean)).Encode(), }, }, }, }
DistributedObjectType represents the object type of REST execution options for distributed servers
var SingleObjectType rest.ObjectType = rest.ObjectType{ Description: utils.ToPtr("Execution options for REST requests to a single server"), Fields: map[string]rest.ObjectField{ "servers": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Specify remote servers to receive the request. If there are many server IDs the server is selected randomly"), Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(RESTServerIDScalarName))).Encode(), }, }, }, }
SingleObjectType represents the object type of REST execution options for single server
Functions ¶
func MaskString ¶
MaskString masks the string value for security
func UnwrapNullableType ¶
UnwrapNullableType unwraps the underlying type of the nullable type
Types ¶
type DataURI ¶
DataURI represents the Data URI scheme
func DecodeDataURI ¶
DecodeDataURI decodes data URI scheme data:[<media type>][;<key>=<value>][;<extension>],<data>
type DistributedError ¶
type DistributedError struct { schema.ConnectorError // Identity of the remote server Server string `json:"server" yaml:"server"` }
DistributedError represents the error response of the remote request
func (DistributedError) Error ¶
func (de DistributedError) Error() string
Error implements the Error interface
type DistributedResponse ¶
type DistributedResponse[T any] struct { Results []DistributedResult[T] `json:"results" yaml:"results"` Errors []DistributedError `json:"errors" yaml:"errors"` }
DistributedResponse represents the response object of distributed operations
func NewDistributedResponse ¶
func NewDistributedResponse[T any]() *DistributedResponse[T]
NewDistributedResponse creates an empty DistributedResponse instance
type DistributedResult ¶
type DistributedResult[T any] struct { Server string `json:"server" yaml:"server"` Data T `json:"data" yaml:"data"` }
DistributedResult contains the success response of remote requests with a server identity
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient represents a http client wrapper with advanced methods
func NewHTTPClient ¶
func NewHTTPClient(client Doer) *HTTPClient
NewHTTPClient creates a http client wrapper
func (*HTTPClient) Send ¶
func (client *HTTPClient) Send(ctx context.Context, request *RetryableRequest, selection schema.NestedField, resultType schema.Type, restOptions *RESTOptions) (any, error)
Send creates and executes the request and evaluate response selection
func (*HTTPClient) SetTracer ¶
func (client *HTTPClient) SetTracer(tracer *connector.Tracer)
SetTracer sets the tracer instance
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a key string or index
type MetadataCollection ¶
type MetadataCollection []rest.NDCRestSchema
MetadataCollection stores list of REST metadata with helper methods
func (MetadataCollection) GetFunction ¶
func (rms MetadataCollection) GetFunction(name string) (*rest.OperationInfo, *rest.NDCRestSettings, error)
GetFunction gets the NDC function by name
func (MetadataCollection) GetProcedure ¶
func (rms MetadataCollection) GetProcedure(name string) (*rest.OperationInfo, *rest.NDCRestSettings, error)
GetProcedure gets the NDC procedure by name
type MultipartWriter ¶
MultipartWriter extends multipart.Writer with helpers
func NewMultipartWriter ¶
func NewMultipartWriter(w io.Writer) *MultipartWriter
NewMultipartWriter creates a MultipartWriter instance
func (*MultipartWriter) WriteDataURI ¶
WriteDataURI write a file from data URI string
func (*MultipartWriter) WriteField ¶
func (w *MultipartWriter) WriteField(fieldName, value string, headers http.Header) error
WriteField calls CreateFormField and then writes the given value.
type ParameterItem ¶
type ParameterItem struct {
// contains filtered or unexported fields
}
ParameterItem represents the key-value slice pair
func NewParameterItem ¶
func NewParameterItem(keys Keys, values []string) ParameterItem
NewParameterItem creates a parameter value pair
func (*ParameterItem) Add ¶
func (ssp *ParameterItem) Add(key Key, value string)
func (*ParameterItem) AddKey ¶
func (ssp *ParameterItem) AddKey(key Key)
func (*ParameterItem) AddKeys ¶
func (ssp *ParameterItem) AddKeys(keys []Key)
func (*ParameterItem) AddValue ¶
func (ssp *ParameterItem) AddValue(value string)
func (*ParameterItem) AddValues ¶
func (ssp *ParameterItem) AddValues(values []string)
func (ParameterItem) Keys ¶
func (ssp ParameterItem) Keys() Keys
Keys returns keys of the parameter item
func (*ParameterItem) PrependKey ¶
func (ssp *ParameterItem) PrependKey(key Key)
func (*ParameterItem) PrependKeys ¶
func (ssp *ParameterItem) PrependKeys(keys []Key)
func (*ParameterItem) PrependValue ¶
func (ssp *ParameterItem) PrependValue(value string)
func (*ParameterItem) PrependValues ¶
func (ssp *ParameterItem) PrependValues(values []string)
func (ParameterItem) String ¶
func (ssp ParameterItem) String() string
String implements fmt.Stringer interface
func (ParameterItem) Values ¶
func (ssp ParameterItem) Values() []string
type ParameterItems ¶
type ParameterItems []ParameterItem
func (*ParameterItems) Add ¶
func (ssp *ParameterItems) Add(keys []Key, values []string)
func (ParameterItems) Find ¶
func (ssp ParameterItems) Find(keys []Key) *ParameterItem
func (ParameterItems) FindDefault ¶
func (ssp ParameterItems) FindDefault() *ParameterItem
func (ParameterItems) FindIndex ¶
func (ssp ParameterItems) FindIndex(keys []Key) int
func (ParameterItems) String ¶
func (ssp ParameterItems) String() string
String implements fmt.Stringer interface
type RESTOptions ¶
type RESTOptions struct { Servers []string `json:"servers" yaml:"serverIds"` Parallel bool `json:"parallel" yaml:"parallel"` Explain bool `json:"-" yaml:"-"` Distributed bool `json:"-" yaml:"-"` Settings *rest.NDCRestSettings `json:"-" yaml:"-"` }
RESTOptions represent execution options for REST requests
func (*RESTOptions) FromValue ¶
func (ro *RESTOptions) FromValue(value any) error
FromValue parses rest execution options from any value
type RequestBuilder ¶
type RequestBuilder struct { Schema *rest.NDCRestSchema Operation *rest.OperationInfo Arguments map[string]any }
RequestBuilder builds requests to the remote service
func NewRequestBuilder ¶
func NewRequestBuilder(restSchema *rest.NDCRestSchema, operation *rest.OperationInfo, arguments map[string]any) *RequestBuilder
NewRequestBuilder creates a new RequestBuilder instance
func (*RequestBuilder) Build ¶
func (c *RequestBuilder) Build() (*RetryableRequest, error)
Build evaluates and builds a RetryableRequest
type RetryableRequest ¶
type RetryableRequest struct { RawRequest *rest.Request URL string ServerID string ContentType string Headers http.Header Body io.ReadSeeker Timeout uint Retry *rest.RetryPolicy }
RetryableRequest wraps the raw request with retryable
func BuildDistributedRequestsWithOptions ¶
func BuildDistributedRequestsWithOptions(request *RetryableRequest, restOptions *RESTOptions) ([]RetryableRequest, error)
BuildDistributedRequestsWithOptions builds distributed requests with options
func (*RetryableRequest) CreateRequest ¶
func (r *RetryableRequest) CreateRequest(ctx context.Context) (*http.Request, context.CancelFunc, error)
CreateRequest creates an HTTP request with body copied