ngsilib

package
v0.0.0-...-60f56ae Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogOff is ...
	LogOff = iota
	// LogErr is ...
	LogErr
	// LogWarn is ...
	LogWarn
	// LogInfo is ...
	LogInfo
	// LogDebug is ...
	LogDebug
	// LogTrace is ...
	LogTrace
)

Variables

This section is empty.

Functions

func Contains

func Contains(a []string, e string) bool

Contains is ...

func GetExpirationDate

func GetExpirationDate(s string) (string, error)

GetExpirationDate is ...

func GetJSONArray

func GetJSONArray(b []byte, v interface{}) error

GetJSONArray is ...

func InitBrokerList

func InitBrokerList()

InitBrokerList is ...

func IsHTTP

func IsHTTP(url string) bool

IsHTTP is ...

func IsJSON

func IsJSON(b []byte) bool

IsJSON is ...

func IsNameString

func IsNameString(s string) bool

IsNameString is ...

func IsNgsiLd

func IsNgsiLd(s string) bool

IsNgsiLd is ...

func IsNgsiV2

func IsNgsiV2(s string) bool

IsNgsiV2 is ...

func IsOrionDateTime

func IsOrionDateTime(s string) bool

IsOrionDateTime is ...

func JSONMarshal

func JSONMarshal(v interface{}) ([]byte, error)

JSONMarshal is ...

func JSONMarshalDecode

func JSONMarshalDecode(v interface{}, safeString bool) ([]byte, error)

JSONMarshalDecode is ...

func JSONMarshalEncode

func JSONMarshalEncode(v interface{}, safeString bool) ([]byte, error)

JSONMarshalEncode is ...

func JSONSafeStringDecode

func JSONSafeStringDecode(data []byte) ([]byte, error)

JSONSafeStringDecode is ...

func JSONSafeStringEncode

func JSONSafeStringEncode(data []byte) ([]byte, error)

JSONSafeStringEncode is ...

func JSONUnmarshal

func JSONUnmarshal(data []byte, v interface{}) error

JSONUnmarshal is ...

func JSONUnmarshalDecode

func JSONUnmarshalDecode(data []byte, v interface{}, safeString bool) error

JSONUnmarshalDecode is ...

func JSONUnmarshalEncode

func JSONUnmarshalEncode(data []byte, v interface{}, safeString bool) error

JSONUnmarshalEncode is ...

func LogLevel

func LogLevel(s string) (int, error)

LogLevel is ...

func Reset

func Reset()

Reset is ...

func SafeStringDecode

func SafeStringDecode(s string) string

SafeStringDecode is ...

func SafeStringEncode

func SafeStringEncode(s string) string

SafeStringEncode is ...

Types

type Broker

type Broker struct {
	BrokerHost   string `json:"brokerHost,omitempty"`
	NgsiType     string `json:"ngsiType,omitempty"`
	APIPath      string `json:"apiPath,omitempty"`
	IdmType      string `json:"idmType,omitempty"`
	IdmHost      string `json:"idmHost,omitempty"`
	Token        string `json:"token,omitempty"`
	Username     string `json:"username,omitempty"`
	Password     string `json:"password,omitempty"`
	ClientID     string `json:"clientId,omitempty"`
	ClientSecret string `json:"clientSecret,omitempty"`
	Context      string `json:"context,omitempty"`
	Tenant       string `json:"tenant,omitempty"`
	Scope        string `json:"scope,omitempty"`
	SafeString   string `json:"safeString,omitempty"`
	XAuthToken   string `json:"xAuthToken,omitempty"`
}

Broker is

type BrokerList

type BrokerList map[string]*Broker

BrokerList is ...

func (*BrokerList) BrokerInfo

func (info *BrokerList) BrokerInfo(name string) (*Broker, error)

BrokerInfo is ...

func (*BrokerList) BrokerInfoJSON

func (info *BrokerList) BrokerInfoJSON(name string) (*string, error)

BrokerInfoJSON is ...

func (*BrokerList) List

func (info *BrokerList) List() string

List is ...

type Client

type Client struct {
	Broker        *Broker
	URL           *url.URL
	Headers       map[string]string
	Token         string
	Tenant        string
	Scope         string
	APIPathBefore string
	APIPathAfter  string
	NgsiType      int
	SafeString    bool
	XAuthToken    bool
	Link          *string
	HTTP          HTTPRequest
}

Client is

func (*Client) CheckScope

func (client *Client) CheckScope(scope string) error

CheckScope is ...

func (*Client) CheckTenant

func (client *Client) CheckTenant(tenant string) error

CheckTenant is ...

func (*Client) HTTPDelete

func (client *Client) HTTPDelete() (*http.Response, []byte, error)

HTTPDelete is

func (*Client) HTTPGet

func (client *Client) HTTPGet() (*http.Response, []byte, error)

HTTPGet is ...

func (*Client) HTTPPatch

func (client *Client) HTTPPatch(body interface{}) (*http.Response, []byte, error)

HTTPPatch is ...

func (*Client) HTTPPost

func (client *Client) HTTPPost(body interface{}) (*http.Response, []byte, error)

HTTPPost is ...

func (*Client) HTTPPut

func (client *Client) HTTPPut(body interface{}) (*http.Response, []byte, error)

HTTPPut is ...

func (*Client) InitHeader

func (client *Client) InitHeader() error

InitHeader is ...

func (*Client) IsNgsiLd

func (client *Client) IsNgsiLd() bool

IsNgsiLd is

func (*Client) IsNgsiV2

func (client *Client) IsNgsiV2() bool

IsNgsiV2 is

func (*Client) IsSafeString

func (client *Client) IsSafeString() bool

IsSafeString is ...

func (*Client) OpUpdate

func (client *Client) OpUpdate(entities interface{}, actionType string, keyValues bool, safeString bool) (*http.Response, []byte, error)

OpUpdate is ...

func (*Client) RemoveHeader

func (client *Client) RemoveHeader(key string)

RemoveHeader is ...

func (*Client) ResultsCount

func (client *Client) ResultsCount(res *http.Response) (int, error)

ResultsCount is ...

func (*Client) SetContentType

func (client *Client) SetContentType()

SetContentType is ...

func (*Client) SetHeader

func (client *Client) SetHeader(key string, value string)

SetHeader is ...

func (*Client) SetHeaders

func (client *Client) SetHeaders(headers map[string]string)

SetHeaders is ...

func (*Client) SetPath

func (client *Client) SetPath(path string)

SetPath is ...

func (*Client) SetQuery

func (client *Client) SetQuery(values *url.Values)

SetQuery is ...

type CmdFlags

type CmdFlags struct {
	Token      *string
	Tenant     *string
	Scope      *string
	SafeString *string
	XAuthToken bool
	Link       *string
}

CmdFlags is ...

type ContextsInfo

type ContextsInfo map[string]string

ContextsInfo is ...

type FileLib

type FileLib interface {
	Open(path string) error
	Close() error
	FilePathAbs(path string) (string, error)
	ReadAll(r io.Reader) ([]byte, error)
	ReadFile(filename string) ([]byte, error)
	SetReader(r io.Reader)
	File() io.Reader
}

FileLib is ...

type HTTPRequest

type HTTPRequest interface {
	Request(method string, url *url.URL, headers map[string]string, body interface{}) (*http.Response, []byte, error)
}

HTTPRequest is ...

func NewHTTPRequet

func NewHTTPRequet() HTTPRequest

NewHTTPRequet is ...

type IoLib

type IoLib interface {
	Open() error
	OpenFile(flag int, perm os.FileMode) error
	Truncate(size int64) error
	Close() error
	Decode(v interface{}) error
	Encode(v interface{}) error
	MkdirAll(path string, perm os.FileMode) error
	Stat(name string) (os.FileInfo, error)
	UserConfigDir() (string, error)
	UserHomeDir() (string, error)
	SetFileName(filename *string)
	FileName() *string
	Getenv(key string) string
	FilePathAbs(path string) (string, error)
	FilePathJoin(elem ...string) string
}

IoLib is ...

type JSONLib

type JSONLib interface {
	Decode(r io.Reader, v interface{}) error
	Encode(w io.Writer, v interface{}) error
}

JSONLib is

type LogWriter

type LogWriter struct {
	Writer   io.Writer
	LogLevel int
}

LogWriter is ...

func (*LogWriter) Write

func (w *LogWriter) Write(p []byte) (n int, err error)

type NGSI

type NGSI struct {
	LogLevel      int
	ConfigFile    IoLib
	CacheFile     IoLib
	StdReader     io.Reader
	StdWriter     io.Writer
	LogWriter     io.Writer
	FileReader    FileLib
	JSONConverter JSONLib
	Host          string
	Destination   string
	Margin        int64
	Maxsize       int
	Timeout       time.Duration
	PreviousArgs  *Settings
	Updated       bool
	HTTP          HTTPRequest
	Stderr        *os.File
	OsType        string
	SyslogLib     SyslogLib
	TimeLib       TimeLib
	BatchFlag     *bool
	// contains filtered or unexported fields
}

NGSI is ...

func NewNGSI

func NewNGSI() *NGSI

NewNGSI is ...

func (*NGSI) AddContext

func (ngsi *NGSI) AddContext(key string, value string) error

AddContext is ...

func (*NGSI) BoolFlag

func (ngsi *NGSI) BoolFlag(s string) (bool, error)

BoolFlag is ...

func (*NGSI) BrokerList

func (ngsi *NGSI) BrokerList() *BrokerList

BrokerList is ...

func (*NGSI) Close

func (ngsi *NGSI) Close()

Close is ...

func (*NGSI) CreateBroker

func (ngsi *NGSI) CreateBroker(name string, brokerParam map[string]string) error

CreateBroker is ...

func (*NGSI) DeleteBroker

func (ngsi *NGSI) DeleteBroker(host string) error

DeleteBroker is ...

func (*NGSI) DeleteContext

func (ngsi *NGSI) DeleteContext(key string) error

DeleteContext is ...

func (*NGSI) DeleteItem

func (ngsi *NGSI) DeleteItem(host string, item string) error

DeleteItem is ...

func (*NGSI) ExistsBrokerHost

func (ngsi *NGSI) ExistsBrokerHost(host string) bool

ExistsBrokerHost is ...

func (*NGSI) GetContext

func (ngsi *NGSI) GetContext(key string) (string, error)

GetContext is ...

func (*NGSI) GetContextList

func (ngsi *NGSI) GetContextList() ContextsInfo

GetContextList is ...

func (*NGSI) GetPreviousArgs

func (ngsi *NGSI) GetPreviousArgs() *Settings

GetPreviousArgs is ...

func (*NGSI) GetToken

func (ngsi *NGSI) GetToken(client *Client) (string, error)

GetToken is ...

func (*NGSI) InitConfig

func (ngsi *NGSI) InitConfig(file *string) error

InitConfig is ...

func (*NGSI) InitLog

func (ngsi *NGSI) InitLog(stdin io.Reader, stdout, stderr io.Writer) *NGSI

InitLog is ...

func (*NGSI) InitTokenMgr

func (ngsi *NGSI) InitTokenMgr(file *string) error

InitTokenMgr is ..

func (*NGSI) IsContextReferenced

func (ngsi *NGSI) IsContextReferenced(context string) error

IsContextReferenced is ...

func (*NGSI) IsHostReferenced

func (ngsi *NGSI) IsHostReferenced(host string) error

IsHostReferenced is ...

func (*NGSI) Logging

func (ngsi *NGSI) Logging(level int, s string) (n int, err error)

Logging is ...

func (*NGSI) NewClient

func (ngsi *NGSI) NewClient(name string, cmdFlags *CmdFlags, isHTTPVerb bool) (client *Client, err error)

NewClient is ...

func (*NGSI) SavePreviousArgs

func (ngsi *NGSI) SavePreviousArgs() error

SavePreviousArgs is ...

func (*NGSI) ServerInfoArgs

func (ngsi *NGSI) ServerInfoArgs() []string

ServerInfoArgs is ...

func (*NGSI) TokenInfo

func (ngsi *NGSI) TokenInfo(client *Client) (*TokenInfo, error)

TokenInfo is ...

func (*NGSI) TokenList

func (ngsi *NGSI) TokenList() string

TokenList is ...

func (*NGSI) UpdateBroker

func (ngsi *NGSI) UpdateBroker(host string, brokerParam map[string]string) error

UpdateBroker is ...

func (*NGSI) UpdateContext

func (ngsi *NGSI) UpdateContext(key string, value string) error

UpdateContext is ...

type NgsiConfig

type NgsiConfig struct {
	DefaultValues Settings     `json:"settings"`
	Brokers       BrokerList   `json:"brokers"`
	Contexts      ContextsInfo `json:"contexts"`
}

NgsiConfig is ...

type NgsiLibError

type NgsiLibError struct {
	Function string
	ErrNo    int
	Message  string
	Err      error
}

NgsiLibError is ...

func (*NgsiLibError) Error

func (e *NgsiLibError) Error() string

func (*NgsiLibError) String

func (e *NgsiLibError) String() string

func (*NgsiLibError) Unwrap

func (e *NgsiLibError) Unwrap() error

type Settings

type Settings struct {
	UsePreviousArgs bool   `json:"usePreviousArgs"`
	Syslog          string `json:"syslog"`
	Stderr          string `json:"stderr"`
	Logfile         string `json:"logfile"`
	Loglevel        string `json:"loglevel"`
	CacheFile       string `json:"cachefile"`
	Host            string `json:"host"`
	Tenant          string `json:"tenant"`
	Scope           string `json:"scope"`
	Token           string `json:"token"`
}

Settings is ...

type SyslogLib

type SyslogLib interface {
	New() (io.Writer, error)
}

SyslogLib is ...

type TimeLib

type TimeLib interface {
	Now() time.Time
	NowUnix() int64
}

TimeLib is ...

type Token

type Token struct {
	AccessToken  string   `json:"access_token"`
	ExpiresIn    int64    `json:"expires_in"`
	RefreshToken string   `json:"refresh_token"`
	Scope        []string `json:"scope"`
	TokenType    string   `json:"token_type"`
}

Token is ...

type TokenInfo

type TokenInfo struct {
	Expires int64 `json:"expires"`
	Token   Token `json:"token"`
}

TokenInfo is ...

Jump to

Keyboard shortcuts

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