File: cc_primary.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 (63 lines) | stat: -rw-r--r-- 1,993 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
package common_configs

import (
	"net"

	"github.com/mimuret/golang-iij-dpf/pkg/api"
	"github.com/mimuret/golang-iij-dpf/pkg/apis"
	"github.com/mimuret/golang-iij-dpf/pkg/types"
)

// for IDE.
var _ ChildSpec = &CcPrimary{}

// +k8s:deepcopy-gen:interfaces=github.com/mimuret/golang-iij-dpf/pkg/api.Object
type CcPrimary struct {
	AttributeMeta
	ID      int64                       `read:"id,omitempty" id:"2,required"`
	Address net.IP                      `read:"address" create:"address" update:"address"`
	TsigID  types.NullablePositiveInt64 `read:"tsig_id"  create:"tsig_id" update:"tsig_id"`
	Enabled types.Boolean               `read:"enabled" update:"enabled"`
}

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

func (c *CcPrimary) GetID() int64    { return c.ID }
func (c *CcPrimary) SetID(id int64)  { c.ID = id }
func (c *CcPrimary) GetName() string { return "cc_primaries" }
func (c *CcPrimary) GetPathMethod(action api.Action) (string, string) {
	return GetPathMethodForChildSpec(action, c)
}

// for IDE.
var _ ListSpec = &CcPrimaryList{}

// +k8s:deepcopy-gen:interfaces=github.com/mimuret/golang-iij-dpf/pkg/api.Object
type CcPrimaryList struct {
	AttributeMeta
	Items []CcPrimary `read:"items"`
}

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

func (c *CcPrimaryList) GetPathMethod(action api.Action) (string, string) {
	return GetPathMethodForListSpec(action, c)
}
func (c *CcPrimaryList) GetName() string         { return "cc_primaries" }
func (c *CcPrimaryList) GetItems() interface{}   { return &c.Items }
func (c *CcPrimaryList) Len() int                { return len(c.Items) }
func (c *CcPrimaryList) Index(i int) interface{} { return c.Items[i] }

func (c *CcPrimaryList) Init() {
	for i := range c.Items {
		c.Items[i].AttributeMeta = c.AttributeMeta
	}
}

func init() {
	register(&CcPrimary{}, &CcPrimaryList{})
}