log.go raw

   1  package zones
   2  
   3  import (
   4  	"github.com/mimuret/golang-iij-dpf/pkg/api"
   5  	"github.com/mimuret/golang-iij-dpf/pkg/apis"
   6  	"github.com/mimuret/golang-iij-dpf/pkg/apis/dpf/v1/core"
   7  )
   8  
   9  var _ CountableListSpec = &LogList{}
  10  
  11  // +k8s:deepcopy-gen:interfaces=github.com/mimuret/golang-iij-dpf/pkg/api.Object
  12  
  13  type LogList struct {
  14  	AttributeMeta
  15  	api.Count
  16  	Items []core.Log `read:"items"`
  17  }
  18  
  19  func (c *LogList) GetName() string         { return "logs" }
  20  func (c *LogList) GetItems() interface{}   { return &c.Items }
  21  func (c *LogList) Len() int                { return len(c.Items) }
  22  func (c *LogList) Index(i int) interface{} { return c.Items[i] }
  23  func (c *LogList) GetMaxLimit() int32      { return 100 }
  24  func (c *LogList) ClearItems()             { c.Items = []core.Log{} }
  25  func (c *LogList) AddItem(v interface{}) bool {
  26  	if a, ok := v.(core.Log); ok {
  27  		c.Items = append(c.Items, a)
  28  		return true
  29  	}
  30  	return false
  31  }
  32  
  33  func (c *LogList) GetPathMethod(action api.Action) (string, string) {
  34  	return GetPathMethodForListSpec(action, c)
  35  }
  36  func (c *LogList) Init() {}
  37  func (c *LogList) SetPathParams(args ...interface{}) error {
  38  	return apis.SetPathParams(args, &c.ZoneID)
  39  }
  40  
  41  func init() {
  42  	register(&LogList{})
  43  }
  44