File: responses.go

package info (click to toggle)
golang-github-dreamitgetit-statuscake 0.0~git20201021.4e32615-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 304 kB
  • sloc: makefile: 19
file content (112 lines) | stat: -rw-r--r-- 4,351 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package statuscake

import (
	"strconv"
	"strings"
)

type autheticationErrorResponse struct {
	ErrNo int
	Error string
}

type updateResponse struct {
	Issues   interface{} `json:"Issues"`
	Success  bool        `json:"Success"`
	Message  string      `json:"Message"`
	InsertID int         `json:"InsertID"`
}

type deleteResponse struct {
	Success bool   `json:"Success"`
	Error   string `json:"Error"`
}

type contactGroupDetailResponse struct {
	ID    int    `json:"ID"`
	Name  string `json:"Name"`
	Email string `json:"Email"`
}

type detailResponse struct {
	Method           string                       `json:"Method"`
	TestID           int                          `json:"TestID"`
	TestType         string                       `json:"TestType"`
	Paused           bool                         `json:"Paused"`
	WebsiteName      string                       `json:"WebsiteName"`
	URI              string                       `json:"URI"`
	ContactID        int                          `json:"ContactID"`
	ContactGroups    []contactGroupDetailResponse `json:"ContactGroups"`
	Status           string                       `json:"Status"`
	Uptime           float64                      `json:"Uptime"`
	CustomHeader     string                       `json:"CustomHeader"`
	UserAgent        string                       `json:"UserAgent"`
	CheckRate        int                          `json:"CheckRate"`
	Timeout          int                          `json:"Timeout"`
	LogoImage        string                       `json:"LogoImage"`
	Confirmation     int                          `json:"Confirmation,string"`
	WebsiteHost      string                       `json:"WebsiteHost"`
	NodeLocations    []string                     `json:"NodeLocations"`
	FindString       string                       `json:"FindString"`
	DoNotFind        bool                         `json:"DoNotFind"`
	LastTested       string                       `json:"LastTested"`
	NextLocation     string                       `json:"NextLocation"`
	Port             int                          `json:"Port"`
	Processing       bool                         `json:"Processing"`
	ProcessingState  string                       `json:"ProcessingState"`
	ProcessingOn     string                       `json:"ProcessingOn"`
	DownTimes        int                          `json:"DownTimes,string"`
	Sensitive        bool                         `json:"Sensitive"`
	TriggerRate      int                          `json:"TriggerRate,string"`
	UseJar           int                          `json:"UseJar"`
	PostRaw          string                       `json:"PostRaw"`
	PostBody         string                       `json:"PostBody"`
	FinalEndpoint    string                       `json:"FinalEndpoint"`
	EnableSSLWarning bool                         `json:"EnableSSLWarning"`
	FollowRedirect   bool                         `json:"FollowRedirect"`
	DNSServer        string                       `json:"DNSServer"`
	DNSIP            string                       `json:"DNSIP"`
	StatusCodes      []string                     `json:"StatusCodes"`
	Tags             []string                     `json:"Tags"`
}

func (d *detailResponse) test() *Test {
	contactGroupIds := make([]string, len(d.ContactGroups))
	for i, v := range d.ContactGroups {
		contactGroupIds[i] = strconv.Itoa(v.ID)
	}

	return &Test{
		TestID:         d.TestID,
		TestType:       d.TestType,
		Paused:         d.Paused,
		WebsiteName:    d.WebsiteName,
		WebsiteURL:     d.URI,
		CustomHeader:   d.CustomHeader,
		UserAgent:      d.UserAgent,
		ContactID:      d.ContactID,
		ContactGroup:   contactGroupIds,
		Status:         d.Status,
		Uptime:         d.Uptime,
		CheckRate:      d.CheckRate,
		Timeout:        d.Timeout,
		LogoImage:      d.LogoImage,
		Confirmation:   d.Confirmation,
		WebsiteHost:    d.WebsiteHost,
		NodeLocations:  d.NodeLocations,
		FindString:     d.FindString,
		DoNotFind:      d.DoNotFind,
		Port:           d.Port,
		TriggerRate:    d.TriggerRate,
		UseJar:         d.UseJar,
		PostRaw:        d.PostRaw,
		PostBody:       d.PostBody,
		FinalEndpoint:  d.FinalEndpoint,
		DNSServer:      d.DNSServer,
		DNSIP:          d.DNSIP,
		EnableSSLAlert: d.EnableSSLWarning,
		FollowRedirect: d.FollowRedirect,
		StatusCodes:    strings.Join(d.StatusCodes[:], ","),
		TestTags:       d.Tags,
	}
}