Documentation ¶
Index ¶
- func LoadApibaseFromConfig(conffile string) string
- func LoadApibaseFromConfigWithFallback(conffile string) string
- func LoadApikeyFromConfig(conffile string) string
- func LoadApikeyFromEnvOrConfig(conffile string) string
- func LoadHostIDFromConfig(conffile string) string
- func NewFromContext(c *cli.Context) *mackerel.Client
- type Client
- type MockClient
- func (c *MockClient) ApplyOption(opt MockClientOption)
- func (c *MockClient) CreateHost(param *mackerel.CreateHostParam) (string, error)
- func (c *MockClient) FindAWSIntegrations() ([]*mackerel.AWSIntegration, error)
- func (c *MockClient) FindChannels() ([]*mackerel.Channel, error)
- func (c *MockClient) FindHost(id string) (*mackerel.Host, error)
- func (c *MockClient) FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)
- func (c *MockClient) FindServices() ([]*mackerel.Service, error)
- func (c *MockClient) GetOrg() (*mackerel.Org, error)
- func (c *MockClient) ListHostMetricNames(hostID string) ([]string, error)
- func (c *MockClient) UpdateHostStatus(hostID string, status string) error
- type MockClientOption
- func MockCreateHost(callback func(*mackerel.CreateHostParam) (string, error)) MockClientOption
- func MockFindAWSIntegrations(callback func() ([]*mackerel.AWSIntegration, error)) MockClientOption
- func MockFindChannels(callback func() ([]*mackerel.Channel, error)) MockClientOption
- func MockFindHost(callback func(id string) (*mackerel.Host, error)) MockClientOption
- func MockFindHosts(callback func(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)) MockClientOption
- func MockFindServices(callback func() ([]*mackerel.Service, error)) MockClientOption
- func MockGetOrg(callback func() (*mackerel.Org, error)) MockClientOption
- func MockListHostMetricNames(callback func(string) ([]string, error)) MockClientOption
- func MockUpdateHostStatus(callback func(string, string) error) MockClientOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadApibaseFromConfig ¶
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 ¶
LoadApibaseFromConfigWithFallback get mackerel api Base URL from mackerel-agent.conf, and fallbacks to default (https://api.mackerelio.com/) if not specified.
func LoadApikeyFromConfig ¶
LoadApikeyFromConfig gets mackerel.io apikey from mackerel-agent.conf if it's installed mackerel-agent on localhost
func LoadApikeyFromEnvOrConfig ¶
LoadApikeyFromEnvOrConfig is similar to LoadApikeyFromConfig. return MACKEREL_APIKEY environment value if defined MACKEREL_APIKEY
func LoadHostIDFromConfig ¶
LoadHostIDFromConfig gets localhost's hostID from conf.Root (ex. /var/lib/mackerel/id) if it's installed mackerel-agent on localhost
func NewFromContext ¶
NewFromContext returns mackerel client from cli.Context
Types ¶
type Client ¶ added in v0.36.0
type Client interface { FindAWSIntegrations() ([]*mackerel.AWSIntegration, error) FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error) FindHost(id string) (*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 ListHostMetricNames(id string) ([]string, error) }
Client represents a client of Mackerel API
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) FindAWSIntegrations ¶ added in v0.45.3
func (c *MockClient) FindAWSIntegrations() ([]*mackerel.AWSIntegration, error)
FindAWSIntegrations ...
func (*MockClient) FindChannels ¶ added in v0.40.0
func (c *MockClient) FindChannels() ([]*mackerel.Channel, error)
FindChannels ...
func (*MockClient) FindHost ¶ added in v0.47.0
func (c *MockClient) FindHost(id string) (*mackerel.Host, error)
FindHost ...
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) ListHostMetricNames ¶ added in v0.48.0
func (c *MockClient) ListHostMetricNames(hostID string) ([]string, error)
ListHostMetricNames ...
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 MockFindAWSIntegrations ¶ added in v0.45.3
func MockFindAWSIntegrations(callback func() ([]*mackerel.AWSIntegration, error)) MockClientOption
MockFindAWSIntegrations returns an option to set the callback of FindAWSIntegrations
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 MockFindHost ¶ added in v0.47.0
func MockFindHost(callback func(id string) (*mackerel.Host, error)) MockClientOption
MockFindHost returns an option to set the callback of FindHost
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 MockListHostMetricNames ¶ added in v0.48.0
func MockListHostMetricNames(callback func(string) ([]string, error)) MockClientOption
MockListHostMetricNames returns an option to set the callback of ListHostMetricNames
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