File: lb_domain.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 (99 lines) | stat: -rw-r--r-- 3,309 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
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
package core

import (
	"fmt"
	"net/url"

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

var _ api.Spec = &LBDomain{}

// +k8s:deepcopy-gen:interfaces=github.com/mimuret/golang-iij-dpf/pkg/api.Object

type LBDomain struct {
	AttributeMeta
	ID               string         `read:"id"`
	CommonConfigID   int64          `read:"common_config_id"`
	ServiceCode      string         `read:"service_code"`
	State            types.State    `read:"state"`
	Favorite         types.Favorite `read:"favorite" update:"favorite"`
	Name             string         `read:"name"`
	Description      string         `read:"description" update:"description"`
	RuleResourceName string         `read:"rule_resource_name" update:"rule_resource_name"`
}

func (c *LBDomain) GetName() string { return "lb_domains" }
func (c *LBDomain) GetPathMethod(action api.Action) (string, string) {
	switch action {
	case api.ActionRead, api.ActionUpdate:
		return action.ToMethod(), fmt.Sprintf("/lb_domains/%s", c.ID)
	}
	return "", ""
}

func (c *LBDomain) SetPathParams(args ...interface{}) error {
	return apis.SetPathParams(args, &c.ID)
}

var _ apis.CountableListSpec = &ZoneList{}

// +k8s:deepcopy-gen:interfaces=github.com/mimuret/golang-iij-dpf/pkg/api.Object

type LBDomainList struct {
	AttributeMeta
	api.Count
	Items []LBDomain `read:"items"`
}

func (c *LBDomainList) GetName() string         { return "lb_domains" }
func (c *LBDomainList) GetItems() interface{}   { return &c.Items }
func (c *LBDomainList) Len() int                { return len(c.Items) }
func (c *LBDomainList) Index(i int) interface{} { return c.Items[i] }
func (c *LBDomainList) GetMaxLimit() int32      { return 10000 }
func (c *LBDomainList) ClearItems()             { c.Items = []LBDomain{} }
func (c *LBDomainList) AddItem(v interface{}) bool {
	if a, ok := v.(LBDomain); ok {
		c.Items = append(c.Items, a)
		return true
	}
	return false
}

func (c *LBDomainList) GetPathMethod(action api.Action) (string, string) {
	switch action {
	case api.ActionList:
		return action.ToMethod(), "/lb_domains"
	case api.ActionCount:
		return action.ToMethod(), "/lb_domains/count"
	}
	return "", ""
}
func (c *LBDomainList) Init() {}
func (c *LBDomainList) SetPathParams(args ...interface{}) error {
	return nil
}

var _ api.SearchParams = &LBDomainListSearchKeywords{}

// +k8s:deepcopy-gen=false
type LBDomainListSearchKeywords struct {
	api.CommonSearchParams
	FullText       api.KeywordsString   `url:"_keywords_full_text[],omitempty"`
	ServiceCode    api.KeywordsString   `url:"_keywords_service_code[],omitempty"`
	Name           api.KeywordsString   `url:"_keywords_name[],omitempty"`
	State          api.KeywordsState    `url:"_keywords_state[],omitempty"`
	Favorite       api.KeywordsFavorite `url:"_keywords_favorite[],omitempty"`
	Description    api.KeywordsString   `url:"_keywords_description[],omitempty"`
	CommonConfigID api.KeywordsID       `url:"_keywords_common_config_id[],omitempty"`
	Label          api.KeywordsLabels   `url:"_keywords_label[],omitempty"`
}

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

func init() {
	register(&LBDomain{}, &LBDomainList{})
}