models

package
v0.0.0-...-fc1e0a8 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerter

type Alerter interface {
	Alert(msg string) error
}

type AssertionV1

type AssertionV1 struct {
	StatusCode int `json:"statusCode"`
}

func (AssertionV1) Assert

func (assertion AssertionV1) Assert(res *rshttp.Response) bool

func (*AssertionV1) Scan

func (assertion *AssertionV1) Scan(src interface{}) error

func (AssertionV1) Value

func (assertion AssertionV1) Value() (driver.Value, error)

type IsSuccess

type IsSuccess string

func (IsSuccess) IsBoth

func (isSuccess IsSuccess) IsBoth() bool

func (IsSuccess) String

func (isSuccess IsSuccess) String() string

func (IsSuccess) Validate

func (isSuccess IsSuccess) Validate() error

type Parameters

type Parameters struct {
	Auth   map[string]interface{} `json:"auth"`
	Header map[string]string      `json:"header"`
	Query  map[string]interface{} `json:"query"`
	Body   map[string]interface{} `json:"body"`
}

func (*Parameters) Scan

func (parameters *Parameters) Scan(src interface{}) error

func (Parameters) Value

func (parameters Parameters) Value() (driver.Value, error)

type Test

type Test struct {
	rsmodels.DefaultValidateChecker
	Id           string              `json:"id"`
	Name         string              `json:"name"`
	WebServiceId string              `json:"-"`
	WebService   *WebService         `json:"webService,omitempty" gorm:"PRELOAD:true"`
	Path         rshttp.EndpointPath `json:"path"`
	Method       rshttp.Method       `json:"method"`
	ContentType  rshttp.ContentType  `json:"contentType"`
	Description  string              `json:"description" gorm:"Type:TEXT"`
	Parameters   Parameters          `json:"parameters" gorm:"Type:JSON"`
	Schedule     TestSchedule        `json:"schedule" gorm:"Column:schedule;Type:VARCHAR(5)"`
	Timeout      rshttp.Timeout      `json:"timeout"`
	Assertion    AssertionV1         `json:"assertion" gorm:"Type:JSON"`
	Alerts       WebHookAlerts       `json:"alerts" gorm:"Column:alerts;Type:JSON"`
	CreatedAt    time.Time           `json:"createdAt"`
	ModifiedAt   time.Time           `json:"modifiedAt"`
}

func NewTest

func NewTest(webService *WebService, request TestRequest) (*Test, error)

func (Test) Execute

func (test Test) Execute() (*rshttp.Response, error)

func (Test) ToHttpRequest

func (test Test) ToHttpRequest(webService *WebService) (*rshttp.Request, error)

func (*Test) UpdateFromRequest

func (test *Test) UpdateFromRequest(request TestRequest) error

func (*Test) Validate

func (test *Test) Validate() error

type TestListItem

type TestListItem struct {
	Id           string              `json:"id"`
	WebServiceId string              `json:"webServiceId"  gorm:"foreignkey:WebServiceId"`
	WebService   *WebService         `json:"webService"`
	Path         rshttp.EndpointPath `json:"path"`
	Method       rshttp.Method       `json:"method"`
	Description  string              `json:"description"`
	Created      time.Time           `json:"created"`
	LastModified time.Time           `json:"lastModified"`
}

func (TestListItem) MarshalJSON

func (testListItem TestListItem) MarshalJSON() ([]byte, error)

func (TestListItem) TableName

func (testListItem TestListItem) TableName() string

type TestListRequest

type TestListRequest struct {
	Page         int
	NumItem      int
	WebServiceId string
}

type TestRequest

type TestRequest struct {
	Id          string              `json:"-"`
	Name        string              `json:"name"`
	Path        rshttp.EndpointPath `json:"path"`
	Method      rshttp.Method       `json:"method"`
	ContentType rshttp.ContentType  `json:"contentType"`
	Description string              `json:"description"`
	Parameters  Parameters          `json:"parameters"`
	Schedule    TestSchedule        `json:"schedule"`
	Assertion   AssertionV1         `json:"assertion"`
	Alerts      WebHookAlerts       `json:"alerts"`
	Timeout     int                 `json:"timeout"`
}

func (TestRequest) Validate

func (request TestRequest) Validate() error

type TestResult

type TestResult struct {
	rsmodels.DefaultValidateChecker
	Id           string    `json:"id" gorm:"Size:36"`
	TestId       string    `json:"testId" gorm:"NOT NULL"`
	IsSuccess    bool      `json:"isSuccess"`
	StatusCode   int       `json:"statusCode"`
	Response     string    `json:"response" gorm:"Type:TEXT"`
	ResponseTime int64     `json:"responseTime"`
	TestedAt     time.Time `json:"testedAt"`
}

func (TestResult) ErrorMessage

func (result TestResult) ErrorMessage() string

func (TestResult) TableName

func (result TestResult) TableName() string

func (TestResult) Validate

func (result TestResult) Validate() error

type TestResultListRequest

type TestResultListRequest struct {
	Page          int       `json:"page"`
	NumItem       int       `json:"numItem"`
	IsSuccess     IsSuccess `json:"isSuccess"`
	StartTestedAt time.Time `json:"startTestedAt"`
	EndTestedAt   time.Time `json:"endTestedAt"`
}

func (*TestResultListRequest) SetZeroToDefault

func (request *TestResultListRequest) SetZeroToDefault()

type TestSchedule

type TestSchedule string
const (
	ScheduleOneMinute     TestSchedule = "1m"
	ScheduleFiveMinute    TestSchedule = "5m"
	ScheduleFifteenMinute TestSchedule = "15m"
	ScheduleThirtyMinute  TestSchedule = "30m"
	ScheduleHourly        TestSchedule = "1h"
	ScheduleDaily         TestSchedule = "1d"
)

func (TestSchedule) GetDuration

func (schedule TestSchedule) GetDuration() time.Duration

func (TestSchedule) GetTicker

func (schedule TestSchedule) GetTicker() *time.Ticker

func (*TestSchedule) UnmarshalJSON

func (schedule *TestSchedule) UnmarshalJSON(data []byte) error

func (*TestSchedule) Validate

func (schedule *TestSchedule) Validate() error

type WebHookAlerter

type WebHookAlerter struct {
	URL    string `json:"url"`
	Enable bool   `json:"disable"`
}

func (WebHookAlerter) Alert

func (alerter WebHookAlerter) Alert(msg string) error

type WebHookAlerts

type WebHookAlerts []*WebHookAlerter

func (*WebHookAlerts) Scan

func (alerts *WebHookAlerts) Scan(src interface{}) error

func (WebHookAlerts) Value

func (alerts WebHookAlerts) Value() (driver.Value, error)

type WebService

type WebService struct {
	rsmodels.DefaultValidateChecker
	Id          string    `json:"id" gorm:"private_key"`
	Host        string    `json:"host" gorm:"unique"`
	Schema      string    `json:"schema" gorm:"Size:20;Default:'http'"`
	Description string    `json:"description" gorm:"Type:TEXT"`
	CreatedAt   time.Time `json:"createdAt"`
	ModifiedAt  time.Time `json:"modifiedAt"`
}

func NewWebService

func NewWebService(request WebServiceRequest) (*WebService, error)

func (*WebService) UpdateFromRequest

func (webService *WebService) UpdateFromRequest(request WebServiceRequest) error

func (*WebService) Validate

func (webService *WebService) Validate() error

type WebServiceListRequest

type WebServiceListRequest struct {
	Page          int
	NumItem       int
	SearchKeyword string
}

type WebServiceRequest

type WebServiceRequest struct {
	Host        string `json:"host"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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