common

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IDSeparator is used for separation of IDs in the URL
	IDSeparator = ","

	// Location of APIs
	RegistryAPILoc = "/registry"
	DataAPILoc     = "/data"
	AggrAPILoc     = "/aggr"

	// Query parameters
	ParamPage    = "page"
	ParamPerPage = "per_page"
	ParamLimit   = "limit"
	ParamStart   = "start"
	ParamEnd     = "end"
	ParamSort    = "sort"
	// Values for ParamSort
	ASC  = "asc"  // ascending
	DESC = "desc" // descending
)
View Source
const (
	STRING = "string"
	FLOAT  = "float"
	BOOL   = "bool"
)

Data source types

Variables

View Source
var (
	// APIVersion defines the API version
	APIVersion = "N/A"
	// Default MIME type for all responses
	DefaultMIMEType = "application/json;version=" + APIVersion
)

Functions

func ErrorResponse

func ErrorResponse(code int, msg string, w http.ResponseWriter)

ErrorResponse writes error to HTTP ResponseWriter

func ParsePagingParams

func ParsePagingParams(page, perPage string, maxPerPage int) (int, int, error)

func PerItemPagination

func PerItemPagination(_qLimit, _page, _perPage, _numOfSrcs int) ([]int, []int)

Calculate perItem and offset given the page, perPage, limit, and number of sources

func SupportedAggregate

func SupportedAggregate(a string) bool

SupportedAggregate validates an aggregate

func SupportedPeriod added in v0.5.0

func SupportedPeriod(p string) bool

SupportedPeriod validates a period

func SupportedPeriods added in v0.6.1

func SupportedPeriods() []string

SupportedPeriods returns supported periods

func SupportedType

func SupportedType(t string) bool

SupportedType validates a type

func ValidatePagingParams

func ValidatePagingParams(page, perPage, maxPerPage int) error

func ValidatePerItemLimit

func ValidatePerItemLimit(_qLimit, _perPage, _numOfSrcs int) error

Check if the parameters match the criteria required by PerItemPagination function

Types

type AggrConf added in v0.5.0

type AggrConf struct{}

Aggregation config

type Config added in v0.5.0

type Config struct {
	// Service ID
	ServiceID string `json:"serviceID"`
	// HDS API addr
	HTTP HTTPConf `json:"http"`
	// Web GUI
	Web WebConfig `json:"web"`
	// Registry API Config
	Reg RegConf `json:"registry"`
	// Data API Config
	Data DataConf `json:"data"`
	// Aggregation API Config
	Aggr AggrConf `json:"aggregation"`
	// LinkSmart Service Catalog registration config
	ServiceCatalog *ServiceCatalogConf `json:"serviceCatalog"`
	// Auth config
	Auth ValidatorConf `json:"auth"`
}

type DataBackendConf added in v0.5.0

type DataBackendConf struct {
	Type string `json:"type"`
	DSN  string `json:"dsn"`
}

Data backend config

type DataConf added in v0.5.0

type DataConf struct {
	Backend DataBackendConf `json:"backend"`
	// RetentionPeriods is deprecated, will be removed from v0.6.0. Use registry.retentionPeriods instead.
	RetentionPeriods []string `json:"retentionPeriods"`
	AutoRegistration bool     `json:"autoRegistration"`
}

Data config

type Error

type Error struct {
	// Code is the (http) code of the error
	Code int `json:"code"`
	// Message is the (human-readable) error message
	Message string `json:"message"`
}

Error describes an API error (serializable in JSON)

type HTTPConf added in v0.5.0

type HTTPConf struct {
	PublicEndpoint string `json:"publicEndpoint"`
	BindAddr       string `json:"bindAddr"`
	BindPort       uint16 `json:"bindPort"`
}

HTTP config

type ObtainerConf added in v0.5.0

type ObtainerConf struct {
	// Authentication provider name
	Provider string `json:"provider"`
	// Authentication provider URL
	ProviderURL string `json:"providerURL"`
	// Service ID
	ServiceID string `json:"serviceID"`
	// User credentials
	Username string `json:"username"`
	Password string `json:"password"`
}

Ticket Obtainer Client Config

func (ObtainerConf) Validate added in v0.5.0

func (c ObtainerConf) Validate() error

type RegBackendConf added in v0.5.0

type RegBackendConf struct {
	Type string `json:"type"`
	DSN  string `json:"dsn"`
}

Registry backend config

type RegConf added in v0.5.0

type RegConf struct {
	Backend          RegBackendConf `json:"backend"`
	RetentionPeriods []string       `json:"retentionPeriods"`
}

Registry config

func (RegConf) ConfiguredRetention added in v0.5.2

func (c RegConf) ConfiguredRetention(period string) bool

type ServiceCatalogConf added in v0.5.0

type ServiceCatalogConf struct {
	Discover bool          `json:"discover"`
	Endpoint string        `json:"endpoint"`
	TTL      uint          `json:"ttl"`
	Auth     *ObtainerConf `json:"auth"`
}

LinkSmart Service Catalog registration config

type ValidatorConf added in v0.5.0

type ValidatorConf struct {
	// Auth switch
	Enabled bool `json:"enabled"`
	// Authentication provider name
	Provider string `json:"provider"`
	// Authentication provider URL
	ProviderURL string `json:"providerURL"`
	// Service ID
	ServiceID string `json:"serviceID"`
	// Basic Authentication switch
	BasicEnabled bool `json:"basicEnabled"`
	// Authorization config
	Authz *authz.Conf `json:"authorization"`
}

Ticket Validator Config

func (ValidatorConf) Validate added in v0.5.0

func (c ValidatorConf) Validate() error

type WebConfig added in v0.5.0

type WebConfig struct {
	BindAddr  string `json:"bindAddr"`
	BindPort  uint16 `json:"bindPort"`
	StaticDir string `json:"staticDir"`
}

Web GUI Config

Jump to

Keyboard shortcuts

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