File: log.go

package info (click to toggle)
golang-github-mimuret-golang-iij-dpf 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,340 kB
  • sloc: makefile: 55
file content (72 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download
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
package core

import (
	"net/url"

	"github.com/google/go-querystring/query"
	"github.com/mimuret/golang-iij-dpf/pkg/api"
	"github.com/mimuret/golang-iij-dpf/pkg/types"
)

type LogStatus string

const (
	LogStatusStart   LogStatus = "start"
	LogStatusSuccess LogStatus = "success"
	LogStatusFailure LogStatus = "failure"
	LogStatusRetry   LogStatus = "retry"
)

func (c LogStatus) String() string {
	return string(c)
}

// +k8s:deepcopy-gen=false
type KeywordsLogStatus []LogStatus

type Log struct {
	Time      types.Time `read:"time"`
	LogType   string     `read:"log_type"`
	Operator  string     `read:"operator"`
	Operation string     `read:"operation"`
	Target    string     `read:"target"`
	RequestID string     `read:"request_id"`
	Status    LogStatus  `read:"status"`
}

// +k8s:deepcopy-gen=false
type SearchLogsOffset int32

func (s SearchLogsOffset) Validate() bool {
	if s < 0 || s > 9900 {
		return false
	}
	return true
}

// +k8s:deepcopy-gen=false
type SearchLogsLimit int32

func (s SearchLogsLimit) Validate() bool {
	if s < 1 || s > 100 {
		return false
	}
	return true
}

var _ api.SearchParams = &LogListSearchKeywords{}

// +k8s:deepcopy-gen=false
type LogListSearchKeywords struct {
	api.CommonSearchParams
	FullText  api.KeywordsString `url:"_keywords_full_text[],omitempty"`
	LogType   api.KeywordsString `url:"_keywords_log_type[],omitempty"`
	Operator  api.KeywordsString `url:"_keywords_operator[],omitempty"`
	Operation api.KeywordsString `url:"_keywords_operation[],omitempty"`
	Target    api.KeywordsString `url:"_keywords_target[],omitempty"`
	Detail    api.KeywordsString `url:"_keywords_detail[],omitempty"`
	RequestID api.KeywordsString `url:"_keywords_request_id[],omitempty"`
	Status    KeywordsLogStatus  `url:"_keywords_status[],omitempty"`
}

func (s *LogListSearchKeywords) GetValues() (url.Values, error) { return query.Values(s) }