api

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreProcess added in v0.90.0

type PreProcess struct {
	Cmd struct {
		Name string   `json:"name"`
		Args []string `json:"args,omitempty"`
	} `json:"cmd"`
}

func (*PreProcess) RunPreProcess added in v0.90.0

func (proc *PreProcess) RunPreProcess(response Response) (Response, error)

type Request

type Request struct {
	Endpoint             string                 `yaml:"endpoint" json:"endpoint"`
	ServerURL            string                 `yaml:"server_url" json:"server_url"`
	Method               string                 `yaml:"method" json:"method"`
	QueryParams          map[string]interface{} `yaml:"query_params" json:"query_params"`
	QueryParamsFromStore map[string]string      `yaml:"query_params_from_store" json:"query_params_from_store"`
	Headers              map[string]*string     `yaml:"header" json:"header"`
	HeaderFromStore      map[string]string      `yaml:"header_from_store" json:"header_from_store"`
	BodyType             string                 `yaml:"body_type" json:"body_type"`
	BodyFile             string                 `yaml:"body_file" json:"body_file"`
	Body                 interface{}            `yaml:"body" json:"body"`

	DoNotStore  bool
	ManifestDir string
	DataStore   *datastore.Datastore
	// contains filtered or unexported fields
}

func (Request) Send

func (request Request) Send() (response Response, err error)

func (Request) ToString

func (request Request) ToString(curl bool) (res string)

type Response

type Response struct {
	Format ResponseFormat
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(statusCode int, headers map[string][]string, body io.Reader, bodyControl util.JsonObject, bodyFormat ResponseFormat) (res Response, err error)

func NewResponseFromSpec

func NewResponseFromSpec(spec ResponseSerialization) (res Response, err error)

func (Response) Body

func (response Response) Body() []byte

func (Response) ServerResponseToGenericJSON added in v0.90.0

func (response Response) ServerResponseToGenericJSON(responseFormat ResponseFormat, bodyOnly bool) (interface{}, error)

ServerResponseToGenericJSON parse response from server. convert xml, csv, binary to json if necessary

func (Response) ServerResponseToJsonString added in v0.90.0

func (response Response) ServerResponseToJsonString(bodyOnly bool) (string, error)

func (Response) ToGenericJSON added in v0.90.0

func (response Response) ToGenericJSON() (interface{}, error)

ToGenericJSON parse expected response

func (Response) ToString

func (response Response) ToString() string

type ResponseFormat added in v0.90.0

type ResponseFormat struct {
	IgnoreBody bool   `json:"-"`    // if true, do not try to parse the body (since it is not expected in the response)
	Type       string `json:"type"` // default "json", allowed: "csv", "json", "xml", "binary"
	CSV        struct {
		Comma string `json:"comma,omitempty"`
	} `json:"csv,omitempty"`
	PreProcess *PreProcess `json:"pre_process,omitempty"`
}

type ResponseSerialization

type ResponseSerialization struct {
	StatusCode  int                 `yaml:"statuscode" json:"statuscode"`
	Headers     map[string][]string `yaml:"header" json:"header,omitempty"`
	Body        interface{}         `yaml:"body" json:"body,omitempty"`
	BodyControl util.JsonObject     `yaml:"body:control" json:"body:control,omitempty"`
	Format      ResponseFormat      `yaml:"format" json:"format,omitempty"`
}

Jump to

Keyboard shortcuts

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