feed.go raw

   1  package data
   2  
   3  // Destination is the target resource the receives data from a feed/source.
   4  type Destination struct {
   5  	ID string `json:"destid"`
   6  
   7  	// All destinations must point to a record.
   8  	RecordID string `json:"record"`
   9  
  10  	// Type is the 'level' at which to apply the filters(on the targeted record).
  11  	// Options:
  12  	//   - answer (highest precedence)
  13  	//   - region
  14  	//   - record (lowest precendence)
  15  	Type string `json:"desttype"`
  16  
  17  	SourceID string `json:"-"`
  18  }
  19  
  20  // NewDestination returns an empty feed destination.
  21  func NewDestination() *Destination {
  22  	return &Destination{}
  23  }
  24  
  25  // Feed wraps an NS1 /data/feeds resource
  26  type Feed struct {
  27  	ID     string `json:"id,omitempty"`
  28  	Name   string `json:"name"`
  29  	Config Config `json:"config,omitempty"`
  30  	Data   Meta   `json:"data,omitempty"`
  31  
  32  	Destinations []Destination `json:"destinations"`
  33  
  34  	SourceID string
  35  }
  36  
  37  // NewFeed returns a data feed with given name and config.
  38  func NewFeed(name string, cfg Config) *Feed {
  39  	return &Feed{Name: name, Config: cfg}
  40  }
  41