foreman

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserAgent = fmt.Sprintf("foreman_exporter/%s", version.Version)
)

Functions

This section is empty.

Types

type ErrorResult added in v0.0.6

type ErrorResult struct {
	Status int64  `json:"status"`
	Error  string `json:"error"`
}

type HTTPClient

type HTTPClient struct {
	BaseURL  *url.URL
	Username string
	Password string

	Concurrency          int64
	Limit                int64
	Search               string
	SearchHostFact       string
	IncludeHostFactRegex *regexp.Regexp
	ExcludeHostFactRegex *regexp.Regexp
	Log                  *logrus.Logger
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(baseURL *url.URL, username, password string, skipTLSVerify bool, concurrency, limit int64, search, searchHostFact string, includeHostFactRegex, excludeHostFactRegex *regexp.Regexp, log *logrus.Logger) *HTTPClient

func (*HTTPClient) DoWithContext

func (c *HTTPClient) DoWithContext(ctx context.Context, r *http.Request, data interface{}) error

DoWithContext sends an API Request and returns back the response. The API response is checked to see if it was a successful call. A successful call is then checked to see if we need to unmarshal since some resources have their own implements of unmarshal.

func (*HTTPClient) GetHostFacts

func (c *HTTPClient) GetHostFacts(ctx context.Context, hostID, page, perPage int64) (HostFactsResponse, error)

func (*HTTPClient) GetHostFactsWithConcurrency

func (c *HTTPClient) GetHostFactsWithConcurrency(hosts []Host) []HostFactsWithConcurrencyResult

GetHostFactsWithConcurrency sends requests in parallel but only up to a certain limit, and furthermore it's only parallel up to the amount of CPUs but is always concurrent up to the concurrency limit

func (*HTTPClient) GetHostWithConcurrency

func (c *HTTPClient) GetHostWithConcurrency(pages []int64, perPage int64) []HostWithConcurrencyResult

GetHostWithConcurrency sends requests in parallel but only up to a certain limit, and furthermore it's only parallel up to the amount of CPUs but is always concurrent up to the concurrency limit

func (*HTTPClient) GetHosts

func (c *HTTPClient) GetHosts(ctx context.Context, thin string, page, perPage int64) (HostResponse, error)

func (*HTTPClient) GetHostsFactsFiltered

func (c *HTTPClient) GetHostsFactsFiltered(perPage int64) (map[string]map[string]string, error)

func (*HTTPClient) GetHostsFiltered

func (c *HTTPClient) GetHostsFiltered(perPage int64) ([]Host, error)

func (*HTTPClient) OnRequestCompleted

func (c *HTTPClient) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the API request completion callback

func (*HTTPClient) SetHostsFactsRegistry added in v0.0.6

func (c *HTTPClient) SetHostsFactsRegistry(reg prometheus.Registerer)

Set hosts facts prometheus registry

func (*HTTPClient) SetHostsRegistry added in v0.0.6

func (c *HTTPClient) SetHostsRegistry(reg prometheus.Registerer)

Set hosts prometheus registry

type Host

type Host struct {
	ID                       int64  `json:"id"`
	Name                     string `json:"name"`
	GlobalStatusLabel        string `json:"global_status_label,omitempty"`
	ConfigurationStatusLabel string `json:"configuration_status_label,omitempty"`
	BuildStatusLabel         string `json:"build_status_label,omitempty"`
	OrganizationName         string `json:"organization_name,omitempty"`
	EnvironmentName          string `json:"environment_name,omitempty"`
	OperatingSystemName      string `json:"operatingsystem_name,omitempty"`
	OwnerName                string `json:"owner_name,omitempty"`
	LocationName             string `json:"location_name,omitempty"`
	ModelName                string `json:"model_name,omitempty"`
	HostgroupName            string `json:"hostgroup_name,omitempty"`
}

type HostFactsResponse

type HostFactsResponse struct {
	Total   int64                        `json:"total"`
	Page    int64                        `json:"page"`
	PerPage int64                        `json:"per_page"`
	Results map[string]map[string]string `json:"results"`
}

type HostFactsWithConcurrencyResult

type HostFactsWithConcurrencyResult struct {
	Index  int
	Result HostFactsResponse
	Error  error
}

a struct to hold the result from each request including an index which will be used for sorting the results after they come in

type HostResponse

type HostResponse struct {
	Total   int64  `json:"total"`
	Page    int64  `json:"page"`
	PerPage int64  `json:"per_page"`
	Results []Host `json:"results"`
}

type HostWithConcurrencyResult

type HostWithConcurrencyResult struct {
	Index  int
	Result HostResponse
	Error  error
}

a struct to hold the result from each request including an index which will be used for sorting the results after they come in

type LeveledLogrus

type LeveledLogrus struct {
	*logrus.Logger
}

func (*LeveledLogrus) Debug

func (l *LeveledLogrus) Debug(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Error

func (l *LeveledLogrus) Error(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Info

func (l *LeveledLogrus) Info(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Warn

func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{})

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

Jump to

Keyboard shortcuts

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