api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: GPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdOutputType added in v0.99.0

type CmdOutputType string
const (
	CmdOutputStdout   CmdOutputType = "stdout"
	CmdOutputStderr   CmdOutputType = "stderr"
	CmdOutputExitCode CmdOutputType = "exitcode"
)
type Cookie struct {
	Name     string        `json:"name"`
	Value    string        `json:"value"`
	Path     string        `json:"path,omitempty"`
	Domain   string        `json:"domain,omitempty"`
	Expires  time.Time     `json:"expires,omitempty"`
	MaxAge   int           `json:"max_age,omitempty"`
	Secure   bool          `json:"secure,omitempty"`
	HttpOnly bool          `json:"http_only,omitempty"`
	SameSite http.SameSite `json:"same_site,omitempty"`
}

Cookie definition

type PreProcess added in v0.90.0

type PreProcess struct {
	Cmd struct {
		Name   string        `json:"name"`
		Args   []string      `json:"args,omitempty"`
		Output CmdOutputType `json:"output,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"`
	Cookies              map[string]*RequestCookie `yaml:"cookies" json:"cookies"`
	SetCookies           []*Cookie                 `yaml:"header-x-test-set-cookie" json:"header-x-test-set-cookie"`
	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 RequestCookie added in v0.100.0

type RequestCookie struct {
	ValueFromStore string `yaml:"value_from_store" json:"value_from_store"`
	Value          string `yaml:"value" json:"value"`
}

type Response

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

func NewResponse

func NewResponse(statusCode int, headers map[string][]string, cookies []*http.Cookie, 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"`
	Cookies     map[string]Cookie   `yaml:"cookie" json:"cookie,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