rest

package
v0.16.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 40 Imported by: 0

README

snap REST API

Task Schema

This is used in REST, and in a file format for the cli.

---
version: 1
task:
  schedule:
    type: simple
    interval: 5s
  deadline: 5s
  config:
    /intel/mock:
    - key: password
      value: j3rr
  workflow:
    collect:
      metric_types:
      - namespace: /intel/mock/foo
      - namespace: /intel/mock/bar
      publish:
      - plugin:
          name: "influx"
          version: 2
      process:
      - plugin:
          name: "averager"
        publish:
        - plugin:
          name: "rabbitmq"
          version: 1
{
  "version": 1,
  "task": {
    "schedule": {
      "type": "simple",
      "interval": "5s"
    },
    "deadline": "5s",
    "config": {
      "/intel/mock": [
        {
          "key": "password",
          "value": "j3rr"
        }
      ]
    },
    "workflow": {
      "collect": {
        "metric_types": [
          {
            "namespace": "/intel/mock/foo"
          },
          {
            "namespace": "/intel/mock/bar"
          }
        ],
        "publish": [
          {
            "plugin": {
              "name": "influx",
              "version": 2
            }
          }
        ],
        "process": [
          {
            "plugin": {
              "name": "averager"
            },
            "publish": [
              {
                "plugin": {
                  "name": "rabbitmq",
                  "version": 1
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Documentation

Index

Constants

View Source
const (
	APIVersion = 1
)
View Source
const (
	CONFIG_CONSTRAINTS = `` /* 575-byte string literal not displayed */

)
View Source
const PluginAlreadyLoaded = "plugin is already loaded"

Variables

View Source
var (
	ErrMissingPluginName = errors.New("missing plugin name")
	ErrPluginNotFound    = errors.New("plugin not found")
)
View Source
var (
	// The amount of time to buffer streaming events before flushing in seconds
	StreamingBufferWindow = 0.1

	ErrStreamingUnsupported    = errors.New("Streaming unsupported")
	ErrTaskNotFound            = errors.New("Task not found")
	ErrTaskDisabledNotRunnable = errors.New("Task is disabled. Cannot be started")
)
View Source
var (
	ErrInvalidJSON           = errors.New("Invalid JSON")
	ErrAgreementDoesNotExist = errors.New("Agreement not found")
	ErrMemberNotFound        = errors.New("Member not found")
)
View Source
var (
	ErrBadCert = errors.New("Invalid certificate given")
)
View Source
var (

	// Flags consumed by snapd
	Flags = []cli.Flag{flAPIDisabled, flAPIAddr, flAPIPort, flRestHTTPS, flRestCert, flRestKey, flRestAuth}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable           bool   `json:"enable"yaml:"enable"`
	Port             int    `json:"port"yaml:"port"`
	Address          string `json:"addr"yaml:"addr"`
	HTTPS            bool   `json:"https"yaml:"https"`
	RestCertificate  string `json:"rest_certificate"yaml:"rest_certificate"`
	RestKey          string `json:"rest_key"yaml:"rest_key"`
	RestAuth         bool   `json:"rest_auth"yaml:"rest_auth"`
	RestAuthPassword string `json:"rest_auth_password"yaml:"rest_auth_password"`
	// contains filtered or unexported fields
}

holds the configuration passed in through the SNAP config file

Note: if this struct is modified, then the switch statement in the
      UnmarshalJSON method in this same file needs to be modified to
      match the field mapping that is defined here

func GetDefaultConfig

func GetDefaultConfig() *Config

GetDefaultConfig gets the default snapd configuration

func (*Config) PortSetByConfigFile

func (c *Config) PortSetByConfigFile() bool

define a method that can be used to determine if the port the RESTful API is listening on was set in the configuration file

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals valid json into a Config. An example Config can be found at github.com/intelsdi-x/snap/blob/master/examples/configs/snap-config-sample.json

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a snap middleware that logs to a logrus facility

func NewLogger

func NewLogger() *Logger

NewLogger returns a new Logger instance

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Server, error)

New creates a REST API server with a given config

func (*Server) BindConfigManager

func (s *Server) BindConfigManager(c managesConfig)

func (*Server) BindMetricManager

func (s *Server) BindMetricManager(m managesMetrics)

func (*Server) BindTaskManager

func (s *Server) BindTaskManager(t managesTasks)

func (*Server) BindTribeManager

func (s *Server) BindTribeManager(t managesTribe)

func (*Server) Err

func (s *Server) Err() <-chan error

func (*Server) Name

func (s *Server) Name() string

func (*Server) Port

func (s *Server) Port() int

func (*Server) SetAPIAuth

func (s *Server) SetAPIAuth(auth bool)

SetAPIAuth sets API authentication to enabled or disabled

func (*Server) SetAPIAuthPwd

func (s *Server) SetAPIAuthPwd(pwd string)

SetAPIAuthPwd sets the API authentication password from snapd

func (*Server) SetAddress

func (s *Server) SetAddress(addrString string)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

type TaskWatchHandler

type TaskWatchHandler struct {
	// contains filtered or unexported fields
}

func (*TaskWatchHandler) CatchCollection

func (t *TaskWatchHandler) CatchCollection(m []core.Metric)

func (*TaskWatchHandler) CatchTaskDisabled

func (t *TaskWatchHandler) CatchTaskDisabled(why string)

func (*TaskWatchHandler) CatchTaskStarted

func (t *TaskWatchHandler) CatchTaskStarted()

func (*TaskWatchHandler) CatchTaskStopped

func (t *TaskWatchHandler) CatchTaskStopped()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL