commit
a3fd8aa0cf
4
Makefile
4
Makefile
|
@ -53,10 +53,12 @@ jsdep:
|
|||
gen: bolt/internal/internal.proto
|
||||
go generate github.com/influxdata/mrfusion/bolt/internal
|
||||
|
||||
test: jstest gotest
|
||||
test: jstest gotest gotestrace
|
||||
|
||||
gotest:
|
||||
go test ./...
|
||||
|
||||
gotestrace:
|
||||
go test -race ./...
|
||||
|
||||
jstest:
|
||||
|
|
|
@ -14,12 +14,14 @@ type Client struct {
|
|||
|
||||
ExplorationStore *ExplorationStore
|
||||
SourcesStore *SourcesStore
|
||||
ServersStore *ServersStore
|
||||
}
|
||||
|
||||
func NewClient() *Client {
|
||||
c := &Client{Now: time.Now}
|
||||
c.ExplorationStore = &ExplorationStore{client: c}
|
||||
c.SourcesStore = &SourcesStore{client: c}
|
||||
c.ServersStore = &ServersStore{client: c}
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,10 @@ func (c *Client) Open() error {
|
|||
if _, err := tx.CreateBucketIfNotExists(SourcesBucket); err != nil {
|
||||
return err
|
||||
}
|
||||
// Always create Servers bucket.
|
||||
if _, err := tx.CreateBucketIfNotExists(ServersBucket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
@ -49,6 +55,7 @@ func (c *Client) Open() error {
|
|||
|
||||
c.ExplorationStore = &ExplorationStore{client: c}
|
||||
c.SourcesStore = &SourcesStore{client: c}
|
||||
c.ServersStore = &ServersStore{client: c}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -69,3 +69,31 @@ func UnmarshalSource(data []byte, s *mrfusion.Source) error {
|
|||
s.Default = pb.Default
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalServer encodes an source to binary protobuf format.
|
||||
func MarshalServer(s mrfusion.Server) ([]byte, error) {
|
||||
return proto.Marshal(&Server{
|
||||
ID: int64(s.ID),
|
||||
SrcID: int64(s.SrcID),
|
||||
Name: s.Name,
|
||||
Username: s.Username,
|
||||
Password: s.Password,
|
||||
URL: s.URL,
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalServer decodes an source from binary protobuf data.
|
||||
func UnmarshalServer(data []byte, s *mrfusion.Server) error {
|
||||
var pb Server
|
||||
if err := proto.Unmarshal(data, &pb); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.ID = int(pb.ID)
|
||||
s.SrcID = int(pb.SrcID)
|
||||
s.Name = pb.Name
|
||||
s.Username = pb.Username
|
||||
s.Password = pb.Password
|
||||
s.URL = pb.URL
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ It is generated from these files:
|
|||
It has these top-level messages:
|
||||
Exploration
|
||||
Source
|
||||
Server
|
||||
*/
|
||||
package internal
|
||||
|
||||
|
@ -59,30 +60,47 @@ func (m *Source) String() string { return proto.CompactTextString(m)
|
|||
func (*Source) ProtoMessage() {}
|
||||
func (*Source) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{1} }
|
||||
|
||||
type Server struct {
|
||||
ID int64 `protobuf:"varint,1,opt,name=ID,json=iD,proto3" json:"ID,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"`
|
||||
Username string `protobuf:"bytes,3,opt,name=Username,json=username,proto3" json:"Username,omitempty"`
|
||||
Password string `protobuf:"bytes,4,opt,name=Password,json=password,proto3" json:"Password,omitempty"`
|
||||
URL string `protobuf:"bytes,5,opt,name=URL,json=uRL,proto3" json:"URL,omitempty"`
|
||||
SrcID int64 `protobuf:"varint,6,opt,name=SrcID,json=srcID,proto3" json:"SrcID,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Server) Reset() { *m = Server{} }
|
||||
func (m *Server) String() string { return proto.CompactTextString(m) }
|
||||
func (*Server) ProtoMessage() {}
|
||||
func (*Server) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{2} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Exploration)(nil), "internal.Exploration")
|
||||
proto.RegisterType((*Source)(nil), "internal.Source")
|
||||
proto.RegisterType((*Server)(nil), "internal.Server")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
|
||||
|
||||
var fileDescriptorInternal = []byte{
|
||||
// 257 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x90, 0xcf, 0x4a, 0xf4, 0x30,
|
||||
0x14, 0xc5, 0x49, 0xdb, 0x2f, 0x6d, 0xef, 0x07, 0xb3, 0xc8, 0x42, 0x82, 0xb8, 0x28, 0xb3, 0xea,
|
||||
0xca, 0x8d, 0x4f, 0x20, 0xd6, 0xc5, 0xc0, 0x20, 0x12, 0xed, 0x03, 0x5c, 0xa7, 0x57, 0x28, 0x74,
|
||||
0x9a, 0x90, 0x3f, 0xe8, 0xbc, 0x90, 0x2f, 0xe0, 0x0b, 0x4a, 0xd2, 0x76, 0x29, 0xb8, 0x3c, 0xf7,
|
||||
0x77, 0x38, 0xfc, 0x12, 0xd8, 0x8d, 0xb3, 0x27, 0x3b, 0xe3, 0x74, 0x6b, 0xac, 0xf6, 0x5a, 0x54,
|
||||
0x5b, 0xde, 0x7f, 0x33, 0xf8, 0xff, 0xf8, 0x69, 0x26, 0x6d, 0xd1, 0x8f, 0x7a, 0x16, 0x3b, 0xc8,
|
||||
0x0e, 0x9d, 0x64, 0x0d, 0x6b, 0x73, 0x95, 0x8d, 0x9d, 0x10, 0x50, 0x3c, 0xe1, 0x99, 0x64, 0xd6,
|
||||
0xb0, 0xb6, 0x56, 0xc5, 0x8c, 0x67, 0x12, 0x57, 0xc0, 0x7b, 0x47, 0xf6, 0xd0, 0xc9, 0x3c, 0xf5,
|
||||
0x78, 0x48, 0x29, 0x76, 0x3b, 0xf4, 0x28, 0x8b, 0xa5, 0x3b, 0xa0, 0x47, 0x71, 0x03, 0xf5, 0x83,
|
||||
0x25, 0xf4, 0x34, 0xdc, 0x7b, 0xf9, 0x2f, 0xd5, 0xeb, 0xd3, 0x76, 0x88, 0xb4, 0x37, 0xc3, 0x4a,
|
||||
0xf9, 0x42, 0xc3, 0x76, 0x10, 0x12, 0xca, 0x8e, 0xde, 0x31, 0x4c, 0x5e, 0x96, 0x0d, 0x6b, 0x2b,
|
||||
0x55, 0x0e, 0x4b, 0xdc, 0x7f, 0x31, 0xe0, 0x2f, 0x3a, 0xd8, 0x13, 0xfd, 0x49, 0x58, 0x40, 0xf1,
|
||||
0x7a, 0x31, 0x94, 0x74, 0x6b, 0x55, 0xf8, 0x8b, 0x21, 0x71, 0x0d, 0x55, 0x7c, 0x44, 0xe4, 0xab,
|
||||
0x70, 0x15, 0xd6, 0x1c, 0xd9, 0x33, 0x3a, 0xf7, 0xa1, 0xed, 0x90, 0x9c, 0x6b, 0x55, 0x99, 0x35,
|
||||
0xc7, 0xad, 0x5e, 0x1d, 0x9d, 0xe4, 0x4d, 0x1e, 0xb7, 0x82, 0x3a, 0xba, 0xdf, 0x45, 0xdf, 0x78,
|
||||
0xfa, 0xef, 0xbb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1d, 0x58, 0x30, 0x04, 0x81, 0x01, 0x00,
|
||||
0x00,
|
||||
// 299 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x91, 0xcd, 0x4a, 0x33, 0x31,
|
||||
0x14, 0x86, 0x99, 0x4e, 0x9a, 0xce, 0x9c, 0x0f, 0xca, 0x47, 0x10, 0x09, 0xe2, 0x62, 0xe8, 0xaa,
|
||||
0x2b, 0x37, 0x5e, 0x81, 0x18, 0x17, 0x85, 0x41, 0x24, 0x75, 0x2e, 0x20, 0x76, 0x8e, 0x50, 0x68,
|
||||
0x27, 0x21, 0x3f, 0x6a, 0xef, 0xc1, 0xeb, 0xf0, 0x06, 0xbc, 0x41, 0x49, 0x9a, 0x01, 0x71, 0x51,
|
||||
0xba, 0x7c, 0xce, 0xfb, 0x72, 0x78, 0x92, 0x03, 0xf3, 0xed, 0xe0, 0xd1, 0x0e, 0x6a, 0x77, 0x63,
|
||||
0xac, 0xf6, 0x9a, 0x55, 0x23, 0x2f, 0xbe, 0x0b, 0xf8, 0xf7, 0xf0, 0x61, 0x76, 0xda, 0x2a, 0xbf,
|
||||
0xd5, 0x03, 0x9b, 0xc3, 0x64, 0x25, 0x78, 0xd1, 0x14, 0xcb, 0x52, 0x4e, 0xb6, 0x82, 0x31, 0x20,
|
||||
0x8f, 0x6a, 0x8f, 0x7c, 0xd2, 0x14, 0xcb, 0x5a, 0x92, 0x41, 0xed, 0x91, 0x5d, 0x02, 0xed, 0x1c,
|
||||
0xda, 0x95, 0xe0, 0x65, 0xea, 0xd1, 0x90, 0x28, 0x76, 0x85, 0xf2, 0x8a, 0x93, 0x63, 0xb7, 0x57,
|
||||
0x5e, 0xb1, 0x6b, 0xa8, 0xef, 0x2d, 0x2a, 0x8f, 0xfd, 0x9d, 0xe7, 0xd3, 0x54, 0xaf, 0x37, 0xe3,
|
||||
0x20, 0xa6, 0x9d, 0xe9, 0x73, 0x4a, 0x8f, 0x69, 0x18, 0x07, 0x8c, 0xc3, 0x4c, 0xe0, 0xab, 0x0a,
|
||||
0x3b, 0xcf, 0x67, 0x4d, 0xb1, 0xac, 0xe4, 0xac, 0x3f, 0xe2, 0xe2, 0xab, 0x00, 0xba, 0xd6, 0xc1,
|
||||
0x6e, 0xf0, 0x2c, 0x61, 0x06, 0xe4, 0xf9, 0x60, 0x30, 0xe9, 0xd6, 0x92, 0xf8, 0x83, 0x41, 0x76,
|
||||
0x05, 0x55, 0x7c, 0x44, 0xcc, 0xb3, 0x70, 0x15, 0x32, 0xc7, 0xec, 0x49, 0x39, 0xf7, 0xae, 0x6d,
|
||||
0x9f, 0x9c, 0x6b, 0x59, 0x99, 0xcc, 0x71, 0x57, 0x27, 0x5b, 0xc7, 0x69, 0x53, 0xc6, 0x5d, 0x41,
|
||||
0xb6, 0xee, 0x84, 0xe8, 0x67, 0x14, 0x45, 0xfb, 0x86, 0xf6, 0x2c, 0xd1, 0xdf, 0x52, 0xe5, 0x09,
|
||||
0x29, 0xf2, 0x47, 0xea, 0x3f, 0x94, 0x9d, 0x6c, 0xb3, 0x6b, 0x19, 0x64, 0xcb, 0x2e, 0x60, 0xba,
|
||||
0xb6, 0x9b, 0x95, 0xc8, 0xbf, 0x3a, 0x75, 0x11, 0x5e, 0x68, 0x3a, 0xff, 0xed, 0x4f, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0xd9, 0x74, 0xaa, 0x1f, 0x10, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -20,3 +20,12 @@ message Source {
|
|||
repeated string URLs = 6; // URL are the connections to the source
|
||||
bool Default = 7; // Flags an exploration as the default.
|
||||
}
|
||||
|
||||
message Server {
|
||||
int64 ID = 1; // ID is the unique ID of the server
|
||||
string Name = 2; // Name is the user-defined name for the server
|
||||
string Username = 3; // Username is the username to connect to the server
|
||||
string Password = 4;
|
||||
string URL = 5; // URL is the path to the server
|
||||
int64 SrcID = 6; // SrcID is the ID of the data source
|
||||
}
|
||||
|
|
|
@ -50,3 +50,23 @@ func TestMarshalSource(t *testing.T) {
|
|||
t.Fatalf("source protobuf copy error: got %#v, expected %#v", vv, v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalServer(t *testing.T) {
|
||||
v := mrfusion.Server{
|
||||
ID: 12,
|
||||
SrcID: 2,
|
||||
Name: "Fountain of Truth",
|
||||
Username: "docbrown",
|
||||
Password: "1 point twenty-one g1g@w@tts",
|
||||
URL: "http://oldmanpeabody.mall.io:9092",
|
||||
}
|
||||
|
||||
var vv mrfusion.Server
|
||||
if buf, err := internal.MarshalServer(v); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := internal.UnmarshalServer(buf, &vv); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(v, vv) {
|
||||
t.Fatalf("source protobuf copy error: got %#v, expected %#v", vv, v)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
package bolt
|
||||
|
||||
import (
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/influxdata/mrfusion"
|
||||
"github.com/influxdata/mrfusion/bolt/internal"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Ensure ServersStore implements mrfusion.ServersStore.
|
||||
var _ mrfusion.ServersStore = &ServersStore{}
|
||||
|
||||
var ServersBucket = []byte("Servers")
|
||||
|
||||
type ServersStore struct {
|
||||
client *Client
|
||||
}
|
||||
|
||||
// All returns all known servers
|
||||
func (s *ServersStore) All(ctx context.Context) ([]mrfusion.Server, error) {
|
||||
var srcs []mrfusion.Server
|
||||
if err := s.client.db.View(func(tx *bolt.Tx) error {
|
||||
if err := tx.Bucket(ServersBucket).ForEach(func(k, v []byte) error {
|
||||
var src mrfusion.Server
|
||||
if err := internal.UnmarshalServer(v, &src); err != nil {
|
||||
return err
|
||||
}
|
||||
srcs = append(srcs, src)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return srcs, nil
|
||||
|
||||
}
|
||||
|
||||
// Add creates a new Server in the ServerStore.
|
||||
func (s *ServersStore) Add(ctx context.Context, src mrfusion.Server) (mrfusion.Server, error) {
|
||||
if err := s.client.db.Update(func(tx *bolt.Tx) error {
|
||||
b := tx.Bucket(ServersBucket)
|
||||
seq, err := b.NextSequence()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
src.ID = int(seq)
|
||||
|
||||
if v, err := internal.MarshalServer(src); err != nil {
|
||||
return err
|
||||
} else if err := b.Put(itob(src.ID), v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return mrfusion.Server{}, err
|
||||
}
|
||||
|
||||
return src, nil
|
||||
}
|
||||
|
||||
// Delete removes the Server from the ServersStore
|
||||
func (s *ServersStore) Delete(ctx context.Context, src mrfusion.Server) error {
|
||||
if err := s.client.db.Update(func(tx *bolt.Tx) error {
|
||||
if err := tx.Bucket(ServersBucket).Delete(itob(src.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get returns a Server if the id exists.
|
||||
func (s *ServersStore) Get(ctx context.Context, id int) (mrfusion.Server, error) {
|
||||
var src mrfusion.Server
|
||||
if err := s.client.db.View(func(tx *bolt.Tx) error {
|
||||
if v := tx.Bucket(ServersBucket).Get(itob(id)); v == nil {
|
||||
return mrfusion.ErrServerNotFound
|
||||
} else if err := internal.UnmarshalServer(v, &src); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return mrfusion.Server{}, err
|
||||
}
|
||||
|
||||
return src, nil
|
||||
}
|
||||
|
||||
// Update a Server
|
||||
func (s *ServersStore) Update(ctx context.Context, src mrfusion.Server) error {
|
||||
if err := s.client.db.Update(func(tx *bolt.Tx) error {
|
||||
// Get an existing server with the same ID.
|
||||
b := tx.Bucket(ServersBucket)
|
||||
if v := b.Get(itob(src.ID)); v == nil {
|
||||
return mrfusion.ErrServerNotFound
|
||||
}
|
||||
|
||||
if v, err := internal.MarshalServer(src); err != nil {
|
||||
return err
|
||||
} else if err := b.Put(itob(src.ID), v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package bolt_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/mrfusion"
|
||||
)
|
||||
|
||||
// Ensure an ServerStore can store, retrieve, update, and delete servers.
|
||||
func TestServerStore(t *testing.T) {
|
||||
c, err := NewTestClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := c.Open(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer c.Close()
|
||||
s := c.ServersStore
|
||||
|
||||
srcs := []mrfusion.Server{
|
||||
mrfusion.Server{
|
||||
Name: "Of Truth",
|
||||
SrcID: 10,
|
||||
Username: "marty",
|
||||
Password: "I❤️ jennifer parker",
|
||||
URL: "toyota-hilux.lyon-estates.local",
|
||||
},
|
||||
mrfusion.Server{
|
||||
Name: "HipToBeSquare",
|
||||
SrcID: 12,
|
||||
Username: "calvinklein",
|
||||
Password: "chuck b3rry",
|
||||
URL: "toyota-hilux.lyon-estates.local",
|
||||
},
|
||||
}
|
||||
|
||||
// Add new srcs.
|
||||
for i, src := range srcs {
|
||||
if srcs[i], err = s.Add(nil, src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Confirm first src in the store is the same as the original.
|
||||
if actual, err := s.Get(nil, srcs[i].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(actual, srcs[i]) {
|
||||
t.Fatal("server loaded is different then server saved; actual: %v, expected %v", actual, srcs[i])
|
||||
}
|
||||
}
|
||||
|
||||
// Update server.
|
||||
srcs[0].Username = "calvinklein"
|
||||
srcs[1].Name = "Enchantment Under the Sea Dance"
|
||||
if err := s.Update(nil, srcs[0]); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := s.Update(nil, srcs[1]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Confirm servers have updated.
|
||||
if src, err := s.Get(nil, srcs[0].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if src.Username != "calvinklein" {
|
||||
t.Fatalf("server 0 update error: got %v, expected %v", src.Username, "calvinklein")
|
||||
}
|
||||
if src, err := s.Get(nil, srcs[1].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if src.Name != "Enchantment Under the Sea Dance" {
|
||||
t.Fatalf("server 1 update error: got %v, expected %v", src.Name, "Enchantment Under the Sea Dance")
|
||||
}
|
||||
|
||||
// Delete an server.
|
||||
if err := s.Delete(nil, srcs[0]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Confirm server has been deleted.
|
||||
if _, err := s.Get(nil, srcs[0].ID); err != mrfusion.ErrServerNotFound {
|
||||
t.Fatalf("server delete error: got %v, expected %v", err, mrfusion.ErrServerNotFound)
|
||||
}
|
||||
|
||||
if bsrcs, err := s.All(nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if len(bsrcs) != 1 {
|
||||
t.Fatalf("After delete All returned incorrect number of srcs; got %d, expected %d", len(bsrcs), 1)
|
||||
} else if !reflect.DeepEqual(bsrcs[0], srcs[1]) {
|
||||
t.Fatalf("After delete All returned incorrect server; got %v, expected %v", bsrcs[0], srcs[1])
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Ensure ExplorationStore implements mrfusion.ExplorationStore.
|
||||
// Ensure SourcesStore implements mrfusion.SourcesStore.
|
||||
var _ mrfusion.SourcesStore = &SourcesStore{}
|
||||
|
||||
var SourcesBucket = []byte("Sources")
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package bolt_test
|
||||
|
||||
import (
|
||||
|
||||
// "fmt"
|
||||
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/mrfusion"
|
||||
)
|
||||
|
||||
// Ensure an SourceStore can store, retrieve, update, and delete explorations.
|
||||
// Ensure an SourceStore can store, retrieve, update, and delete sources.
|
||||
func TestSourceStore(t *testing.T) {
|
||||
c, err := NewTestClient()
|
||||
if err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ const (
|
|||
ErrUpstreamTimeout = Error("request to backend timed out")
|
||||
ErrExplorationNotFound = Error("exploration not found")
|
||||
ErrSourceNotFound = Error("source not found")
|
||||
ErrServerNotFound = Error("server not found")
|
||||
)
|
||||
|
||||
// Error is a domain error encountered while processing mrfusion requests
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/influxdata/mrfusion"
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
|
||||
op "github.com/influxdata/mrfusion/restapi/operations"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (h *Store) NewKapacitor(ctx context.Context, params op.PostSourcesIDKapacitorsParams) middleware.Responder {
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewGetSourcesIDKapacitorsDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
_, err = h.SourcesStore.Get(ctx, srcID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.ID)}
|
||||
return op.NewGetSourcesIDKapacitorsDefault(404).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv := mrfusion.Server{
|
||||
SrcID: srcID,
|
||||
Name: *params.Kapacitor.Name,
|
||||
Username: params.Kapacitor.Username,
|
||||
Password: params.Kapacitor.Password,
|
||||
URL: *params.Kapacitor.URL,
|
||||
}
|
||||
if srv, err = h.ServersStore.Add(ctx, srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error storing kapacitor %v: %v", params.Kapacitor, err)}
|
||||
return op.NewPostSourcesIDKapacitorsDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
mSrv := srvToModel(srv)
|
||||
return op.NewPostSourcesIDKapacitorsCreated().WithPayload(mSrv).WithLocation(mSrv.Links.Self)
|
||||
}
|
||||
|
||||
func srvLinks(srcID int, id int) *models.KapacitorLinks {
|
||||
return &models.KapacitorLinks{
|
||||
Self: fmt.Sprintf("/chronograf/v1/sources/%d/kapacitors/%d", srcID, id),
|
||||
Proxy: fmt.Sprintf("/chronograf/v1/sources/%d/kapacitors/%d/proxy", srcID, id),
|
||||
}
|
||||
}
|
||||
|
||||
func srvToModel(srv mrfusion.Server) *models.Kapacitor {
|
||||
return &models.Kapacitor{
|
||||
ID: strconv.Itoa(srv.ID),
|
||||
Links: srvLinks(srv.SrcID, srv.ID),
|
||||
Name: &srv.Name,
|
||||
Username: srv.Username,
|
||||
Password: srv.Password,
|
||||
URL: &srv.URL,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Store) Kapacitors(ctx context.Context, params op.GetSourcesIDKapacitorsParams) middleware.Responder {
|
||||
mrSrvs, err := h.ServersStore.All(ctx)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: "Error loading kapacitors"}
|
||||
return op.NewGetSourcesIDKapacitorsDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srvs := make([]*models.Kapacitor, len(mrSrvs))
|
||||
for i, srv := range mrSrvs {
|
||||
srvs[i] = srvToModel(srv)
|
||||
}
|
||||
|
||||
res := &models.Kapacitors{
|
||||
Kapacitors: srvs,
|
||||
}
|
||||
|
||||
return op.NewGetSourcesIDKapacitorsOK().WithPayload(res)
|
||||
}
|
||||
|
||||
func (h *Store) KapacitorsID(ctx context.Context, params op.GetSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDOK().WithPayload(srvToModel(srv))
|
||||
}
|
||||
|
||||
func (h *Store) RemoveKapacitor(ctx context.Context, params op.DeleteSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if err = h.ServersStore.Delete(ctx, srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Unknown error deleting kapacitor %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDNoContent()
|
||||
}
|
||||
|
||||
func (h *Store) UpdateKapacitor(ctx context.Context, params op.PatchSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDNotFound().WithPayload(errMsg)
|
||||
}
|
||||
if params.Config.Name != nil {
|
||||
srv.Name = *params.Config.Name
|
||||
}
|
||||
if params.Config.Password != "" {
|
||||
srv.Password = params.Config.Password
|
||||
}
|
||||
if params.Config.Username != "" {
|
||||
srv.Username = params.Config.Username
|
||||
}
|
||||
if params.Config.URL != nil {
|
||||
srv.URL = *params.Config.URL
|
||||
}
|
||||
if err := h.ServersStore.Update(ctx, srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error updating kapacitor ID %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDNoContent()
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
@ -13,8 +15,10 @@ import (
|
|||
)
|
||||
|
||||
type InfluxProxy struct {
|
||||
Srcs mrfusion.SourcesStore
|
||||
TimeSeries mrfusion.TimeSeries
|
||||
Srcs mrfusion.SourcesStore
|
||||
ServersStore mrfusion.ServersStore
|
||||
TimeSeries mrfusion.TimeSeries
|
||||
KapacitorProxy mrfusion.Proxy
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) Proxy(ctx context.Context, params op.PostSourcesIDProxyParams) middleware.Responder {
|
||||
|
@ -65,3 +69,236 @@ func (h *InfluxProxy) Proxy(ctx context.Context, params op.PostSourcesIDProxyPar
|
|||
}
|
||||
return op.NewPostSourcesIDProxyOK().WithPayload(res)
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) KapacitorProxyPost(ctx context.Context, params op.PostSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if err = h.KapacitorProxy.Connect(ctx, &srv); err != nil {
|
||||
errMsg := &models.Error{Code: 400, Message: fmt.Sprintf("Unable to connect to servers store %s", params.KapaID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
body, err := json.Marshal(params.Query)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting to JSON %v", err)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
req := &mrfusion.Request{
|
||||
Method: "POST",
|
||||
Path: params.Path,
|
||||
Body: body,
|
||||
}
|
||||
|
||||
resp, err := h.KapacitorProxy.Do(ctx, req)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error with proxy %v", err)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNoContent {
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyNoContent()
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var j interface{}
|
||||
err = dec.Decode(&j)
|
||||
if err != nil && err.Error() == "EOF" && resp.StatusCode != http.StatusOK {
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error reading body of response: %v", err)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(resp.StatusCode).WithPayload(j)
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) KapacitorProxyPatch(ctx context.Context, params op.PatchSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if err = h.KapacitorProxy.Connect(ctx, &srv); err != nil {
|
||||
errMsg := &models.Error{Code: 400, Message: fmt.Sprintf("Unable to connect to servers store %s", params.KapaID)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
body, err := json.Marshal(params.Query)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting to JSON %v", err)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
req := &mrfusion.Request{
|
||||
Method: "PATCH",
|
||||
Path: params.Path,
|
||||
Body: body,
|
||||
}
|
||||
|
||||
resp, err := h.KapacitorProxy.Do(ctx, req)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error with proxy %v", err)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNoContent {
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyNoContent()
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var j interface{}
|
||||
err = dec.Decode(&j)
|
||||
if err != nil && err.Error() == "EOF" && resp.StatusCode != http.StatusOK {
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error reading body of response: %v", err)}
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
return op.NewPatchSourcesIDKapacitorsKapaIDProxyDefault(resp.StatusCode).WithPayload(j)
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) KapacitorProxyGet(ctx context.Context, params op.GetSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if err = h.KapacitorProxy.Connect(ctx, &srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Unable to connect to servers store %s", params.KapaID)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
req := &mrfusion.Request{
|
||||
Method: "GET",
|
||||
Path: params.Path,
|
||||
}
|
||||
|
||||
resp, err := h.KapacitorProxy.Do(ctx, req)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error with proxy %v", err)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNoContent {
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyNoContent()
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var j interface{}
|
||||
err = dec.Decode(&j)
|
||||
if err != nil && err.Error() == "EOF" && resp.StatusCode != http.StatusOK {
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error reading body of response: %v", err)}
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyDefault(resp.StatusCode).WithPayload(j)
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) KapacitorProxyDelete(ctx context.Context, params op.DeleteSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.KapaID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srcID, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil || srv.SrcID != srcID {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
if err = h.KapacitorProxy.Connect(ctx, &srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Unable to connect to servers store %s", params.KapaID)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
req := &mrfusion.Request{
|
||||
Method: "DELETE",
|
||||
Path: params.Path,
|
||||
}
|
||||
|
||||
resp, err := h.KapacitorProxy.Do(ctx, req)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error with proxy %v", err)}
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNoContent {
|
||||
return op.NewGetSourcesIDKapacitorsKapaIDProxyNoContent()
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var j interface{}
|
||||
err = dec.Decode(&j)
|
||||
if err != nil && err.Error() == "EOF" && resp.StatusCode != http.StatusOK {
|
||||
err = nil
|
||||
}
|
||||
|
||||
return op.NewDeleteSourcesIDKapacitorsKapaIDProxyDefault(resp.StatusCode).WithPayload(j)
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ func srcLinks(id int) *models.SourceLinks {
|
|||
Users: fmt.Sprintf("/chronograf/v1/sources/%d/users", id),
|
||||
Roles: fmt.Sprintf("/chronograf/v1/sources/%d/roles", id),
|
||||
Permissions: fmt.Sprintf("/chronograf/v1/sources/%d/permissions", id),
|
||||
Kapacitors: fmt.Sprintf("/chronograf/v1/sources/%d/kapacitors", id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,4 +6,5 @@ import "github.com/influxdata/mrfusion"
|
|||
type Store struct {
|
||||
ExplorationStore mrfusion.ExplorationStore
|
||||
SourcesStore mrfusion.SourcesStore
|
||||
ServersStore mrfusion.ServersStore
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package kapacitor
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/influxdata/mrfusion"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Client is a device for retrieving time series data from an InfluxDB instance
|
||||
type Proxy struct {
|
||||
URL *url.URL
|
||||
}
|
||||
|
||||
func (p *Proxy) Do(ctx context.Context, req *mrfusion.Request) (*http.Response, error) {
|
||||
// TODO: Locking?
|
||||
p.URL.Path = req.Path
|
||||
|
||||
httpReq, err := http.NewRequest(req.Method, p.URL.String(), bytes.NewBuffer(req.Body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
httpReq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
httpClient := &http.Client{}
|
||||
return httpClient.Do(httpReq)
|
||||
}
|
||||
|
||||
func (p *Proxy) Connect(ctx context.Context, srv *mrfusion.Server) error {
|
||||
u, err := url.Parse(srv.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.User = url.UserPassword(srv.Username, srv.Password)
|
||||
p.URL = u
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
/*Kapacitor kapacitor
|
||||
|
||||
swagger:model Kapacitor
|
||||
*/
|
||||
type Kapacitor struct {
|
||||
|
||||
/* Unique identifier representing a kapacitor instance.
|
||||
|
||||
Read Only: true
|
||||
*/
|
||||
ID string `json:"id,omitempty"`
|
||||
|
||||
/* links
|
||||
*/
|
||||
Links *KapacitorLinks `json:"links,omitempty"`
|
||||
|
||||
/* User facing name of kapacitor instance.
|
||||
|
||||
Required: true
|
||||
*/
|
||||
Name *string `json:"name"`
|
||||
|
||||
/* Password in cleartext!
|
||||
*/
|
||||
Password string `json:"password,omitempty"`
|
||||
|
||||
/* URL for the kapacitor backend (e.g. http://localhost:9092)
|
||||
|
||||
Required: true
|
||||
*/
|
||||
URL *string `json:"url"`
|
||||
|
||||
/* Username for authentication to kapacitor
|
||||
*/
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this kapacitor
|
||||
func (m *Kapacitor) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateLinks(formats); err != nil {
|
||||
// prop
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
// prop
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateURL(formats); err != nil {
|
||||
// prop
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Kapacitor) validateLinks(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Links) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Links != nil {
|
||||
|
||||
if err := m.Links.Validate(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Kapacitor) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Kapacitor) validateURL(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("url", "body", m.URL); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*KapacitorLinks kapacitor links
|
||||
|
||||
swagger:model KapacitorLinks
|
||||
*/
|
||||
type KapacitorLinks struct {
|
||||
|
||||
/* URL location of proxy endpoint for this source
|
||||
*/
|
||||
Proxy string `json:"proxy,omitempty"`
|
||||
|
||||
/* Self link mapping to this resource
|
||||
*/
|
||||
Self string `json:"self,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this kapacitor links
|
||||
func (m *KapacitorLinks) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
/*KapacitorProxy Entirely used as the body for the request to the kapacitor backend.
|
||||
|
||||
swagger:model KapacitorProxy
|
||||
*/
|
||||
type KapacitorProxy interface{}
|
|
@ -0,0 +1,10 @@
|
|||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
/*KapacitorProxyResponse Entire response from the kapacitor backend.
|
||||
|
||||
swagger:model KapacitorProxyResponse
|
||||
*/
|
||||
type KapacitorProxyResponse interface{}
|
|
@ -0,0 +1,64 @@
|
|||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
/*Kapacitors kapacitors
|
||||
|
||||
swagger:model Kapacitors
|
||||
*/
|
||||
type Kapacitors struct {
|
||||
|
||||
/* kapacitors
|
||||
|
||||
Required: true
|
||||
*/
|
||||
Kapacitors []*Kapacitor `json:"kapacitors"`
|
||||
}
|
||||
|
||||
// Validate validates this kapacitors
|
||||
func (m *Kapacitors) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateKapacitors(formats); err != nil {
|
||||
// prop
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Kapacitors) validateKapacitors(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("kapacitors", "body", m.Kapacitors); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Kapacitors); i++ {
|
||||
|
||||
if swag.IsZero(m.Kapacitors[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Kapacitors[i] != nil {
|
||||
|
||||
if err := m.Kapacitors[i].Validate(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -161,6 +161,10 @@ swagger:model SourceLinks
|
|||
*/
|
||||
type SourceLinks struct {
|
||||
|
||||
/* URL location of the kapacitors endpoint for this source
|
||||
*/
|
||||
Kapacitors string `json:"kapacitors,omitempty"`
|
||||
|
||||
/* URL location of the monitored services endpoint for this source
|
||||
*/
|
||||
Monitored string `json:"monitored,omitempty"`
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package mrfusion
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Request contains the information needed to make an HTTP call.
|
||||
type Request struct {
|
||||
Method string // Method is the HTTP Verb (POST, PUT, PATCH, GET, etc)
|
||||
Path string // URL Path (not host)
|
||||
Body json.RawMessage // Body is sent if not nil
|
||||
}
|
||||
|
||||
//Proxy will forward the request onto the
|
||||
type Proxy interface {
|
||||
// Do transformation Request and returns the http.Response
|
||||
Do(ctx context.Context, req *Request) (*http.Response, error)
|
||||
// Connect will transform Server a URL for `Do`
|
||||
Connect(ctx context.Context, srv *Server) error
|
||||
}
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/influxdata/mrfusion/dist"
|
||||
"github.com/influxdata/mrfusion/handlers"
|
||||
"github.com/influxdata/mrfusion/influx"
|
||||
"github.com/influxdata/mrfusion/kapacitor"
|
||||
fusionlog "github.com/influxdata/mrfusion/log"
|
||||
"github.com/influxdata/mrfusion/mock"
|
||||
op "github.com/influxdata/mrfusion/restapi/operations"
|
||||
|
@ -95,6 +96,7 @@ func configureAPI(api *op.MrFusionAPI) http.Handler {
|
|||
h := handlers.Store{
|
||||
ExplorationStore: c.ExplorationStore,
|
||||
SourcesStore: c.SourcesStore,
|
||||
ServersStore: c.ServersStore,
|
||||
}
|
||||
api.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(h.DeleteExploration)
|
||||
api.GetSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.GetSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(h.Exploration)
|
||||
|
@ -109,12 +111,25 @@ func configureAPI(api *op.MrFusionAPI) http.Handler {
|
|||
api.GetSourcesIDHandler = op.GetSourcesIDHandlerFunc(h.SourcesID)
|
||||
api.PostSourcesHandler = op.PostSourcesHandlerFunc(h.NewSource)
|
||||
|
||||
ts := influx.Client{}
|
||||
api.GetSourcesIDKapacitorsHandler = op.GetSourcesIDKapacitorsHandlerFunc(h.Kapacitors)
|
||||
api.PostSourcesIDKapacitorsHandler = op.PostSourcesIDKapacitorsHandlerFunc(h.NewKapacitor)
|
||||
|
||||
api.GetSourcesIDKapacitorsKapaIDHandler = op.GetSourcesIDKapacitorsKapaIDHandlerFunc(h.KapacitorsID)
|
||||
api.DeleteSourcesIDKapacitorsKapaIDHandler = op.DeleteSourcesIDKapacitorsKapaIDHandlerFunc(h.RemoveKapacitor)
|
||||
api.PatchSourcesIDKapacitorsKapaIDHandler = op.PatchSourcesIDKapacitorsKapaIDHandlerFunc(h.UpdateKapacitor)
|
||||
|
||||
p := handlers.InfluxProxy{
|
||||
Srcs: c.SourcesStore,
|
||||
TimeSeries: &ts,
|
||||
Srcs: c.SourcesStore,
|
||||
TimeSeries: &influx.Client{},
|
||||
KapacitorProxy: &kapacitor.Proxy{},
|
||||
ServersStore: c.ServersStore,
|
||||
}
|
||||
api.PostSourcesIDProxyHandler = op.PostSourcesIDProxyHandlerFunc(p.Proxy)
|
||||
|
||||
api.PostSourcesIDKapacitorsKapaIDProxyHandler = op.PostSourcesIDKapacitorsKapaIDProxyHandlerFunc(p.KapacitorProxyPost)
|
||||
api.PatchSourcesIDKapacitorsKapaIDProxyHandler = op.PatchSourcesIDKapacitorsKapaIDProxyHandlerFunc(p.KapacitorProxyPatch)
|
||||
api.GetSourcesIDKapacitorsKapaIDProxyHandler = op.GetSourcesIDKapacitorsKapaIDProxyHandlerFunc(p.KapacitorProxyGet)
|
||||
api.DeleteSourcesIDKapacitorsKapaIDProxyHandler = op.DeleteSourcesIDKapacitorsKapaIDProxyHandlerFunc(p.KapacitorProxyDelete)
|
||||
} else {
|
||||
api.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(mockHandler.DeleteExploration)
|
||||
api.GetSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.GetSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(mockHandler.Exploration)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDHandlerFunc turns a function with the right signature into a delete sources ID kapacitors kapa ID handler
|
||||
type DeleteSourcesIDKapacitorsKapaIDHandlerFunc func(context.Context, DeleteSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteSourcesIDKapacitorsKapaIDHandlerFunc) Handle(ctx context.Context, params DeleteSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDHandler interface for that can handle valid delete sources ID kapacitors kapa ID params
|
||||
type DeleteSourcesIDKapacitorsKapaIDHandler interface {
|
||||
Handle(context.Context, DeleteSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaID creates a new http.Handler for the delete sources ID kapacitors kapa ID operation
|
||||
func NewDeleteSourcesIDKapacitorsKapaID(ctx *middleware.Context, handler DeleteSourcesIDKapacitorsKapaIDHandler) *DeleteSourcesIDKapacitorsKapaID {
|
||||
return &DeleteSourcesIDKapacitorsKapaID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaID swagger:route DELETE /sources/{id}/kapacitors/{kapa_id} deleteSourcesIdKapacitorsKapaId
|
||||
|
||||
This specific kapacitor will be removed.
|
||||
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaID struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteSourcesIDKapacitorsKapaIDHandler
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewDeleteSourcesIDKapacitorsKapaIDParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDParams creates a new DeleteSourcesIDKapacitorsKapaIDParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDParams() DeleteSourcesIDKapacitorsKapaIDParams {
|
||||
var ()
|
||||
return DeleteSourcesIDKapacitorsKapaIDParams{}
|
||||
}
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDParams contains all the bound params for the delete sources ID kapacitors kapa ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteSourcesIDKapacitorsKapaID
|
||||
type DeleteSourcesIDKapacitorsKapaIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDProxyHandlerFunc turns a function with the right signature into a delete sources ID kapacitors kapa ID proxy handler
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyHandlerFunc func(context.Context, DeleteSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteSourcesIDKapacitorsKapaIDProxyHandlerFunc) Handle(ctx context.Context, params DeleteSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDProxyHandler interface for that can handle valid delete sources ID kapacitors kapa ID proxy params
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyHandler interface {
|
||||
Handle(context.Context, DeleteSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDProxy creates a new http.Handler for the delete sources ID kapacitors kapa ID proxy operation
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDProxy(ctx *middleware.Context, handler DeleteSourcesIDKapacitorsKapaIDProxyHandler) *DeleteSourcesIDKapacitorsKapaIDProxy {
|
||||
return &DeleteSourcesIDKapacitorsKapaIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDProxy swagger:route DELETE /sources/{id}/kapacitors/{kapa_id}/proxy deleteSourcesIdKapacitorsKapaIdProxy
|
||||
|
||||
DELETE to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteSourcesIDKapacitorsKapaIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewDeleteSourcesIDKapacitorsKapaIDProxyParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDProxyParams creates a new DeleteSourcesIDKapacitorsKapaIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDProxyParams() DeleteSourcesIDKapacitorsKapaIDProxyParams {
|
||||
var ()
|
||||
return DeleteSourcesIDKapacitorsKapaIDProxyParams{}
|
||||
}
|
||||
|
||||
// DeleteSourcesIDKapacitorsKapaIDProxyParams contains all the bound params for the delete sources ID kapacitors kapa ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteSourcesIDKapacitorsKapaIDProxy
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
/*The kapacitor API path to use in the proxy redirect
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Path string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qPath, qhkPath, _ := qs.GetOK("path")
|
||||
if err := o.bindPath(qPath, qhkPath, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyParams) bindPath(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("path", "query")
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if err := validate.RequiredString("path", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Path = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDProxyNoContent Kapacitor returned no content
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdProxyNoContent
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyNoContent struct {
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDProxyNoContent creates DeleteSourcesIDKapacitorsKapaIDProxyNoContent with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDProxyNoContent() *DeleteSourcesIDKapacitorsKapaIDProxyNoContent {
|
||||
return &DeleteSourcesIDKapacitorsKapaIDProxyNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDProxyNotFound Data source or Kapacitor ID does not exist.
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdProxyNotFound
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDProxyNotFound creates DeleteSourcesIDKapacitorsKapaIDProxyNotFound with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDProxyNotFound() *DeleteSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
return &DeleteSourcesIDKapacitorsKapaIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyNotFound) WithPayload(payload *models.Error) *DeleteSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdProxyDefault
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDProxyDefault creates DeleteSourcesIDKapacitorsKapaIDProxyDefault with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDProxyDefault(code int) *DeleteSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteSourcesIDKapacitorsKapaIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete sources ID kapacitors kapa ID proxy default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyDefault) WithStatusCode(code int) *DeleteSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete sources ID kapacitors kapa ID proxy default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete sources ID kapacitors kapa ID proxy default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *DeleteSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete sources ID kapacitors kapa ID proxy default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDProxyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDNoContent kapacitor has been removed.
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdNoContent
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDNoContent struct {
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDNoContent creates DeleteSourcesIDKapacitorsKapaIDNoContent with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDNoContent() *DeleteSourcesIDKapacitorsKapaIDNoContent {
|
||||
return &DeleteSourcesIDKapacitorsKapaIDNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDNotFound Unknown Data source or Kapacitor id
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdNotFound
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDNotFound creates DeleteSourcesIDKapacitorsKapaIDNotFound with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDNotFound() *DeleteSourcesIDKapacitorsKapaIDNotFound {
|
||||
return &DeleteSourcesIDKapacitorsKapaIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete sources Id kapacitors kapa Id not found response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDNotFound) WithPayload(payload *models.Error) *DeleteSourcesIDKapacitorsKapaIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete sources Id kapacitors kapa Id not found response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteSourcesIDKapacitorsKapaIDDefault Unexpected internal service error
|
||||
|
||||
swagger:response deleteSourcesIdKapacitorsKapaIdDefault
|
||||
*/
|
||||
type DeleteSourcesIDKapacitorsKapaIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteSourcesIDKapacitorsKapaIDDefault creates DeleteSourcesIDKapacitorsKapaIDDefault with default headers values
|
||||
func NewDeleteSourcesIDKapacitorsKapaIDDefault(code int) *DeleteSourcesIDKapacitorsKapaIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteSourcesIDKapacitorsKapaIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete sources ID kapacitors kapa ID default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDDefault) WithStatusCode(code int) *DeleteSourcesIDKapacitorsKapaIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete sources ID kapacitors kapa ID default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete sources ID kapacitors kapa ID default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDDefault) WithPayload(payload *models.Error) *DeleteSourcesIDKapacitorsKapaIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete sources ID kapacitors kapa ID default response
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteSourcesIDKapacitorsKapaIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// GetSourcesIDKapacitorsHandlerFunc turns a function with the right signature into a get sources ID kapacitors handler
|
||||
type GetSourcesIDKapacitorsHandlerFunc func(context.Context, GetSourcesIDKapacitorsParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetSourcesIDKapacitorsHandlerFunc) Handle(ctx context.Context, params GetSourcesIDKapacitorsParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsHandler interface for that can handle valid get sources ID kapacitors params
|
||||
type GetSourcesIDKapacitorsHandler interface {
|
||||
Handle(context.Context, GetSourcesIDKapacitorsParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitors creates a new http.Handler for the get sources ID kapacitors operation
|
||||
func NewGetSourcesIDKapacitors(ctx *middleware.Context, handler GetSourcesIDKapacitorsHandler) *GetSourcesIDKapacitors {
|
||||
return &GetSourcesIDKapacitors{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitors swagger:route GET /sources/{id}/kapacitors getSourcesIdKapacitors
|
||||
|
||||
Configured kapacitors
|
||||
|
||||
*/
|
||||
type GetSourcesIDKapacitors struct {
|
||||
Context *middleware.Context
|
||||
Handler GetSourcesIDKapacitorsHandler
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitors) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetSourcesIDKapacitorsParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDHandlerFunc turns a function with the right signature into a get sources ID kapacitors kapa ID handler
|
||||
type GetSourcesIDKapacitorsKapaIDHandlerFunc func(context.Context, GetSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetSourcesIDKapacitorsKapaIDHandlerFunc) Handle(ctx context.Context, params GetSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDHandler interface for that can handle valid get sources ID kapacitors kapa ID params
|
||||
type GetSourcesIDKapacitorsKapaIDHandler interface {
|
||||
Handle(context.Context, GetSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaID creates a new http.Handler for the get sources ID kapacitors kapa ID operation
|
||||
func NewGetSourcesIDKapacitorsKapaID(ctx *middleware.Context, handler GetSourcesIDKapacitorsKapaIDHandler) *GetSourcesIDKapacitorsKapaID {
|
||||
return &GetSourcesIDKapacitorsKapaID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaID swagger:route GET /sources/{id}/kapacitors/{kapa_id} getSourcesIdKapacitorsKapaId
|
||||
|
||||
Configured kapacitors
|
||||
|
||||
These kapacitors are used for monitoring and alerting.
|
||||
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaID struct {
|
||||
Context *middleware.Context
|
||||
Handler GetSourcesIDKapacitorsKapaIDHandler
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetSourcesIDKapacitorsKapaIDParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDParams creates a new GetSourcesIDKapacitorsKapaIDParams object
|
||||
// with the default values initialized.
|
||||
func NewGetSourcesIDKapacitorsKapaIDParams() GetSourcesIDKapacitorsKapaIDParams {
|
||||
var ()
|
||||
return GetSourcesIDKapacitorsKapaIDParams{}
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDParams contains all the bound params for the get sources ID kapacitors kapa ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetSourcesIDKapacitorsKapaID
|
||||
type GetSourcesIDKapacitorsKapaIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *GetSourcesIDKapacitorsKapaIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDProxyHandlerFunc turns a function with the right signature into a get sources ID kapacitors kapa ID proxy handler
|
||||
type GetSourcesIDKapacitorsKapaIDProxyHandlerFunc func(context.Context, GetSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetSourcesIDKapacitorsKapaIDProxyHandlerFunc) Handle(ctx context.Context, params GetSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDProxyHandler interface for that can handle valid get sources ID kapacitors kapa ID proxy params
|
||||
type GetSourcesIDKapacitorsKapaIDProxyHandler interface {
|
||||
Handle(context.Context, GetSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDProxy creates a new http.Handler for the get sources ID kapacitors kapa ID proxy operation
|
||||
func NewGetSourcesIDKapacitorsKapaIDProxy(ctx *middleware.Context, handler GetSourcesIDKapacitorsKapaIDProxyHandler) *GetSourcesIDKapacitorsKapaIDProxy {
|
||||
return &GetSourcesIDKapacitorsKapaIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDProxy swagger:route GET /sources/{id}/kapacitors/{kapa_id}/proxy getSourcesIdKapacitorsKapaIdProxy
|
||||
|
||||
GET to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler GetSourcesIDKapacitorsKapaIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetSourcesIDKapacitorsKapaIDProxyParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDProxyParams creates a new GetSourcesIDKapacitorsKapaIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewGetSourcesIDKapacitorsKapaIDProxyParams() GetSourcesIDKapacitorsKapaIDProxyParams {
|
||||
var ()
|
||||
return GetSourcesIDKapacitorsKapaIDProxyParams{}
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsKapaIDProxyParams contains all the bound params for the get sources ID kapacitors kapa ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetSourcesIDKapacitorsKapaIDProxy
|
||||
type GetSourcesIDKapacitorsKapaIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
/*The kapacitor API path to use in the proxy redirect
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Path string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qPath, qhkPath, _ := qs.GetOK("path")
|
||||
if err := o.bindPath(qPath, qhkPath, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyParams) bindPath(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("path", "query")
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if err := validate.RequiredString("path", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Path = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDProxyNoContent Kapacitor returned no content
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdProxyNoContent
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDProxyNoContent struct {
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDProxyNoContent creates GetSourcesIDKapacitorsKapaIDProxyNoContent with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDProxyNoContent() *GetSourcesIDKapacitorsKapaIDProxyNoContent {
|
||||
return &GetSourcesIDKapacitorsKapaIDProxyNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDProxyNotFound Data source or Kapacitor ID does not exist.
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdProxyNotFound
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDProxyNotFound creates GetSourcesIDKapacitorsKapaIDProxyNotFound with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDProxyNotFound() *GetSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
return &GetSourcesIDKapacitorsKapaIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyNotFound) WithPayload(payload *models.Error) *GetSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdProxyDefault
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDProxyDefault creates GetSourcesIDKapacitorsKapaIDProxyDefault with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDProxyDefault(code int) *GetSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetSourcesIDKapacitorsKapaIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get sources ID kapacitors kapa ID proxy default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyDefault) WithStatusCode(code int) *GetSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get sources ID kapacitors kapa ID proxy default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources ID kapacitors kapa ID proxy default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *GetSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources ID kapacitors kapa ID proxy default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDProxyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDOK Kapacitor connection information
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdOK
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDOK struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitor `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDOK creates GetSourcesIDKapacitorsKapaIDOK with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDOK() *GetSourcesIDKapacitorsKapaIDOK {
|
||||
return &GetSourcesIDKapacitorsKapaIDOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources Id kapacitors kapa Id o k response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDOK) WithPayload(payload *models.Kapacitor) *GetSourcesIDKapacitorsKapaIDOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources Id kapacitors kapa Id o k response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDOK) SetPayload(payload *models.Kapacitor) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDNotFound Unknown data source or kapacitor id
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdNotFound
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDNotFound creates GetSourcesIDKapacitorsKapaIDNotFound with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDNotFound() *GetSourcesIDKapacitorsKapaIDNotFound {
|
||||
return &GetSourcesIDKapacitorsKapaIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources Id kapacitors kapa Id not found response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDNotFound) WithPayload(payload *models.Error) *GetSourcesIDKapacitorsKapaIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources Id kapacitors kapa Id not found response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsKapaIDDefault Unexpected internal service error
|
||||
|
||||
swagger:response getSourcesIdKapacitorsKapaIdDefault
|
||||
*/
|
||||
type GetSourcesIDKapacitorsKapaIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsKapaIDDefault creates GetSourcesIDKapacitorsKapaIDDefault with default headers values
|
||||
func NewGetSourcesIDKapacitorsKapaIDDefault(code int) *GetSourcesIDKapacitorsKapaIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetSourcesIDKapacitorsKapaIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get sources ID kapacitors kapa ID default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDDefault) WithStatusCode(code int) *GetSourcesIDKapacitorsKapaIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get sources ID kapacitors kapa ID default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources ID kapacitors kapa ID default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDDefault) WithPayload(payload *models.Error) *GetSourcesIDKapacitorsKapaIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources ID kapacitors kapa ID default response
|
||||
func (o *GetSourcesIDKapacitorsKapaIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsKapaIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetSourcesIDKapacitorsParams creates a new GetSourcesIDKapacitorsParams object
|
||||
// with the default values initialized.
|
||||
func NewGetSourcesIDKapacitorsParams() GetSourcesIDKapacitorsParams {
|
||||
var ()
|
||||
return GetSourcesIDKapacitorsParams{}
|
||||
}
|
||||
|
||||
// GetSourcesIDKapacitorsParams contains all the bound params for the get sources ID kapacitors operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetSourcesIDKapacitors
|
||||
type GetSourcesIDKapacitorsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *GetSourcesIDKapacitorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetSourcesIDKapacitorsParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*GetSourcesIDKapacitorsOK An array of kapacitors
|
||||
|
||||
swagger:response getSourcesIdKapacitorsOK
|
||||
*/
|
||||
type GetSourcesIDKapacitorsOK struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitors `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsOK creates GetSourcesIDKapacitorsOK with default headers values
|
||||
func NewGetSourcesIDKapacitorsOK() *GetSourcesIDKapacitorsOK {
|
||||
return &GetSourcesIDKapacitorsOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources Id kapacitors o k response
|
||||
func (o *GetSourcesIDKapacitorsOK) WithPayload(payload *models.Kapacitors) *GetSourcesIDKapacitorsOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources Id kapacitors o k response
|
||||
func (o *GetSourcesIDKapacitorsOK) SetPayload(payload *models.Kapacitors) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetSourcesIDKapacitorsDefault Unexpected internal service error
|
||||
|
||||
swagger:response getSourcesIdKapacitorsDefault
|
||||
*/
|
||||
type GetSourcesIDKapacitorsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetSourcesIDKapacitorsDefault creates GetSourcesIDKapacitorsDefault with default headers values
|
||||
func NewGetSourcesIDKapacitorsDefault(code int) *GetSourcesIDKapacitorsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetSourcesIDKapacitorsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get sources ID kapacitors default response
|
||||
func (o *GetSourcesIDKapacitorsDefault) WithStatusCode(code int) *GetSourcesIDKapacitorsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get sources ID kapacitors default response
|
||||
func (o *GetSourcesIDKapacitorsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get sources ID kapacitors default response
|
||||
func (o *GetSourcesIDKapacitorsDefault) WithPayload(payload *models.Error) *GetSourcesIDKapacitorsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get sources ID kapacitors default response
|
||||
func (o *GetSourcesIDKapacitorsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetSourcesIDKapacitorsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,10 @@ type MrFusionAPI struct {
|
|||
DeleteDashboardsIDHandler DeleteDashboardsIDHandler
|
||||
// DeleteSourcesIDHandler sets the operation handler for the delete sources ID operation
|
||||
DeleteSourcesIDHandler DeleteSourcesIDHandler
|
||||
// DeleteSourcesIDKapacitorsKapaIDHandler sets the operation handler for the delete sources ID kapacitors kapa ID operation
|
||||
DeleteSourcesIDKapacitorsKapaIDHandler DeleteSourcesIDKapacitorsKapaIDHandler
|
||||
// DeleteSourcesIDKapacitorsKapaIDProxyHandler sets the operation handler for the delete sources ID kapacitors kapa ID proxy operation
|
||||
DeleteSourcesIDKapacitorsKapaIDProxyHandler DeleteSourcesIDKapacitorsKapaIDProxyHandler
|
||||
// DeleteSourcesIDRolesRoleIDHandler sets the operation handler for the delete sources ID roles role ID operation
|
||||
DeleteSourcesIDRolesRoleIDHandler DeleteSourcesIDRolesRoleIDHandler
|
||||
// DeleteSourcesIDUsersUserIDHandler sets the operation handler for the delete sources ID users user ID operation
|
||||
|
@ -62,6 +66,12 @@ type MrFusionAPI struct {
|
|||
GetSourcesHandler GetSourcesHandler
|
||||
// GetSourcesIDHandler sets the operation handler for the get sources ID operation
|
||||
GetSourcesIDHandler GetSourcesIDHandler
|
||||
// GetSourcesIDKapacitorsHandler sets the operation handler for the get sources ID kapacitors operation
|
||||
GetSourcesIDKapacitorsHandler GetSourcesIDKapacitorsHandler
|
||||
// GetSourcesIDKapacitorsKapaIDHandler sets the operation handler for the get sources ID kapacitors kapa ID operation
|
||||
GetSourcesIDKapacitorsKapaIDHandler GetSourcesIDKapacitorsKapaIDHandler
|
||||
// GetSourcesIDKapacitorsKapaIDProxyHandler sets the operation handler for the get sources ID kapacitors kapa ID proxy operation
|
||||
GetSourcesIDKapacitorsKapaIDProxyHandler GetSourcesIDKapacitorsKapaIDProxyHandler
|
||||
// GetSourcesIDMonitoredHandler sets the operation handler for the get sources ID monitored operation
|
||||
GetSourcesIDMonitoredHandler GetSourcesIDMonitoredHandler
|
||||
// GetSourcesIDPermissionsHandler sets the operation handler for the get sources ID permissions operation
|
||||
|
@ -80,6 +90,10 @@ type MrFusionAPI struct {
|
|||
GetSourcesIDUsersUserIDExplorationsExplorationIDHandler GetSourcesIDUsersUserIDExplorationsExplorationIDHandler
|
||||
// PatchSourcesIDHandler sets the operation handler for the patch sources ID operation
|
||||
PatchSourcesIDHandler PatchSourcesIDHandler
|
||||
// PatchSourcesIDKapacitorsKapaIDHandler sets the operation handler for the patch sources ID kapacitors kapa ID operation
|
||||
PatchSourcesIDKapacitorsKapaIDHandler PatchSourcesIDKapacitorsKapaIDHandler
|
||||
// PatchSourcesIDKapacitorsKapaIDProxyHandler sets the operation handler for the patch sources ID kapacitors kapa ID proxy operation
|
||||
PatchSourcesIDKapacitorsKapaIDProxyHandler PatchSourcesIDKapacitorsKapaIDProxyHandler
|
||||
// PatchSourcesIDRolesRoleIDHandler sets the operation handler for the patch sources ID roles role ID operation
|
||||
PatchSourcesIDRolesRoleIDHandler PatchSourcesIDRolesRoleIDHandler
|
||||
// PatchSourcesIDUsersUserIDHandler sets the operation handler for the patch sources ID users user ID operation
|
||||
|
@ -90,6 +104,10 @@ type MrFusionAPI struct {
|
|||
PostDashboardsHandler PostDashboardsHandler
|
||||
// PostSourcesHandler sets the operation handler for the post sources operation
|
||||
PostSourcesHandler PostSourcesHandler
|
||||
// PostSourcesIDKapacitorsHandler sets the operation handler for the post sources ID kapacitors operation
|
||||
PostSourcesIDKapacitorsHandler PostSourcesIDKapacitorsHandler
|
||||
// PostSourcesIDKapacitorsKapaIDProxyHandler sets the operation handler for the post sources ID kapacitors kapa ID proxy operation
|
||||
PostSourcesIDKapacitorsKapaIDProxyHandler PostSourcesIDKapacitorsKapaIDProxyHandler
|
||||
// PostSourcesIDProxyHandler sets the operation handler for the post sources ID proxy operation
|
||||
PostSourcesIDProxyHandler PostSourcesIDProxyHandler
|
||||
// PostSourcesIDRolesHandler sets the operation handler for the post sources ID roles operation
|
||||
|
@ -171,6 +189,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "DeleteSourcesIDHandler")
|
||||
}
|
||||
|
||||
if o.DeleteSourcesIDKapacitorsKapaIDHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteSourcesIDKapacitorsKapaIDHandler")
|
||||
}
|
||||
|
||||
if o.DeleteSourcesIDKapacitorsKapaIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteSourcesIDKapacitorsKapaIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.DeleteSourcesIDRolesRoleIDHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteSourcesIDRolesRoleIDHandler")
|
||||
}
|
||||
|
@ -203,6 +229,18 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "GetSourcesIDHandler")
|
||||
}
|
||||
|
||||
if o.GetSourcesIDKapacitorsHandler == nil {
|
||||
unregistered = append(unregistered, "GetSourcesIDKapacitorsHandler")
|
||||
}
|
||||
|
||||
if o.GetSourcesIDKapacitorsKapaIDHandler == nil {
|
||||
unregistered = append(unregistered, "GetSourcesIDKapacitorsKapaIDHandler")
|
||||
}
|
||||
|
||||
if o.GetSourcesIDKapacitorsKapaIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "GetSourcesIDKapacitorsKapaIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.GetSourcesIDMonitoredHandler == nil {
|
||||
unregistered = append(unregistered, "GetSourcesIDMonitoredHandler")
|
||||
}
|
||||
|
@ -239,6 +277,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "PatchSourcesIDHandler")
|
||||
}
|
||||
|
||||
if o.PatchSourcesIDKapacitorsKapaIDHandler == nil {
|
||||
unregistered = append(unregistered, "PatchSourcesIDKapacitorsKapaIDHandler")
|
||||
}
|
||||
|
||||
if o.PatchSourcesIDKapacitorsKapaIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "PatchSourcesIDKapacitorsKapaIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.PatchSourcesIDRolesRoleIDHandler == nil {
|
||||
unregistered = append(unregistered, "PatchSourcesIDRolesRoleIDHandler")
|
||||
}
|
||||
|
@ -259,6 +305,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "PostSourcesHandler")
|
||||
}
|
||||
|
||||
if o.PostSourcesIDKapacitorsHandler == nil {
|
||||
unregistered = append(unregistered, "PostSourcesIDKapacitorsHandler")
|
||||
}
|
||||
|
||||
if o.PostSourcesIDKapacitorsKapaIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "PostSourcesIDKapacitorsKapaIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.PostSourcesIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "PostSourcesIDProxyHandler")
|
||||
}
|
||||
|
@ -370,6 +424,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["DELETE"]["/sources/{id}"] = NewDeleteSourcesID(o.context, o.DeleteSourcesIDHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/sources/{id}/kapacitors/{kapa_id}"] = NewDeleteSourcesIDKapacitorsKapaID(o.context, o.DeleteSourcesIDKapacitorsKapaIDHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/sources/{id}/kapacitors/{kapa_id}/proxy"] = NewDeleteSourcesIDKapacitorsKapaIDProxy(o.context, o.DeleteSourcesIDKapacitorsKapaIDProxyHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -410,6 +474,21 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["GET"]["/sources/{id}"] = NewGetSourcesID(o.context, o.GetSourcesIDHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/sources/{id}/kapacitors"] = NewGetSourcesIDKapacitors(o.context, o.GetSourcesIDKapacitorsHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/sources/{id}/kapacitors/{kapa_id}"] = NewGetSourcesIDKapacitorsKapaID(o.context, o.GetSourcesIDKapacitorsKapaIDHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/sources/{id}/kapacitors/{kapa_id}/proxy"] = NewGetSourcesIDKapacitorsKapaIDProxy(o.context, o.GetSourcesIDKapacitorsKapaIDProxyHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -455,6 +534,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["PATCH"]["/sources/{id}"] = NewPatchSourcesID(o.context, o.PatchSourcesIDHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/sources/{id}/kapacitors/{kapa_id}"] = NewPatchSourcesIDKapacitorsKapaID(o.context, o.PatchSourcesIDKapacitorsKapaIDHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/sources/{id}/kapacitors/{kapa_id}/proxy"] = NewPatchSourcesIDKapacitorsKapaIDProxy(o.context, o.PatchSourcesIDKapacitorsKapaIDProxyHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -480,6 +569,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["POST"]["/sources"] = NewPostSources(o.context, o.PostSourcesHandler)
|
||||
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/sources/{id}/kapacitors"] = NewPostSourcesIDKapacitors(o.context, o.PostSourcesIDKapacitorsHandler)
|
||||
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/sources/{id}/kapacitors/{kapa_id}/proxy"] = NewPostSourcesIDKapacitorsKapaIDProxy(o.context, o.PostSourcesIDKapacitorsKapaIDProxyHandler)
|
||||
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDHandlerFunc turns a function with the right signature into a patch sources ID kapacitors kapa ID handler
|
||||
type PatchSourcesIDKapacitorsKapaIDHandlerFunc func(context.Context, PatchSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PatchSourcesIDKapacitorsKapaIDHandlerFunc) Handle(ctx context.Context, params PatchSourcesIDKapacitorsKapaIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDHandler interface for that can handle valid patch sources ID kapacitors kapa ID params
|
||||
type PatchSourcesIDKapacitorsKapaIDHandler interface {
|
||||
Handle(context.Context, PatchSourcesIDKapacitorsKapaIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaID creates a new http.Handler for the patch sources ID kapacitors kapa ID operation
|
||||
func NewPatchSourcesIDKapacitorsKapaID(ctx *middleware.Context, handler PatchSourcesIDKapacitorsKapaIDHandler) *PatchSourcesIDKapacitorsKapaID {
|
||||
return &PatchSourcesIDKapacitorsKapaID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaID swagger:route PATCH /sources/{id}/kapacitors/{kapa_id} patchSourcesIdKapacitorsKapaId
|
||||
|
||||
Update kapacitor configuration
|
||||
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaID struct {
|
||||
Context *middleware.Context
|
||||
Handler PatchSourcesIDKapacitorsKapaIDHandler
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPatchSourcesIDKapacitorsKapaIDParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDParams creates a new PatchSourcesIDKapacitorsKapaIDParams object
|
||||
// with the default values initialized.
|
||||
func NewPatchSourcesIDKapacitorsKapaIDParams() PatchSourcesIDKapacitorsKapaIDParams {
|
||||
var ()
|
||||
return PatchSourcesIDKapacitorsKapaIDParams{}
|
||||
}
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDParams contains all the bound params for the patch sources ID kapacitors kapa ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PatchSourcesIDKapacitorsKapaID
|
||||
type PatchSourcesIDKapacitorsKapaIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*kapacitor configuration
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Config *models.Kapacitor
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of a kapacitor backend
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.Kapacitor
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("config", "body"))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("config", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Config = &body
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
res = append(res, errors.Required("config", "body"))
|
||||
}
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDProxyHandlerFunc turns a function with the right signature into a patch sources ID kapacitors kapa ID proxy handler
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyHandlerFunc func(context.Context, PatchSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PatchSourcesIDKapacitorsKapaIDProxyHandlerFunc) Handle(ctx context.Context, params PatchSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDProxyHandler interface for that can handle valid patch sources ID kapacitors kapa ID proxy params
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyHandler interface {
|
||||
Handle(context.Context, PatchSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDProxy creates a new http.Handler for the patch sources ID kapacitors kapa ID proxy operation
|
||||
func NewPatchSourcesIDKapacitorsKapaIDProxy(ctx *middleware.Context, handler PatchSourcesIDKapacitorsKapaIDProxyHandler) *PatchSourcesIDKapacitorsKapaIDProxy {
|
||||
return &PatchSourcesIDKapacitorsKapaIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDProxy swagger:route PATCH /sources/{id}/kapacitors/{kapa_id}/proxy patchSourcesIdKapacitorsKapaIdProxy
|
||||
|
||||
PATCH body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler PatchSourcesIDKapacitorsKapaIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPatchSourcesIDKapacitorsKapaIDProxyParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDProxyParams creates a new PatchSourcesIDKapacitorsKapaIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewPatchSourcesIDKapacitorsKapaIDProxyParams() PatchSourcesIDKapacitorsKapaIDProxyParams {
|
||||
var ()
|
||||
return PatchSourcesIDKapacitorsKapaIDProxyParams{}
|
||||
}
|
||||
|
||||
// PatchSourcesIDKapacitorsKapaIDProxyParams contains all the bound params for the patch sources ID kapacitors kapa ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PatchSourcesIDKapacitorsKapaIDProxy
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
/*The kapacitor API path to use in the proxy redirect
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Path string
|
||||
/*Kapacitor body
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Query models.KapacitorProxy
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qPath, qhkPath, _ := qs.GetOK("path")
|
||||
if err := o.bindPath(qPath, qhkPath, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.KapacitorProxy
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("query", "body"))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("query", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Query = body
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
res = append(res, errors.Required("query", "body"))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyParams) bindPath(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("path", "query")
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if err := validate.RequiredString("path", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Path = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDProxyNoContent Kapacitor returned no content
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdProxyNoContent
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyNoContent struct {
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDProxyNoContent creates PatchSourcesIDKapacitorsKapaIDProxyNoContent with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDProxyNoContent() *PatchSourcesIDKapacitorsKapaIDProxyNoContent {
|
||||
return &PatchSourcesIDKapacitorsKapaIDProxyNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDProxyNotFound Data source or Kapacitor ID does not exist.
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdProxyNotFound
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDProxyNotFound creates PatchSourcesIDKapacitorsKapaIDProxyNotFound with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDProxyNotFound() *PatchSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
return &PatchSourcesIDKapacitorsKapaIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyNotFound) WithPayload(payload *models.Error) *PatchSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdProxyDefault
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDProxyDefault creates PatchSourcesIDKapacitorsKapaIDProxyDefault with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDProxyDefault(code int) *PatchSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PatchSourcesIDKapacitorsKapaIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the patch sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyDefault) WithStatusCode(code int) *PatchSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the patch sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *PatchSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDProxyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDNoContent Kapacitor's configuration was changed
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdNoContent
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDNoContent struct {
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDNoContent creates PatchSourcesIDKapacitorsKapaIDNoContent with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDNoContent() *PatchSourcesIDKapacitorsKapaIDNoContent {
|
||||
return &PatchSourcesIDKapacitorsKapaIDNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDNotFound Happens when trying to access a non-existent data source or kapacitor.
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdNotFound
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDNotFound creates PatchSourcesIDKapacitorsKapaIDNotFound with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDNotFound() *PatchSourcesIDKapacitorsKapaIDNotFound {
|
||||
return &PatchSourcesIDKapacitorsKapaIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch sources Id kapacitors kapa Id not found response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDNotFound) WithPayload(payload *models.Error) *PatchSourcesIDKapacitorsKapaIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch sources Id kapacitors kapa Id not found response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PatchSourcesIDKapacitorsKapaIDDefault A processing or an unexpected error.
|
||||
|
||||
swagger:response patchSourcesIdKapacitorsKapaIdDefault
|
||||
*/
|
||||
type PatchSourcesIDKapacitorsKapaIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchSourcesIDKapacitorsKapaIDDefault creates PatchSourcesIDKapacitorsKapaIDDefault with default headers values
|
||||
func NewPatchSourcesIDKapacitorsKapaIDDefault(code int) *PatchSourcesIDKapacitorsKapaIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PatchSourcesIDKapacitorsKapaIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the patch sources ID kapacitors kapa ID default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDDefault) WithStatusCode(code int) *PatchSourcesIDKapacitorsKapaIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the patch sources ID kapacitors kapa ID default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch sources ID kapacitors kapa ID default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDDefault) WithPayload(payload *models.Error) *PatchSourcesIDKapacitorsKapaIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch sources ID kapacitors kapa ID default response
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchSourcesIDKapacitorsKapaIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// PostSourcesIDKapacitorsHandlerFunc turns a function with the right signature into a post sources ID kapacitors handler
|
||||
type PostSourcesIDKapacitorsHandlerFunc func(context.Context, PostSourcesIDKapacitorsParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PostSourcesIDKapacitorsHandlerFunc) Handle(ctx context.Context, params PostSourcesIDKapacitorsParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PostSourcesIDKapacitorsHandler interface for that can handle valid post sources ID kapacitors params
|
||||
type PostSourcesIDKapacitorsHandler interface {
|
||||
Handle(context.Context, PostSourcesIDKapacitorsParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitors creates a new http.Handler for the post sources ID kapacitors operation
|
||||
func NewPostSourcesIDKapacitors(ctx *middleware.Context, handler PostSourcesIDKapacitorsHandler) *PostSourcesIDKapacitors {
|
||||
return &PostSourcesIDKapacitors{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PostSourcesIDKapacitors swagger:route POST /sources/{id}/kapacitors postSourcesIdKapacitors
|
||||
|
||||
Create new kapacitor backend
|
||||
|
||||
*/
|
||||
type PostSourcesIDKapacitors struct {
|
||||
Context *middleware.Context
|
||||
Handler PostSourcesIDKapacitorsHandler
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitors) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPostSourcesIDKapacitorsParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
context "golang.org/x/net/context"
|
||||
|
||||
middleware "github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// PostSourcesIDKapacitorsKapaIDProxyHandlerFunc turns a function with the right signature into a post sources ID kapacitors kapa ID proxy handler
|
||||
type PostSourcesIDKapacitorsKapaIDProxyHandlerFunc func(context.Context, PostSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PostSourcesIDKapacitorsKapaIDProxyHandlerFunc) Handle(ctx context.Context, params PostSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PostSourcesIDKapacitorsKapaIDProxyHandler interface for that can handle valid post sources ID kapacitors kapa ID proxy params
|
||||
type PostSourcesIDKapacitorsKapaIDProxyHandler interface {
|
||||
Handle(context.Context, PostSourcesIDKapacitorsKapaIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsKapaIDProxy creates a new http.Handler for the post sources ID kapacitors kapa ID proxy operation
|
||||
func NewPostSourcesIDKapacitorsKapaIDProxy(ctx *middleware.Context, handler PostSourcesIDKapacitorsKapaIDProxyHandler) *PostSourcesIDKapacitorsKapaIDProxy {
|
||||
return &PostSourcesIDKapacitorsKapaIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PostSourcesIDKapacitorsKapaIDProxy swagger:route POST /sources/{id}/kapacitors/{kapa_id}/proxy postSourcesIdKapacitorsKapaIdProxy
|
||||
|
||||
POST body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type PostSourcesIDKapacitorsKapaIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler PostSourcesIDKapacitorsKapaIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPostSourcesIDKapacitorsKapaIDProxyParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(context.Background(), Params) // actually handle the request
|
||||
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
// NewPostSourcesIDKapacitorsKapaIDProxyParams creates a new PostSourcesIDKapacitorsKapaIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewPostSourcesIDKapacitorsKapaIDProxyParams() PostSourcesIDKapacitorsKapaIDProxyParams {
|
||||
var ()
|
||||
return PostSourcesIDKapacitorsKapaIDProxyParams{}
|
||||
}
|
||||
|
||||
// PostSourcesIDKapacitorsKapaIDProxyParams contains all the bound params for the post sources ID kapacitors kapa ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PostSourcesIDKapacitorsKapaIDProxy
|
||||
type PostSourcesIDKapacitorsKapaIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
KapaID string
|
||||
/*The kapacitor API path to use in the proxy redirect
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Path string
|
||||
/*Kapacitor body
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Query models.KapacitorProxy
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rKapaID, rhkKapaID, _ := route.Params.GetOK("kapa_id")
|
||||
if err := o.bindKapaID(rKapaID, rhkKapaID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qPath, qhkPath, _ := qs.GetOK("path")
|
||||
if err := o.bindPath(qPath, qhkPath, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.KapacitorProxy
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("query", "body"))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("query", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Query = body
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
res = append(res, errors.Required("query", "body"))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyParams) bindKapaID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.KapaID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyParams) bindPath(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("path", "query")
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if err := validate.RequiredString("path", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Path = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*PostSourcesIDKapacitorsKapaIDProxyNoContent Kapacitor returned no content
|
||||
|
||||
swagger:response postSourcesIdKapacitorsKapaIdProxyNoContent
|
||||
*/
|
||||
type PostSourcesIDKapacitorsKapaIDProxyNoContent struct {
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsKapaIDProxyNoContent creates PostSourcesIDKapacitorsKapaIDProxyNoContent with default headers values
|
||||
func NewPostSourcesIDKapacitorsKapaIDProxyNoContent() *PostSourcesIDKapacitorsKapaIDProxyNoContent {
|
||||
return &PostSourcesIDKapacitorsKapaIDProxyNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*PostSourcesIDKapacitorsKapaIDProxyNotFound Kapacitor ID does not exist.
|
||||
|
||||
swagger:response postSourcesIdKapacitorsKapaIdProxyNotFound
|
||||
*/
|
||||
type PostSourcesIDKapacitorsKapaIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsKapaIDProxyNotFound creates PostSourcesIDKapacitorsKapaIDProxyNotFound with default headers values
|
||||
func NewPostSourcesIDKapacitorsKapaIDProxyNotFound() *PostSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
return &PostSourcesIDKapacitorsKapaIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyNotFound) WithPayload(payload *models.Error) *PostSourcesIDKapacitorsKapaIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post sources Id kapacitors kapa Id proxy not found response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(404)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PostSourcesIDKapacitorsKapaIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response postSourcesIdKapacitorsKapaIdProxyDefault
|
||||
*/
|
||||
type PostSourcesIDKapacitorsKapaIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsKapaIDProxyDefault creates PostSourcesIDKapacitorsKapaIDProxyDefault with default headers values
|
||||
func NewPostSourcesIDKapacitorsKapaIDProxyDefault(code int) *PostSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PostSourcesIDKapacitorsKapaIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the post sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyDefault) WithStatusCode(code int) *PostSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the post sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *PostSourcesIDKapacitorsKapaIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post sources ID kapacitors kapa ID proxy default response
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostSourcesIDKapacitorsKapaIDProxyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
// NewPostSourcesIDKapacitorsParams creates a new PostSourcesIDKapacitorsParams object
|
||||
// with the default values initialized.
|
||||
func NewPostSourcesIDKapacitorsParams() PostSourcesIDKapacitorsParams {
|
||||
var ()
|
||||
return PostSourcesIDKapacitorsParams{}
|
||||
}
|
||||
|
||||
// PostSourcesIDKapacitorsParams contains all the bound params for the post sources ID kapacitors operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PostSourcesIDKapacitors
|
||||
type PostSourcesIDKapacitorsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the source
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*Configuration options for kapacitor
|
||||
In: body
|
||||
*/
|
||||
Kapacitor *models.Kapacitor
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *PostSourcesIDKapacitorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
rID, rhkID, _ := route.Params.GetOK("id")
|
||||
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.Kapacitor
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("kapacitor", "body", "", err))
|
||||
} else {
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Kapacitor = &body
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PostSourcesIDKapacitorsParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package operations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
/*PostSourcesIDKapacitorsCreated Successfully created kapacitor source
|
||||
|
||||
swagger:response postSourcesIdKapacitorsCreated
|
||||
*/
|
||||
type PostSourcesIDKapacitorsCreated struct {
|
||||
/*Location of the newly created kapacitor resource.
|
||||
Required: true
|
||||
*/
|
||||
Location string `json:"Location"`
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitor `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsCreated creates PostSourcesIDKapacitorsCreated with default headers values
|
||||
func NewPostSourcesIDKapacitorsCreated() *PostSourcesIDKapacitorsCreated {
|
||||
return &PostSourcesIDKapacitorsCreated{}
|
||||
}
|
||||
|
||||
// WithLocation adds the location to the post sources Id kapacitors created response
|
||||
func (o *PostSourcesIDKapacitorsCreated) WithLocation(location string) *PostSourcesIDKapacitorsCreated {
|
||||
o.Location = location
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLocation sets the location to the post sources Id kapacitors created response
|
||||
func (o *PostSourcesIDKapacitorsCreated) SetLocation(location string) {
|
||||
o.Location = location
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post sources Id kapacitors created response
|
||||
func (o *PostSourcesIDKapacitorsCreated) WithPayload(payload *models.Kapacitor) *PostSourcesIDKapacitorsCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post sources Id kapacitors created response
|
||||
func (o *PostSourcesIDKapacitorsCreated) SetPayload(payload *models.Kapacitor) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostSourcesIDKapacitorsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
// response header Location
|
||||
rw.Header().Add("Location", fmt.Sprintf("%v", o.Location))
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PostSourcesIDKapacitorsDefault A processing or an unexpected error.
|
||||
|
||||
swagger:response postSourcesIdKapacitorsDefault
|
||||
*/
|
||||
type PostSourcesIDKapacitorsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostSourcesIDKapacitorsDefault creates PostSourcesIDKapacitorsDefault with default headers values
|
||||
func NewPostSourcesIDKapacitorsDefault(code int) *PostSourcesIDKapacitorsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PostSourcesIDKapacitorsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the post sources ID kapacitors default response
|
||||
func (o *PostSourcesIDKapacitorsDefault) WithStatusCode(code int) *PostSourcesIDKapacitorsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the post sources ID kapacitors default response
|
||||
func (o *PostSourcesIDKapacitorsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post sources ID kapacitors default response
|
||||
func (o *PostSourcesIDKapacitorsDefault) WithPayload(payload *models.Error) *PostSourcesIDKapacitorsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post sources ID kapacitors default response
|
||||
func (o *PostSourcesIDKapacitorsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostSourcesIDKapacitorsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
if err := producer.Produce(rw, o.Payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
23
stores.go
23
stores.go
|
@ -140,3 +140,26 @@ type SourcesStore interface {
|
|||
// Update the Source in the store.
|
||||
Update(context.Context, Source) error
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
ID int // ID is the unique ID of the server
|
||||
SrcID int // SrcID of the data soruce
|
||||
Name string // Name is the user-defined name for the server
|
||||
Username string // Username is the username to connect to the server
|
||||
Password string // Password is in CLEARTEXT FIXME
|
||||
URL string // URL are the connections to the server
|
||||
}
|
||||
|
||||
// ServersStore stores connection information for a `Server`
|
||||
type ServersStore interface {
|
||||
// All returns all servers in the store
|
||||
All(context.Context) ([]Server, error)
|
||||
// Add creates a new source in the ServersStore and returns Server with ID
|
||||
Add(context.Context, Server) (Server, error)
|
||||
// Delete the Server from the store
|
||||
Delete(context.Context, Server) error
|
||||
// Get retrieves Server if `ID` exists
|
||||
Get(ctx context.Context, ID int) (Server, error)
|
||||
// Update the Server in the store.
|
||||
Update(context.Context, Server) error
|
||||
}
|
||||
|
|
310
swagger.yaml
310
swagger.yaml
|
@ -623,6 +623,263 @@ paths:
|
|||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/sources/{id}/kapacitors:
|
||||
get:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
summary: Configured kapacitors
|
||||
responses:
|
||||
200:
|
||||
description: An array of kapacitors
|
||||
schema:
|
||||
$ref: '#/definitions/Kapacitors'
|
||||
default:
|
||||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
post:
|
||||
summary: Create new kapacitor backend
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapacitor
|
||||
in: body
|
||||
description: Configuration options for kapacitor
|
||||
schema:
|
||||
$ref: '#/definitions/Kapacitor'
|
||||
responses:
|
||||
201:
|
||||
description: Successfully created kapacitor source
|
||||
headers:
|
||||
Location:
|
||||
type: string
|
||||
format: url
|
||||
description: Location of the newly created kapacitor resource.
|
||||
schema:
|
||||
$ref: '#/definitions/Kapacitor'
|
||||
default:
|
||||
description: A processing or an unexpected error.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/sources/{id}/kapacitors/{kapa_id}:
|
||||
get:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor
|
||||
required: true
|
||||
summary: Configured kapacitors
|
||||
description: These kapacitors are used for monitoring and alerting.
|
||||
responses:
|
||||
200:
|
||||
description: Kapacitor connection information
|
||||
schema:
|
||||
$ref: '#/definitions/Kapacitor'
|
||||
404:
|
||||
description: Unknown data source or kapacitor id
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
patch:
|
||||
summary: Update kapacitor configuration
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of a kapacitor backend
|
||||
required: true
|
||||
- name: config
|
||||
in: body
|
||||
description: kapacitor configuration
|
||||
schema:
|
||||
$ref: '#/definitions/Kapacitor'
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Kapacitor's configuration was changed
|
||||
404:
|
||||
description: Happens when trying to access a non-existent data source or kapacitor.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: A processing or an unexpected error.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
delete:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor
|
||||
required: true
|
||||
summary: This specific kapacitor will be removed.
|
||||
responses:
|
||||
204:
|
||||
description: kapacitor has been removed.
|
||||
404:
|
||||
description: Unknown Data source or Kapacitor id
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/sources/{id}/kapacitors/{kapa_id}/proxy:
|
||||
get:
|
||||
description: GET to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Kapacitor returned no content
|
||||
404:
|
||||
description: Data source or Kapacitor ID does not exist.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Response directly from kapacitor
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxyResponse'
|
||||
delete:
|
||||
description: DELETE to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Kapacitor returned no content
|
||||
404:
|
||||
description: Data source or Kapacitor ID does not exist.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Response directly from kapacitor
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxyResponse'
|
||||
patch:
|
||||
description: PATCH body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
- name: query
|
||||
in: body
|
||||
description: Kapacitor body
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxy'
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Kapacitor returned no content
|
||||
404:
|
||||
description: Data source or Kapacitor ID does not exist.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Response directly from kapacitor
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxyResponse'
|
||||
|
||||
post:
|
||||
description: POST body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the source
|
||||
required: true
|
||||
- name: kapa_id
|
||||
in: path
|
||||
type: string
|
||||
description: ID of the kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
- name: query
|
||||
in: body
|
||||
description: Kapacitor body
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxy'
|
||||
required: true
|
||||
responses:
|
||||
204:
|
||||
description: Kapacitor returned no content
|
||||
404:
|
||||
description: Kapacitor ID does not exist.
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Response directly from kapacitor
|
||||
schema:
|
||||
$ref: '#/definitions/KapacitorProxyResponse'
|
||||
/dashboards:
|
||||
get:
|
||||
summary: Pre-configured dashboards
|
||||
|
@ -728,6 +985,55 @@ paths:
|
|||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
definitions:
|
||||
Kapacitors:
|
||||
type: object
|
||||
required:
|
||||
- kapacitors
|
||||
properties:
|
||||
kapacitors:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Kapacitor'
|
||||
Kapacitor:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique identifier representing a kapacitor instance.
|
||||
readOnly: True
|
||||
name:
|
||||
type: string
|
||||
description: User facing name of kapacitor instance.
|
||||
username:
|
||||
type: string
|
||||
description: Username for authentication to kapacitor
|
||||
password:
|
||||
type: string
|
||||
description: Password in cleartext!
|
||||
url:
|
||||
type: string
|
||||
format: url
|
||||
description: URL for the kapacitor backend (e.g. http://localhost:9092)
|
||||
links:
|
||||
type: object
|
||||
properties:
|
||||
self:
|
||||
type: string
|
||||
description: Self link mapping to this resource
|
||||
format: url
|
||||
proxy:
|
||||
type: string
|
||||
description: URL location of proxy endpoint for this source
|
||||
format: url
|
||||
KapacitorProxy:
|
||||
description: Entirely used as the body for the request to the kapacitor backend.
|
||||
type: object
|
||||
KapacitorProxyResponse:
|
||||
description: Entire response from the kapacitor backend.
|
||||
type: object
|
||||
Sources:
|
||||
type: object
|
||||
required:
|
||||
|
@ -792,6 +1098,10 @@ definitions:
|
|||
type: string
|
||||
description: URL location of the permissions endpoint for this source
|
||||
format: url
|
||||
kapacitors:
|
||||
type: string
|
||||
description: URL location of the kapacitors endpoint for this source
|
||||
format: url
|
||||
monitored:
|
||||
type: string
|
||||
description: URL location of the monitored services endpoint for this source
|
||||
|
|
Loading…
Reference in New Issue