Add kapacitors endpoint (persist/proxy/rest)
parent
f5b4eed565
commit
ab6d177dc6
handlers
kapacitor
restapi
operations
|
@ -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,29 @@ 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),
|
||||
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.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,45 @@ 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"`
|
||||
}
|
||||
|
||||
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,
|
||||
// 284 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x6a, 0xeb, 0x30,
|
||||
0x14, 0x45, 0x51, 0xa4, 0xaf, 0xd8, 0xef, 0x43, 0x28, 0x1a, 0x14, 0x51, 0x3a, 0x30, 0x19, 0x65,
|
||||
0xd4, 0x49, 0x57, 0x50, 0xea, 0x0e, 0x02, 0xa6, 0x14, 0xa5, 0x5e, 0x80, 0x1a, 0xbf, 0x82, 0xc1,
|
||||
0xb1, 0x84, 0x2c, 0xa5, 0xcd, 0x86, 0xba, 0x81, 0x6e, 0xb0, 0x48, 0xb6, 0xa1, 0x74, 0x10, 0x32,
|
||||
0xbc, 0xef, 0x5c, 0x2e, 0x47, 0x08, 0x56, 0x6d, 0xef, 0xd1, 0xf5, 0xba, 0xbb, 0xb3, 0xce, 0x78,
|
||||
0x23, 0xb2, 0x39, 0xaf, 0xbf, 0x09, 0xfc, 0x7f, 0xfa, 0xb4, 0x9d, 0x71, 0xda, 0xb7, 0xa6, 0x17,
|
||||
0x2b, 0x58, 0x6c, 0x4b, 0x49, 0x0a, 0xb2, 0xa1, 0x6a, 0xd1, 0x96, 0x42, 0x00, 0x7b, 0xd6, 0x07,
|
||||
0x94, 0x8b, 0x82, 0x6c, 0x72, 0xc5, 0x7a, 0x7d, 0x40, 0x71, 0x0d, 0xbc, 0x1e, 0xd0, 0x6d, 0x4b,
|
||||
0x49, 0x53, 0x8f, 0x87, 0x94, 0x62, 0xb7, 0xd4, 0x5e, 0x4b, 0x36, 0x76, 0x1b, 0xed, 0xb5, 0xb8,
|
||||
0x85, 0xfc, 0xd1, 0xa1, 0xf6, 0xd8, 0x3c, 0x78, 0xf9, 0x2f, 0xd5, 0xf3, 0xfd, 0x7c, 0x88, 0xb4,
|
||||
0xb6, 0xcd, 0x44, 0xf9, 0x48, 0xc3, 0x7c, 0x10, 0x12, 0x96, 0x25, 0xbe, 0xeb, 0xd0, 0x79, 0xb9,
|
||||
0x2c, 0xc8, 0x26, 0x53, 0xcb, 0x66, 0x8c, 0xeb, 0x2f, 0x02, 0x7c, 0x67, 0x82, 0xdb, 0xe3, 0x45,
|
||||
0xc2, 0x02, 0xd8, 0xeb, 0xc9, 0x62, 0xd2, 0xcd, 0x15, 0xf3, 0x27, 0x8b, 0xe2, 0x06, 0xb2, 0xf8,
|
||||
0x88, 0xc8, 0x27, 0xe1, 0x2c, 0x4c, 0x39, 0xb2, 0x17, 0x3d, 0x0c, 0x1f, 0xc6, 0x35, 0xc9, 0x39,
|
||||
0x57, 0x99, 0x9d, 0x72, 0xdc, 0xaa, 0x55, 0x35, 0x48, 0x5e, 0xd0, 0xb8, 0x15, 0x54, 0x35, 0x9c,
|
||||
0x11, 0x3d, 0x02, 0xdf, 0xa1, 0x3b, 0xa2, 0xbb, 0xc8, 0xf3, 0xb7, 0x13, 0x3d, 0xe3, 0xc4, 0xfe,
|
||||
0x38, 0x5d, 0x01, 0xad, 0x55, 0x35, 0xa9, 0xd2, 0xa0, 0xaa, 0x37, 0x9e, 0xfe, 0xf9, 0xfe, 0x27,
|
||||
0x00, 0x00, 0xff, 0xff, 0xfa, 0x07, 0x21, 0x1c, 0xf9, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -20,3 +20,11 @@ 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
|
||||
}
|
||||
|
|
|
@ -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,88 @@
|
|||
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",
|
||||
Username: "marty",
|
||||
Password: "I❤️ jennifer parker",
|
||||
URL: "toyota-hilux.lyon-estates.local",
|
||||
},
|
||||
mrfusion.Server{
|
||||
Name: "HipToBeSquare",
|
||||
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,129 @@
|
|||
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.PostKapacitorsParams) middleware.Responder {
|
||||
srv := mrfusion.Server{
|
||||
Name: *params.Kapacitor.Name,
|
||||
Username: params.Kapacitor.Username,
|
||||
Password: params.Kapacitor.Password,
|
||||
URL: *params.Kapacitor.URL,
|
||||
}
|
||||
var err error
|
||||
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.NewPostKapacitorsDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
mSrv := srvToModel(srv)
|
||||
return op.NewPostKapacitorsCreated().WithPayload(mSrv).WithLocation(mSrv.Links.Self)
|
||||
}
|
||||
|
||||
func srvLinks(id int) *models.KapacitorLinks {
|
||||
return &models.KapacitorLinks{
|
||||
Self: fmt.Sprintf("/chronograf/v1/kapacitors/%d", id),
|
||||
Proxy: fmt.Sprintf("/chronograf/v1/kapacitors/%d/proxy", id),
|
||||
}
|
||||
}
|
||||
|
||||
func srvToModel(srv mrfusion.Server) *models.Kapacitor {
|
||||
return &models.Kapacitor{
|
||||
ID: strconv.Itoa(srv.ID),
|
||||
Links: srvLinks(srv.ID),
|
||||
Name: &srv.Name,
|
||||
Username: srv.Username,
|
||||
Password: srv.Password,
|
||||
URL: &srv.URL,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Store) Kapacitors(ctx context.Context, params op.GetKapacitorsParams) middleware.Responder {
|
||||
mrSrvs, err := h.ServersStore.All(ctx)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: "Error loading kapacitors"}
|
||||
return op.NewGetKapacitorsDefault(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.NewGetKapacitorsOK().WithPayload(res)
|
||||
}
|
||||
|
||||
func (h *Store) KapacitorsID(ctx context.Context, params op.GetKapacitorsIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewGetKapacitorsIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.ID)}
|
||||
return op.NewGetKapacitorsIDNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewGetKapacitorsIDOK().WithPayload(srvToModel(srv))
|
||||
}
|
||||
|
||||
func (h *Store) RemoveKapacitor(ctx context.Context, params op.DeleteKapacitorsIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewDeleteKapacitorsIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
srv := mrfusion.Server{
|
||||
ID: id,
|
||||
}
|
||||
if err = h.ServersStore.Delete(ctx, srv); err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Unknown error deleting kapacitor %s", params.ID)}
|
||||
return op.NewDeleteKapacitorsIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
return op.NewDeleteKapacitorsIDNoContent()
|
||||
}
|
||||
|
||||
func (h *Store) UpdateKapacitor(ctx context.Context, params op.PatchKapacitorsIDParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPatchKapacitorsIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.ID)}
|
||||
return op.NewPatchKapacitorsIDNotFound().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.ID)}
|
||||
return op.NewPatchKapacitorsIDDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
return op.NewPatchKapacitorsIDNoContent()
|
||||
}
|
|
@ -2,6 +2,7 @@ package handlers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
@ -13,8 +14,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 +68,44 @@ func (h *InfluxProxy) Proxy(ctx context.Context, params op.PostSourcesIDProxyPar
|
|||
}
|
||||
return op.NewPostSourcesIDProxyOK().WithPayload(res)
|
||||
}
|
||||
|
||||
func (h *InfluxProxy) ProxyPost(ctx context.Context, params op.PostKapacitorsIDProxyParams) middleware.Responder {
|
||||
id, err := strconv.Atoi(params.ID)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error converting ID %s", params.ID)}
|
||||
return op.NewPostKapacitorsIDProxyDefault(500).WithPayload(errMsg)
|
||||
}
|
||||
|
||||
srv, err := h.ServersStore.Get(ctx, id)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 404, Message: fmt.Sprintf("Unknown ID %s", params.ID)}
|
||||
return op.NewPostKapacitorsIDProxyNotFound().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.ID)}
|
||||
return op.NewPostKapacitorsIDProxyNotFound().WithPayload(errMsg)
|
||||
}
|
||||
|
||||
req := &mrfusion.Request{
|
||||
Method: "POST",
|
||||
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.NewPostKapacitorsIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
errMsg := &models.Error{Code: 500, Message: fmt.Sprintf("Error reading body of response: %v", err)}
|
||||
return op.NewPostKapacitorsIDProxyDefault(500).WithPayload(errMsg)
|
||||
|
||||
}
|
||||
|
||||
return op.NewPostKapacitorsIDProxyDefault(resp.StatusCode).WithPayload(content)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package mrfusion
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
|
@ -115,6 +115,13 @@ func configureAPI(api *op.MrFusionAPI) http.Handler {
|
|||
TimeSeries: &ts,
|
||||
}
|
||||
api.PostSourcesIDProxyHandler = op.PostSourcesIDProxyHandlerFunc(p.Proxy)
|
||||
|
||||
api.DeleteKapacitorsIDHandler = op.DeleteKapacitorsIDHandlerFunc(h.RemoveKapacitor)
|
||||
api.PatchKapacitorsIDHandler = op.PatchKapacitorsIDHandlerFunc(h.UpdateKapacitor)
|
||||
|
||||
api.GetKapacitorsHandler = op.GetKapacitorsHandlerFunc(h.Kapacitors)
|
||||
api.GetKapacitorsIDHandler = op.GetKapacitorsIDHandlerFunc(h.KapacitorsID)
|
||||
api.PostKapacitorsHandler = op.PostKapacitorsHandlerFunc(h.NewKapacitor)
|
||||
} else {
|
||||
api.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.DeleteSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(mockHandler.DeleteExploration)
|
||||
api.GetSourcesIDUsersUserIDExplorationsExplorationIDHandler = op.GetSourcesIDUsersUserIDExplorationsExplorationIDHandlerFunc(mockHandler.Exploration)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
// DeleteKapacitorsIDHandlerFunc turns a function with the right signature into a delete kapacitors ID handler
|
||||
type DeleteKapacitorsIDHandlerFunc func(context.Context, DeleteKapacitorsIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteKapacitorsIDHandlerFunc) Handle(ctx context.Context, params DeleteKapacitorsIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// DeleteKapacitorsIDHandler interface for that can handle valid delete kapacitors ID params
|
||||
type DeleteKapacitorsIDHandler interface {
|
||||
Handle(context.Context, DeleteKapacitorsIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsID creates a new http.Handler for the delete kapacitors ID operation
|
||||
func NewDeleteKapacitorsID(ctx *middleware.Context, handler DeleteKapacitorsIDHandler) *DeleteKapacitorsID {
|
||||
return &DeleteKapacitorsID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*DeleteKapacitorsID swagger:route DELETE /kapacitors/{id} deleteKapacitorsId
|
||||
|
||||
This specific kapacitor will be removed.
|
||||
|
||||
*/
|
||||
type DeleteKapacitorsID struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteKapacitorsIDHandler
|
||||
}
|
||||
|
||||
func (o *DeleteKapacitorsID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewDeleteKapacitorsIDParams()
|
||||
|
||||
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,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"
|
||||
)
|
||||
|
||||
// NewDeleteKapacitorsIDParams creates a new DeleteKapacitorsIDParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteKapacitorsIDParams() DeleteKapacitorsIDParams {
|
||||
var ()
|
||||
return DeleteKapacitorsIDParams{}
|
||||
}
|
||||
|
||||
// DeleteKapacitorsIDParams contains all the bound params for the delete kapacitors ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteKapacitorsID
|
||||
type DeleteKapacitorsIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor
|
||||
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 *DeleteKapacitorsIDParams) 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 *DeleteKapacitorsIDParams) 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,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"
|
||||
)
|
||||
|
||||
// DeleteKapacitorsIDProxyHandlerFunc turns a function with the right signature into a delete kapacitors ID proxy handler
|
||||
type DeleteKapacitorsIDProxyHandlerFunc func(context.Context, DeleteKapacitorsIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteKapacitorsIDProxyHandlerFunc) Handle(ctx context.Context, params DeleteKapacitorsIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// DeleteKapacitorsIDProxyHandler interface for that can handle valid delete kapacitors ID proxy params
|
||||
type DeleteKapacitorsIDProxyHandler interface {
|
||||
Handle(context.Context, DeleteKapacitorsIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDProxy creates a new http.Handler for the delete kapacitors ID proxy operation
|
||||
func NewDeleteKapacitorsIDProxy(ctx *middleware.Context, handler DeleteKapacitorsIDProxyHandler) *DeleteKapacitorsIDProxy {
|
||||
return &DeleteKapacitorsIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*DeleteKapacitorsIDProxy swagger:route DELETE /kapacitors/{id}/proxy deleteKapacitorsIdProxy
|
||||
|
||||
DELETE to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type DeleteKapacitorsIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteKapacitorsIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *DeleteKapacitorsIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewDeleteKapacitorsIDProxyParams()
|
||||
|
||||
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,95 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewDeleteKapacitorsIDProxyParams creates a new DeleteKapacitorsIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteKapacitorsIDProxyParams() DeleteKapacitorsIDProxyParams {
|
||||
var ()
|
||||
return DeleteKapacitorsIDProxyParams{}
|
||||
}
|
||||
|
||||
// DeleteKapacitorsIDProxyParams contains all the bound params for the delete kapacitors ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteKapacitorsIDProxy
|
||||
type DeleteKapacitorsIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *DeleteKapacitorsIDProxyParams) 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)
|
||||
}
|
||||
|
||||
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 *DeleteKapacitorsIDProxyParams) 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 *DeleteKapacitorsIDProxyParams) 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,103 @@
|
|||
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"
|
||||
)
|
||||
|
||||
/*DeleteKapacitorsIDProxyNotFound Kapacitor ID does not exist.
|
||||
|
||||
swagger:response deleteKapacitorsIdProxyNotFound
|
||||
*/
|
||||
type DeleteKapacitorsIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDProxyNotFound creates DeleteKapacitorsIDProxyNotFound with default headers values
|
||||
func NewDeleteKapacitorsIDProxyNotFound() *DeleteKapacitorsIDProxyNotFound {
|
||||
return &DeleteKapacitorsIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete kapacitors Id proxy not found response
|
||||
func (o *DeleteKapacitorsIDProxyNotFound) WithPayload(payload *models.Error) *DeleteKapacitorsIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete kapacitors Id proxy not found response
|
||||
func (o *DeleteKapacitorsIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteKapacitorsIDProxyNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteKapacitorsIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response deleteKapacitorsIdProxyDefault
|
||||
*/
|
||||
type DeleteKapacitorsIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDProxyDefault creates DeleteKapacitorsIDProxyDefault with default headers values
|
||||
func NewDeleteKapacitorsIDProxyDefault(code int) *DeleteKapacitorsIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteKapacitorsIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete kapacitors ID proxy default response
|
||||
func (o *DeleteKapacitorsIDProxyDefault) WithStatusCode(code int) *DeleteKapacitorsIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete kapacitors ID proxy default response
|
||||
func (o *DeleteKapacitorsIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete kapacitors ID proxy default response
|
||||
func (o *DeleteKapacitorsIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *DeleteKapacitorsIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete kapacitors ID proxy default response
|
||||
func (o *DeleteKapacitorsIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteKapacitorsIDProxyDefault) 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"
|
||||
)
|
||||
|
||||
/*DeleteKapacitorsIDNoContent kapacitor has been removed.
|
||||
|
||||
swagger:response deleteKapacitorsIdNoContent
|
||||
*/
|
||||
type DeleteKapacitorsIDNoContent struct {
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDNoContent creates DeleteKapacitorsIDNoContent with default headers values
|
||||
func NewDeleteKapacitorsIDNoContent() *DeleteKapacitorsIDNoContent {
|
||||
return &DeleteKapacitorsIDNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteKapacitorsIDNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*DeleteKapacitorsIDNotFound Unknown Kapacitor id
|
||||
|
||||
swagger:response deleteKapacitorsIdNotFound
|
||||
*/
|
||||
type DeleteKapacitorsIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDNotFound creates DeleteKapacitorsIDNotFound with default headers values
|
||||
func NewDeleteKapacitorsIDNotFound() *DeleteKapacitorsIDNotFound {
|
||||
return &DeleteKapacitorsIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete kapacitors Id not found response
|
||||
func (o *DeleteKapacitorsIDNotFound) WithPayload(payload *models.Error) *DeleteKapacitorsIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete kapacitors Id not found response
|
||||
func (o *DeleteKapacitorsIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteKapacitorsIDNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteKapacitorsIDDefault Unexpected internal service error
|
||||
|
||||
swagger:response deleteKapacitorsIdDefault
|
||||
*/
|
||||
type DeleteKapacitorsIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteKapacitorsIDDefault creates DeleteKapacitorsIDDefault with default headers values
|
||||
func NewDeleteKapacitorsIDDefault(code int) *DeleteKapacitorsIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteKapacitorsIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete kapacitors ID default response
|
||||
func (o *DeleteKapacitorsIDDefault) WithStatusCode(code int) *DeleteKapacitorsIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete kapacitors ID default response
|
||||
func (o *DeleteKapacitorsIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete kapacitors ID default response
|
||||
func (o *DeleteKapacitorsIDDefault) WithPayload(payload *models.Error) *DeleteKapacitorsIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete kapacitors ID default response
|
||||
func (o *DeleteKapacitorsIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteKapacitorsIDDefault) 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"
|
||||
)
|
||||
|
||||
// GetKapacitorsHandlerFunc turns a function with the right signature into a get kapacitors handler
|
||||
type GetKapacitorsHandlerFunc func(context.Context, GetKapacitorsParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetKapacitorsHandlerFunc) Handle(ctx context.Context, params GetKapacitorsParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetKapacitorsHandler interface for that can handle valid get kapacitors params
|
||||
type GetKapacitorsHandler interface {
|
||||
Handle(context.Context, GetKapacitorsParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetKapacitors creates a new http.Handler for the get kapacitors operation
|
||||
func NewGetKapacitors(ctx *middleware.Context, handler GetKapacitorsHandler) *GetKapacitors {
|
||||
return &GetKapacitors{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetKapacitors swagger:route GET /kapacitors getKapacitors
|
||||
|
||||
Configured kapacitors
|
||||
|
||||
*/
|
||||
type GetKapacitors struct {
|
||||
Context *middleware.Context
|
||||
Handler GetKapacitorsHandler
|
||||
}
|
||||
|
||||
func (o *GetKapacitors) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetKapacitorsParams()
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// GetKapacitorsIDHandlerFunc turns a function with the right signature into a get kapacitors ID handler
|
||||
type GetKapacitorsIDHandlerFunc func(context.Context, GetKapacitorsIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetKapacitorsIDHandlerFunc) Handle(ctx context.Context, params GetKapacitorsIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetKapacitorsIDHandler interface for that can handle valid get kapacitors ID params
|
||||
type GetKapacitorsIDHandler interface {
|
||||
Handle(context.Context, GetKapacitorsIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetKapacitorsID creates a new http.Handler for the get kapacitors ID operation
|
||||
func NewGetKapacitorsID(ctx *middleware.Context, handler GetKapacitorsIDHandler) *GetKapacitorsID {
|
||||
return &GetKapacitorsID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetKapacitorsID swagger:route GET /kapacitors/{id} getKapacitorsId
|
||||
|
||||
Configured kapacitors
|
||||
|
||||
These kapacitors are used for monitoring and alerting.
|
||||
|
||||
*/
|
||||
type GetKapacitorsID struct {
|
||||
Context *middleware.Context
|
||||
Handler GetKapacitorsIDHandler
|
||||
}
|
||||
|
||||
func (o *GetKapacitorsID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetKapacitorsIDParams()
|
||||
|
||||
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,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"
|
||||
)
|
||||
|
||||
// NewGetKapacitorsIDParams creates a new GetKapacitorsIDParams object
|
||||
// with the default values initialized.
|
||||
func NewGetKapacitorsIDParams() GetKapacitorsIDParams {
|
||||
var ()
|
||||
return GetKapacitorsIDParams{}
|
||||
}
|
||||
|
||||
// GetKapacitorsIDParams contains all the bound params for the get kapacitors ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetKapacitorsID
|
||||
type GetKapacitorsIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor
|
||||
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 *GetKapacitorsIDParams) 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 *GetKapacitorsIDParams) 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,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"
|
||||
)
|
||||
|
||||
// GetKapacitorsIDProxyHandlerFunc turns a function with the right signature into a get kapacitors ID proxy handler
|
||||
type GetKapacitorsIDProxyHandlerFunc func(context.Context, GetKapacitorsIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetKapacitorsIDProxyHandlerFunc) Handle(ctx context.Context, params GetKapacitorsIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// GetKapacitorsIDProxyHandler interface for that can handle valid get kapacitors ID proxy params
|
||||
type GetKapacitorsIDProxyHandler interface {
|
||||
Handle(context.Context, GetKapacitorsIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDProxy creates a new http.Handler for the get kapacitors ID proxy operation
|
||||
func NewGetKapacitorsIDProxy(ctx *middleware.Context, handler GetKapacitorsIDProxyHandler) *GetKapacitorsIDProxy {
|
||||
return &GetKapacitorsIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*GetKapacitorsIDProxy swagger:route GET /kapacitors/{id}/proxy getKapacitorsIdProxy
|
||||
|
||||
GET to `path` of kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type GetKapacitorsIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler GetKapacitorsIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *GetKapacitorsIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewGetKapacitorsIDProxyParams()
|
||||
|
||||
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,95 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewGetKapacitorsIDProxyParams creates a new GetKapacitorsIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewGetKapacitorsIDProxyParams() GetKapacitorsIDProxyParams {
|
||||
var ()
|
||||
return GetKapacitorsIDProxyParams{}
|
||||
}
|
||||
|
||||
// GetKapacitorsIDProxyParams contains all the bound params for the get kapacitors ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetKapacitorsIDProxy
|
||||
type GetKapacitorsIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *GetKapacitorsIDProxyParams) 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)
|
||||
}
|
||||
|
||||
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 *GetKapacitorsIDProxyParams) 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 *GetKapacitorsIDProxyParams) 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,103 @@
|
|||
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"
|
||||
)
|
||||
|
||||
/*GetKapacitorsIDProxyNotFound Kapacitor ID does not exist.
|
||||
|
||||
swagger:response getKapacitorsIdProxyNotFound
|
||||
*/
|
||||
type GetKapacitorsIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDProxyNotFound creates GetKapacitorsIDProxyNotFound with default headers values
|
||||
func NewGetKapacitorsIDProxyNotFound() *GetKapacitorsIDProxyNotFound {
|
||||
return &GetKapacitorsIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors Id proxy not found response
|
||||
func (o *GetKapacitorsIDProxyNotFound) WithPayload(payload *models.Error) *GetKapacitorsIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors Id proxy not found response
|
||||
func (o *GetKapacitorsIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsIDProxyNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetKapacitorsIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response getKapacitorsIdProxyDefault
|
||||
*/
|
||||
type GetKapacitorsIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDProxyDefault creates GetKapacitorsIDProxyDefault with default headers values
|
||||
func NewGetKapacitorsIDProxyDefault(code int) *GetKapacitorsIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetKapacitorsIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get kapacitors ID proxy default response
|
||||
func (o *GetKapacitorsIDProxyDefault) WithStatusCode(code int) *GetKapacitorsIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get kapacitors ID proxy default response
|
||||
func (o *GetKapacitorsIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors ID proxy default response
|
||||
func (o *GetKapacitorsIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *GetKapacitorsIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors ID proxy default response
|
||||
func (o *GetKapacitorsIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsIDProxyDefault) 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"
|
||||
)
|
||||
|
||||
/*GetKapacitorsIDOK Kapacitor connection information
|
||||
|
||||
swagger:response getKapacitorsIdOK
|
||||
*/
|
||||
type GetKapacitorsIDOK struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitor `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDOK creates GetKapacitorsIDOK with default headers values
|
||||
func NewGetKapacitorsIDOK() *GetKapacitorsIDOK {
|
||||
return &GetKapacitorsIDOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors Id o k response
|
||||
func (o *GetKapacitorsIDOK) WithPayload(payload *models.Kapacitor) *GetKapacitorsIDOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors Id o k response
|
||||
func (o *GetKapacitorsIDOK) SetPayload(payload *models.Kapacitor) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsIDOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetKapacitorsIDNotFound Unknown kapacitor id
|
||||
|
||||
swagger:response getKapacitorsIdNotFound
|
||||
*/
|
||||
type GetKapacitorsIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDNotFound creates GetKapacitorsIDNotFound with default headers values
|
||||
func NewGetKapacitorsIDNotFound() *GetKapacitorsIDNotFound {
|
||||
return &GetKapacitorsIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors Id not found response
|
||||
func (o *GetKapacitorsIDNotFound) WithPayload(payload *models.Error) *GetKapacitorsIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors Id not found response
|
||||
func (o *GetKapacitorsIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsIDNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetKapacitorsIDDefault Unexpected internal service error
|
||||
|
||||
swagger:response getKapacitorsIdDefault
|
||||
*/
|
||||
type GetKapacitorsIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsIDDefault creates GetKapacitorsIDDefault with default headers values
|
||||
func NewGetKapacitorsIDDefault(code int) *GetKapacitorsIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetKapacitorsIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get kapacitors ID default response
|
||||
func (o *GetKapacitorsIDDefault) WithStatusCode(code int) *GetKapacitorsIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get kapacitors ID default response
|
||||
func (o *GetKapacitorsIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors ID default response
|
||||
func (o *GetKapacitorsIDDefault) WithPayload(payload *models.Error) *GetKapacitorsIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors ID default response
|
||||
func (o *GetKapacitorsIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsIDDefault) 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,40 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewGetKapacitorsParams creates a new GetKapacitorsParams object
|
||||
// with the default values initialized.
|
||||
func NewGetKapacitorsParams() GetKapacitorsParams {
|
||||
var ()
|
||||
return GetKapacitorsParams{}
|
||||
}
|
||||
|
||||
// GetKapacitorsParams contains all the bound params for the get kapacitors operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetKapacitors
|
||||
type GetKapacitorsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
}
|
||||
|
||||
// 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 *GetKapacitorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
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"
|
||||
)
|
||||
|
||||
/*GetKapacitorsOK An array of kapacitors
|
||||
|
||||
swagger:response getKapacitorsOK
|
||||
*/
|
||||
type GetKapacitorsOK struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitors `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsOK creates GetKapacitorsOK with default headers values
|
||||
func NewGetKapacitorsOK() *GetKapacitorsOK {
|
||||
return &GetKapacitorsOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors o k response
|
||||
func (o *GetKapacitorsOK) WithPayload(payload *models.Kapacitors) *GetKapacitorsOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors o k response
|
||||
func (o *GetKapacitorsOK) SetPayload(payload *models.Kapacitors) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*GetKapacitorsDefault Unexpected internal service error
|
||||
|
||||
swagger:response getKapacitorsDefault
|
||||
*/
|
||||
type GetKapacitorsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetKapacitorsDefault creates GetKapacitorsDefault with default headers values
|
||||
func NewGetKapacitorsDefault(code int) *GetKapacitorsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetKapacitorsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get kapacitors default response
|
||||
func (o *GetKapacitorsDefault) WithStatusCode(code int) *GetKapacitorsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get kapacitors default response
|
||||
func (o *GetKapacitorsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get kapacitors default response
|
||||
func (o *GetKapacitorsDefault) WithPayload(payload *models.Error) *GetKapacitorsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get kapacitors default response
|
||||
func (o *GetKapacitorsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetKapacitorsDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,6 +44,10 @@ type MrFusionAPI struct {
|
|||
|
||||
// DeleteDashboardsIDHandler sets the operation handler for the delete dashboards ID operation
|
||||
DeleteDashboardsIDHandler DeleteDashboardsIDHandler
|
||||
// DeleteKapacitorsIDHandler sets the operation handler for the delete kapacitors ID operation
|
||||
DeleteKapacitorsIDHandler DeleteKapacitorsIDHandler
|
||||
// DeleteKapacitorsIDProxyHandler sets the operation handler for the delete kapacitors ID proxy operation
|
||||
DeleteKapacitorsIDProxyHandler DeleteKapacitorsIDProxyHandler
|
||||
// DeleteSourcesIDHandler sets the operation handler for the delete sources ID operation
|
||||
DeleteSourcesIDHandler DeleteSourcesIDHandler
|
||||
// DeleteSourcesIDRolesRoleIDHandler sets the operation handler for the delete sources ID roles role ID operation
|
||||
|
@ -58,6 +62,12 @@ type MrFusionAPI struct {
|
|||
GetDashboardsHandler GetDashboardsHandler
|
||||
// GetDashboardsIDHandler sets the operation handler for the get dashboards ID operation
|
||||
GetDashboardsIDHandler GetDashboardsIDHandler
|
||||
// GetKapacitorsHandler sets the operation handler for the get kapacitors operation
|
||||
GetKapacitorsHandler GetKapacitorsHandler
|
||||
// GetKapacitorsIDHandler sets the operation handler for the get kapacitors ID operation
|
||||
GetKapacitorsIDHandler GetKapacitorsIDHandler
|
||||
// GetKapacitorsIDProxyHandler sets the operation handler for the get kapacitors ID proxy operation
|
||||
GetKapacitorsIDProxyHandler GetKapacitorsIDProxyHandler
|
||||
// GetSourcesHandler sets the operation handler for the get sources operation
|
||||
GetSourcesHandler GetSourcesHandler
|
||||
// GetSourcesIDHandler sets the operation handler for the get sources ID operation
|
||||
|
@ -78,6 +88,10 @@ type MrFusionAPI struct {
|
|||
GetSourcesIDUsersUserIDExplorationsHandler GetSourcesIDUsersUserIDExplorationsHandler
|
||||
// GetSourcesIDUsersUserIDExplorationsExplorationIDHandler sets the operation handler for the get sources ID users user ID explorations exploration ID operation
|
||||
GetSourcesIDUsersUserIDExplorationsExplorationIDHandler GetSourcesIDUsersUserIDExplorationsExplorationIDHandler
|
||||
// PatchKapacitorsIDHandler sets the operation handler for the patch kapacitors ID operation
|
||||
PatchKapacitorsIDHandler PatchKapacitorsIDHandler
|
||||
// PatchKapacitorsIDProxyHandler sets the operation handler for the patch kapacitors ID proxy operation
|
||||
PatchKapacitorsIDProxyHandler PatchKapacitorsIDProxyHandler
|
||||
// PatchSourcesIDHandler sets the operation handler for the patch sources ID operation
|
||||
PatchSourcesIDHandler PatchSourcesIDHandler
|
||||
// PatchSourcesIDRolesRoleIDHandler sets the operation handler for the patch sources ID roles role ID operation
|
||||
|
@ -88,6 +102,10 @@ type MrFusionAPI struct {
|
|||
PatchSourcesIDUsersUserIDExplorationsExplorationIDHandler PatchSourcesIDUsersUserIDExplorationsExplorationIDHandler
|
||||
// PostDashboardsHandler sets the operation handler for the post dashboards operation
|
||||
PostDashboardsHandler PostDashboardsHandler
|
||||
// PostKapacitorsHandler sets the operation handler for the post kapacitors operation
|
||||
PostKapacitorsHandler PostKapacitorsHandler
|
||||
// PostKapacitorsIDProxyHandler sets the operation handler for the post kapacitors ID proxy operation
|
||||
PostKapacitorsIDProxyHandler PostKapacitorsIDProxyHandler
|
||||
// PostSourcesHandler sets the operation handler for the post sources operation
|
||||
PostSourcesHandler PostSourcesHandler
|
||||
// PostSourcesIDProxyHandler sets the operation handler for the post sources ID proxy operation
|
||||
|
@ -167,6 +185,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "DeleteDashboardsIDHandler")
|
||||
}
|
||||
|
||||
if o.DeleteKapacitorsIDHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteKapacitorsIDHandler")
|
||||
}
|
||||
|
||||
if o.DeleteKapacitorsIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteKapacitorsIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.DeleteSourcesIDHandler == nil {
|
||||
unregistered = append(unregistered, "DeleteSourcesIDHandler")
|
||||
}
|
||||
|
@ -195,6 +221,18 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "GetDashboardsIDHandler")
|
||||
}
|
||||
|
||||
if o.GetKapacitorsHandler == nil {
|
||||
unregistered = append(unregistered, "GetKapacitorsHandler")
|
||||
}
|
||||
|
||||
if o.GetKapacitorsIDHandler == nil {
|
||||
unregistered = append(unregistered, "GetKapacitorsIDHandler")
|
||||
}
|
||||
|
||||
if o.GetKapacitorsIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "GetKapacitorsIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.GetSourcesHandler == nil {
|
||||
unregistered = append(unregistered, "GetSourcesHandler")
|
||||
}
|
||||
|
@ -235,6 +273,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "GetSourcesIDUsersUserIDExplorationsExplorationIDHandler")
|
||||
}
|
||||
|
||||
if o.PatchKapacitorsIDHandler == nil {
|
||||
unregistered = append(unregistered, "PatchKapacitorsIDHandler")
|
||||
}
|
||||
|
||||
if o.PatchKapacitorsIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "PatchKapacitorsIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.PatchSourcesIDHandler == nil {
|
||||
unregistered = append(unregistered, "PatchSourcesIDHandler")
|
||||
}
|
||||
|
@ -255,6 +301,14 @@ func (o *MrFusionAPI) Validate() error {
|
|||
unregistered = append(unregistered, "PostDashboardsHandler")
|
||||
}
|
||||
|
||||
if o.PostKapacitorsHandler == nil {
|
||||
unregistered = append(unregistered, "PostKapacitorsHandler")
|
||||
}
|
||||
|
||||
if o.PostKapacitorsIDProxyHandler == nil {
|
||||
unregistered = append(unregistered, "PostKapacitorsIDProxyHandler")
|
||||
}
|
||||
|
||||
if o.PostSourcesHandler == nil {
|
||||
unregistered = append(unregistered, "PostSourcesHandler")
|
||||
}
|
||||
|
@ -365,6 +419,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["DELETE"]["/dashboards/{id}"] = NewDeleteDashboardsID(o.context, o.DeleteDashboardsIDHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/kapacitors/{id}"] = NewDeleteKapacitorsID(o.context, o.DeleteKapacitorsIDHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/kapacitors/{id}/proxy"] = NewDeleteKapacitorsIDProxy(o.context, o.DeleteKapacitorsIDProxyHandler)
|
||||
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -400,6 +464,21 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["GET"]["/dashboards/{id}"] = NewGetDashboardsID(o.context, o.GetDashboardsIDHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/kapacitors"] = NewGetKapacitors(o.context, o.GetKapacitorsHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/kapacitors/{id}"] = NewGetKapacitorsID(o.context, o.GetKapacitorsIDHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/kapacitors/{id}/proxy"] = NewGetKapacitorsIDProxy(o.context, o.GetKapacitorsIDProxyHandler)
|
||||
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -450,6 +529,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["GET"]["/sources/{id}/users/{user_id}/explorations/{exploration_id}"] = NewGetSourcesIDUsersUserIDExplorationsExplorationID(o.context, o.GetSourcesIDUsersUserIDExplorationsExplorationIDHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/kapacitors/{id}"] = NewPatchKapacitorsID(o.context, o.PatchKapacitorsIDHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/kapacitors/{id}/proxy"] = NewPatchKapacitorsIDProxy(o.context, o.PatchKapacitorsIDProxyHandler)
|
||||
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers[strings.ToUpper("PATCH")] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -475,6 +564,16 @@ func (o *MrFusionAPI) initHandlerCache() {
|
|||
}
|
||||
o.handlers["POST"]["/dashboards"] = NewPostDashboards(o.context, o.PostDashboardsHandler)
|
||||
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/kapacitors"] = NewPostKapacitors(o.context, o.PostKapacitorsHandler)
|
||||
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/kapacitors/{id}/proxy"] = NewPostKapacitorsIDProxy(o.context, o.PostKapacitorsIDProxyHandler)
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// PatchKapacitorsIDHandlerFunc turns a function with the right signature into a patch kapacitors ID handler
|
||||
type PatchKapacitorsIDHandlerFunc func(context.Context, PatchKapacitorsIDParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PatchKapacitorsIDHandlerFunc) Handle(ctx context.Context, params PatchKapacitorsIDParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PatchKapacitorsIDHandler interface for that can handle valid patch kapacitors ID params
|
||||
type PatchKapacitorsIDHandler interface {
|
||||
Handle(context.Context, PatchKapacitorsIDParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsID creates a new http.Handler for the patch kapacitors ID operation
|
||||
func NewPatchKapacitorsID(ctx *middleware.Context, handler PatchKapacitorsIDHandler) *PatchKapacitorsID {
|
||||
return &PatchKapacitorsID{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PatchKapacitorsID swagger:route PATCH /kapacitors/{id} patchKapacitorsId
|
||||
|
||||
Update kapacitor configuration
|
||||
|
||||
*/
|
||||
type PatchKapacitorsID struct {
|
||||
Context *middleware.Context
|
||||
Handler PatchKapacitorsIDHandler
|
||||
}
|
||||
|
||||
func (o *PatchKapacitorsID) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPatchKapacitorsIDParams()
|
||||
|
||||
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,97 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewPatchKapacitorsIDParams creates a new PatchKapacitorsIDParams object
|
||||
// with the default values initialized.
|
||||
func NewPatchKapacitorsIDParams() PatchKapacitorsIDParams {
|
||||
var ()
|
||||
return PatchKapacitorsIDParams{}
|
||||
}
|
||||
|
||||
// PatchKapacitorsIDParams contains all the bound params for the patch kapacitors ID operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PatchKapacitorsID
|
||||
type PatchKapacitorsIDParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*kapacitor configuration
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Config *models.Kapacitor
|
||||
/*ID of a kapacitor backend
|
||||
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 *PatchKapacitorsIDParams) 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)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *PatchKapacitorsIDParams) 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,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"
|
||||
)
|
||||
|
||||
// PatchKapacitorsIDProxyHandlerFunc turns a function with the right signature into a patch kapacitors ID proxy handler
|
||||
type PatchKapacitorsIDProxyHandlerFunc func(context.Context, PatchKapacitorsIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PatchKapacitorsIDProxyHandlerFunc) Handle(ctx context.Context, params PatchKapacitorsIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PatchKapacitorsIDProxyHandler interface for that can handle valid patch kapacitors ID proxy params
|
||||
type PatchKapacitorsIDProxyHandler interface {
|
||||
Handle(context.Context, PatchKapacitorsIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDProxy creates a new http.Handler for the patch kapacitors ID proxy operation
|
||||
func NewPatchKapacitorsIDProxy(ctx *middleware.Context, handler PatchKapacitorsIDProxyHandler) *PatchKapacitorsIDProxy {
|
||||
return &PatchKapacitorsIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PatchKapacitorsIDProxy swagger:route PATCH /kapacitors/{id}/proxy patchKapacitorsIdProxy
|
||||
|
||||
PATCH body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type PatchKapacitorsIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler PatchKapacitorsIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *PatchKapacitorsIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPatchKapacitorsIDProxyParams()
|
||||
|
||||
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,124 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewPatchKapacitorsIDProxyParams creates a new PatchKapacitorsIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewPatchKapacitorsIDProxyParams() PatchKapacitorsIDProxyParams {
|
||||
var ()
|
||||
return PatchKapacitorsIDProxyParams{}
|
||||
}
|
||||
|
||||
// PatchKapacitorsIDProxyParams contains all the bound params for the patch kapacitors ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PatchKapacitorsIDProxy
|
||||
type PatchKapacitorsIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *PatchKapacitorsIDProxyParams) 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)
|
||||
}
|
||||
|
||||
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 *PatchKapacitorsIDProxyParams) 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 *PatchKapacitorsIDProxyParams) 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,103 @@
|
|||
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"
|
||||
)
|
||||
|
||||
/*PatchKapacitorsIDProxyNotFound Kapacitor ID does not exist.
|
||||
|
||||
swagger:response patchKapacitorsIdProxyNotFound
|
||||
*/
|
||||
type PatchKapacitorsIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDProxyNotFound creates PatchKapacitorsIDProxyNotFound with default headers values
|
||||
func NewPatchKapacitorsIDProxyNotFound() *PatchKapacitorsIDProxyNotFound {
|
||||
return &PatchKapacitorsIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch kapacitors Id proxy not found response
|
||||
func (o *PatchKapacitorsIDProxyNotFound) WithPayload(payload *models.Error) *PatchKapacitorsIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch kapacitors Id proxy not found response
|
||||
func (o *PatchKapacitorsIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchKapacitorsIDProxyNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PatchKapacitorsIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response patchKapacitorsIdProxyDefault
|
||||
*/
|
||||
type PatchKapacitorsIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDProxyDefault creates PatchKapacitorsIDProxyDefault with default headers values
|
||||
func NewPatchKapacitorsIDProxyDefault(code int) *PatchKapacitorsIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PatchKapacitorsIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the patch kapacitors ID proxy default response
|
||||
func (o *PatchKapacitorsIDProxyDefault) WithStatusCode(code int) *PatchKapacitorsIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the patch kapacitors ID proxy default response
|
||||
func (o *PatchKapacitorsIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch kapacitors ID proxy default response
|
||||
func (o *PatchKapacitorsIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *PatchKapacitorsIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch kapacitors ID proxy default response
|
||||
func (o *PatchKapacitorsIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchKapacitorsIDProxyDefault) 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"
|
||||
)
|
||||
|
||||
/*PatchKapacitorsIDNoContent Kapacitor's configuration was changed
|
||||
|
||||
swagger:response patchKapacitorsIdNoContent
|
||||
*/
|
||||
type PatchKapacitorsIDNoContent struct {
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDNoContent creates PatchKapacitorsIDNoContent with default headers values
|
||||
func NewPatchKapacitorsIDNoContent() *PatchKapacitorsIDNoContent {
|
||||
return &PatchKapacitorsIDNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchKapacitorsIDNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*PatchKapacitorsIDNotFound Happens when trying to access a non-existent kapacitor.
|
||||
|
||||
swagger:response patchKapacitorsIdNotFound
|
||||
*/
|
||||
type PatchKapacitorsIDNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDNotFound creates PatchKapacitorsIDNotFound with default headers values
|
||||
func NewPatchKapacitorsIDNotFound() *PatchKapacitorsIDNotFound {
|
||||
return &PatchKapacitorsIDNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch kapacitors Id not found response
|
||||
func (o *PatchKapacitorsIDNotFound) WithPayload(payload *models.Error) *PatchKapacitorsIDNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch kapacitors Id not found response
|
||||
func (o *PatchKapacitorsIDNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchKapacitorsIDNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PatchKapacitorsIDDefault A processing or an unexpected error.
|
||||
|
||||
swagger:response patchKapacitorsIdDefault
|
||||
*/
|
||||
type PatchKapacitorsIDDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPatchKapacitorsIDDefault creates PatchKapacitorsIDDefault with default headers values
|
||||
func NewPatchKapacitorsIDDefault(code int) *PatchKapacitorsIDDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PatchKapacitorsIDDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the patch kapacitors ID default response
|
||||
func (o *PatchKapacitorsIDDefault) WithStatusCode(code int) *PatchKapacitorsIDDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the patch kapacitors ID default response
|
||||
func (o *PatchKapacitorsIDDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the patch kapacitors ID default response
|
||||
func (o *PatchKapacitorsIDDefault) WithPayload(payload *models.Error) *PatchKapacitorsIDDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the patch kapacitors ID default response
|
||||
func (o *PatchKapacitorsIDDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PatchKapacitorsIDDefault) 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"
|
||||
)
|
||||
|
||||
// PostKapacitorsHandlerFunc turns a function with the right signature into a post kapacitors handler
|
||||
type PostKapacitorsHandlerFunc func(context.Context, PostKapacitorsParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PostKapacitorsHandlerFunc) Handle(ctx context.Context, params PostKapacitorsParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PostKapacitorsHandler interface for that can handle valid post kapacitors params
|
||||
type PostKapacitorsHandler interface {
|
||||
Handle(context.Context, PostKapacitorsParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPostKapacitors creates a new http.Handler for the post kapacitors operation
|
||||
func NewPostKapacitors(ctx *middleware.Context, handler PostKapacitorsHandler) *PostKapacitors {
|
||||
return &PostKapacitors{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PostKapacitors swagger:route POST /kapacitors postKapacitors
|
||||
|
||||
Create new kapacitor backend
|
||||
|
||||
*/
|
||||
type PostKapacitors struct {
|
||||
Context *middleware.Context
|
||||
Handler PostKapacitorsHandler
|
||||
}
|
||||
|
||||
func (o *PostKapacitors) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPostKapacitorsParams()
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// PostKapacitorsIDProxyHandlerFunc turns a function with the right signature into a post kapacitors ID proxy handler
|
||||
type PostKapacitorsIDProxyHandlerFunc func(context.Context, PostKapacitorsIDProxyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn PostKapacitorsIDProxyHandlerFunc) Handle(ctx context.Context, params PostKapacitorsIDProxyParams) middleware.Responder {
|
||||
return fn(ctx, params)
|
||||
}
|
||||
|
||||
// PostKapacitorsIDProxyHandler interface for that can handle valid post kapacitors ID proxy params
|
||||
type PostKapacitorsIDProxyHandler interface {
|
||||
Handle(context.Context, PostKapacitorsIDProxyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewPostKapacitorsIDProxy creates a new http.Handler for the post kapacitors ID proxy operation
|
||||
func NewPostKapacitorsIDProxy(ctx *middleware.Context, handler PostKapacitorsIDProxyHandler) *PostKapacitorsIDProxy {
|
||||
return &PostKapacitorsIDProxy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*PostKapacitorsIDProxy swagger:route POST /kapacitors/{id}/proxy postKapacitorsIdProxy
|
||||
|
||||
POST body directly to configured kapacitor. The response and status code from kapacitor is directly returned.
|
||||
|
||||
*/
|
||||
type PostKapacitorsIDProxy struct {
|
||||
Context *middleware.Context
|
||||
Handler PostKapacitorsIDProxyHandler
|
||||
}
|
||||
|
||||
func (o *PostKapacitorsIDProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, _ := o.Context.RouteInfo(r)
|
||||
var Params = NewPostKapacitorsIDProxyParams()
|
||||
|
||||
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,124 @@
|
|||
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"
|
||||
)
|
||||
|
||||
// NewPostKapacitorsIDProxyParams creates a new PostKapacitorsIDProxyParams object
|
||||
// with the default values initialized.
|
||||
func NewPostKapacitorsIDProxyParams() PostKapacitorsIDProxyParams {
|
||||
var ()
|
||||
return PostKapacitorsIDProxyParams{}
|
||||
}
|
||||
|
||||
// PostKapacitorsIDProxyParams contains all the bound params for the post kapacitors ID proxy operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PostKapacitorsIDProxy
|
||||
type PostKapacitorsIDProxyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*ID of the kapacitor backend.
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *PostKapacitorsIDProxyParams) 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)
|
||||
}
|
||||
|
||||
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 *PostKapacitorsIDProxyParams) 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 *PostKapacitorsIDProxyParams) 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,103 @@
|
|||
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"
|
||||
)
|
||||
|
||||
/*PostKapacitorsIDProxyNotFound Kapacitor ID does not exist.
|
||||
|
||||
swagger:response postKapacitorsIdProxyNotFound
|
||||
*/
|
||||
type PostKapacitorsIDProxyNotFound struct {
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostKapacitorsIDProxyNotFound creates PostKapacitorsIDProxyNotFound with default headers values
|
||||
func NewPostKapacitorsIDProxyNotFound() *PostKapacitorsIDProxyNotFound {
|
||||
return &PostKapacitorsIDProxyNotFound{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post kapacitors Id proxy not found response
|
||||
func (o *PostKapacitorsIDProxyNotFound) WithPayload(payload *models.Error) *PostKapacitorsIDProxyNotFound {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post kapacitors Id proxy not found response
|
||||
func (o *PostKapacitorsIDProxyNotFound) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostKapacitorsIDProxyNotFound) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PostKapacitorsIDProxyDefault Response directly from kapacitor
|
||||
|
||||
swagger:response postKapacitorsIdProxyDefault
|
||||
*/
|
||||
type PostKapacitorsIDProxyDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload models.KapacitorProxyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostKapacitorsIDProxyDefault creates PostKapacitorsIDProxyDefault with default headers values
|
||||
func NewPostKapacitorsIDProxyDefault(code int) *PostKapacitorsIDProxyDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PostKapacitorsIDProxyDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the post kapacitors ID proxy default response
|
||||
func (o *PostKapacitorsIDProxyDefault) WithStatusCode(code int) *PostKapacitorsIDProxyDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the post kapacitors ID proxy default response
|
||||
func (o *PostKapacitorsIDProxyDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post kapacitors ID proxy default response
|
||||
func (o *PostKapacitorsIDProxyDefault) WithPayload(payload models.KapacitorProxyResponse) *PostKapacitorsIDProxyDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post kapacitors ID proxy default response
|
||||
func (o *PostKapacitorsIDProxyDefault) SetPayload(payload models.KapacitorProxyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostKapacitorsIDProxyDefault) 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,65 @@
|
|||
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/influxdata/mrfusion/models"
|
||||
)
|
||||
|
||||
// NewPostKapacitorsParams creates a new PostKapacitorsParams object
|
||||
// with the default values initialized.
|
||||
func NewPostKapacitorsParams() PostKapacitorsParams {
|
||||
var ()
|
||||
return PostKapacitorsParams{}
|
||||
}
|
||||
|
||||
// PostKapacitorsParams contains all the bound params for the post kapacitors operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters PostKapacitors
|
||||
type PostKapacitorsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request
|
||||
|
||||
/*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 *PostKapacitorsParams) 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 {
|
||||
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
|
||||
}
|
|
@ -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"
|
||||
)
|
||||
|
||||
/*PostKapacitorsCreated Successfully created kapacitor source
|
||||
|
||||
swagger:response postKapacitorsCreated
|
||||
*/
|
||||
type PostKapacitorsCreated struct {
|
||||
/*Location of the newly created kapacitor resource.
|
||||
Required: true
|
||||
*/
|
||||
Location string `json:"Location"`
|
||||
|
||||
// In: body
|
||||
Payload *models.Kapacitor `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostKapacitorsCreated creates PostKapacitorsCreated with default headers values
|
||||
func NewPostKapacitorsCreated() *PostKapacitorsCreated {
|
||||
return &PostKapacitorsCreated{}
|
||||
}
|
||||
|
||||
// WithLocation adds the location to the post kapacitors created response
|
||||
func (o *PostKapacitorsCreated) WithLocation(location string) *PostKapacitorsCreated {
|
||||
o.Location = location
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLocation sets the location to the post kapacitors created response
|
||||
func (o *PostKapacitorsCreated) SetLocation(location string) {
|
||||
o.Location = location
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post kapacitors created response
|
||||
func (o *PostKapacitorsCreated) WithPayload(payload *models.Kapacitor) *PostKapacitorsCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post kapacitors created response
|
||||
func (o *PostKapacitorsCreated) SetPayload(payload *models.Kapacitor) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostKapacitorsCreated) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*PostKapacitorsDefault A processing or an unexpected error.
|
||||
|
||||
swagger:response postKapacitorsDefault
|
||||
*/
|
||||
type PostKapacitorsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
// In: body
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewPostKapacitorsDefault creates PostKapacitorsDefault with default headers values
|
||||
func NewPostKapacitorsDefault(code int) *PostKapacitorsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &PostKapacitorsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the post kapacitors default response
|
||||
func (o *PostKapacitorsDefault) WithStatusCode(code int) *PostKapacitorsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the post kapacitors default response
|
||||
func (o *PostKapacitorsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the post kapacitors default response
|
||||
func (o *PostKapacitorsDefault) WithPayload(payload *models.Error) *PostKapacitorsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the post kapacitors default response
|
||||
func (o *PostKapacitorsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *PostKapacitorsDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
22
stores.go
22
stores.go
|
@ -140,3 +140,25 @@ 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
|
||||
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
|
||||
}
|
||||
|
|
253
swagger.yaml
253
swagger.yaml
|
@ -623,6 +623,210 @@ paths:
|
|||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/kapacitors:
|
||||
get:
|
||||
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: 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'
|
||||
/kapacitors/{id}:
|
||||
get:
|
||||
parameters:
|
||||
- name: 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 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 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 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 kapacitor
|
||||
required: true
|
||||
summary: This specific kapacitor will be removed.
|
||||
responses:
|
||||
204:
|
||||
description: kapacitor has been removed.
|
||||
404:
|
||||
description: Unknown Kapacitor id
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
default:
|
||||
description: Unexpected internal service error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/kapacitors/{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 kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
responses:
|
||||
404:
|
||||
description: 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 kapacitor backend.
|
||||
required: true
|
||||
- name: path
|
||||
in: query
|
||||
type: string
|
||||
description: The kapacitor API path to use in the proxy redirect
|
||||
required: true
|
||||
responses:
|
||||
404:
|
||||
description: 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 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:
|
||||
404:
|
||||
description: 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 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:
|
||||
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 +932,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:
|
||||
|
|
Loading…
Reference in New Issue