mackerelclient

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadApibaseFromConfig

func LoadApibaseFromConfig(conffile string) string

LoadApibaseFromConfig gets mackerel api Base URL (usually https://api.mackerelio.com/) from mackerel-agent.conf if it's installed mackerel-agent on localhost

func LoadApibaseFromConfigWithFallback

func LoadApibaseFromConfigWithFallback(conffile string) string

LoadApibaseFromConfigWithFallback get mackerel api Base URL from mackerel-agent.conf, and fallbacks to default (https://api.mackerelio.com/) if not specified.

func LoadApikeyFromConfig

func LoadApikeyFromConfig(conffile string) string

LoadApikeyFromConfig gets mackerel.io apikey from mackerel-agent.conf if it's installed mackerel-agent on localhost

func LoadApikeyFromEnvOrConfig

func LoadApikeyFromEnvOrConfig(conffile string) string

LoadApikeyFromEnvOrConfig is similar to LoadApikeyFromConfig. return MACKEREL_APIKEY environment value if defined MACKEREL_APIKEY

func LoadHostIDFromConfig

func LoadHostIDFromConfig(conffile string) string

LoadHostIDFromConfig gets localhost's hostID from conf.Root (ex. /var/lib/mackerel/id) if it's installed mackerel-agent on localhost

func NewFromContext

func NewFromContext(c *cli.Context) *mackerel.Client

NewFromContext returns mackerel client from cli.Context

Types

type Client added in v0.36.0

type Client interface {
	FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)
	FindServices() ([]*mackerel.Service, error)
	FindChannels() ([]*mackerel.Channel, error)
	GetOrg() (*mackerel.Org, error)
	CreateHost(param *mackerel.CreateHostParam) (string, error)
	UpdateHostStatus(hostID string, status string) error
}

Client represents a client of Mackerel API

func New

func New(conffile, apibase string) (Client, error)

New returns new mackerel client

type MockClient added in v0.36.0

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

MockClient represents a mock client of Mackerel API

func NewMockClient added in v0.36.0

func NewMockClient(opts ...MockClientOption) *MockClient

NewMockClient creates a new mock client of Mackerel API

func (*MockClient) ApplyOption added in v0.36.0

func (c *MockClient) ApplyOption(opt MockClientOption)

ApplyOption applies a mock client option

func (*MockClient) CreateHost added in v0.38.0

func (c *MockClient) CreateHost(param *mackerel.CreateHostParam) (string, error)

CreateHost ...

func (*MockClient) FindChannels added in v0.40.0

func (c *MockClient) FindChannels() ([]*mackerel.Channel, error)

FindChannels ...

func (*MockClient) FindHosts added in v0.36.0

func (c *MockClient) FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)

FindHosts ...

func (*MockClient) FindServices added in v0.36.0

func (c *MockClient) FindServices() ([]*mackerel.Service, error)

FindServices ...

func (*MockClient) GetOrg added in v0.36.0

func (c *MockClient) GetOrg() (*mackerel.Org, error)

GetOrg ...

func (*MockClient) UpdateHostStatus added in v0.38.0

func (c *MockClient) UpdateHostStatus(hostID string, status string) error

UpdateHostStatus ...

type MockClientOption added in v0.36.0

type MockClientOption func(*MockClient)

MockClientOption represents an option of mock client of Mackerel API

func MockCreateHost added in v0.38.0

func MockCreateHost(callback func(*mackerel.CreateHostParam) (string, error)) MockClientOption

MockCreateHost returns an option to set the callback of CreateHost

func MockFindChannels added in v0.40.0

func MockFindChannels(callback func() ([]*mackerel.Channel, error)) MockClientOption

MockFindChannels returns an option to set the callback of FindChannels

func MockFindHosts added in v0.36.0

func MockFindHosts(callback func(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)) MockClientOption

MockFindHosts returns an option to set the callback of FindHosts

func MockFindServices added in v0.36.0

func MockFindServices(callback func() ([]*mackerel.Service, error)) MockClientOption

MockFindServices returns an option to set the callback of FindServices

func MockGetOrg added in v0.36.0

func MockGetOrg(callback func() (*mackerel.Org, error)) MockClientOption

MockGetOrg returns an option to set the callback of GetOrg

func MockUpdateHostStatus added in v0.38.0

func MockUpdateHostStatus(callback func(string, string) error) MockClientOption

MockUpdateHostStatus returns an option to set the callback of UpdateHostStatus

Jump to

Keyboard shortcuts

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