inventoryapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const MaxSourceLen = 100

Maximum size for the delta source field.

View Source
const ResetAll = "all"

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkDeltaResponse

type BulkDeltaResponse struct {
	PostDeltaResponse
	EntityKeys []string `json:"entityKeys"`
	Error      string   `json:"error,omitempty"`
}

BulkDeltaResponse is an entry in the bulk delta post, which is the PostDeltaResponse decorated with the request entityKeys and an error to indicate a failure.

type DeltaState

type DeltaState struct {
	// NeedsReset was added Sept 2017 to fix the situation where the agent
	// sent id N and the server expected N+1 resulting in the ambiguous
	// SendNextID server response of N+1.  The agent only observes this in
	// versions > 1.0.783.
	NeedsReset   bool    `json:"needs_reset,omitempty"`
	LastStoredID int64   `json:"last_stored_id"` // Latest ID of what is stored, zero if none
	SendNextID   int64   `json:"send_next_id"`   // Starting ID that should be sent back, zero if send original
	Error        *string `json:"error,omitempty"`
}

DeltaState platform response for a given plugin submission.

type DeltaStateMap

type DeltaStateMap map[string]*DeltaState

type DeltasByID

type DeltasByID []*RawDelta

Sortable implementation of a raw delta list so we can sort by ID

func (DeltasByID) Len

func (a DeltasByID) Len() int

func (DeltasByID) Less

func (a DeltasByID) Less(i, j int) bool

func (DeltasByID) Swap

func (a DeltasByID) Swap(i, j int)

type IngestClient

type IngestClient struct {
	HttpClient       backendhttp.Client
	CompressionLevel int
	// contains filtered or unexported fields
}

func NewIngestClient

func NewIngestClient(
	svcUrl, licenseKey, userAgent string,
	compressionLevel int,
	agentKey string,
	agentIDProvide id.Provide,
	connectEnabled bool,
	httpClient backendhttp.Client,
) (*IngestClient, error)

func (*IngestClient) Do

func (i *IngestClient) Do(req *http.Request) (*http.Response, error)

Do performs an http.Request, augmenting it with auth headers

func (*IngestClient) PostDeltas

func (ic *IngestClient) PostDeltas(entityKeys []string, entityID entity.ID, isAgent bool, deltas ...*RawDelta) (*PostDeltaResponse, error)

PostDeltas posts deltas to inventory ingest. The deltas are assumed to all be coming from one logical entity (host, container, etc) and blending deltas together will lead to confusion.

func (*IngestClient) PostDeltasBulk

func (ic *IngestClient) PostDeltasBulk(reqs []PostDeltaBody) ([]BulkDeltaResponse, error)

PostDeltasBulk allows posting deltas for multiple entities in a single request. On an IngestError, all processed deltas will be returned with a non-empty Error string for any that errored.

func (*IngestClient) PostDeltasVortex

func (ic *IngestClient) PostDeltasVortex(entityID entity.ID, entityKeys []string, isAgent bool, deltas ...*RawDelta) (*PostDeltaResponse, error)

PostDeltasVortex posts deltas to inventory ingest. The deltas are assumed to all be coming from one logical entity (host, container, etc) and blending deltas together will lead to confusion.

type IngestError

type IngestError struct {
	Status     string
	StatusCode int
	Body       string
	// contains filtered or unexported fields
}

IngestError is an error type that only occurs in the bad status code case.

func NewIngestError

func NewIngestError(msg string, code int, status, body string) *IngestError

NewIngestError returns a new IngestError.

func (*IngestError) Error

func (e *IngestError) Error() string

type PostDeltaBody

type PostDeltaBody struct {
	EntityID entity.ID `json:"entityId,omitempty"`

	ExternalKeys []string `json:"entityKeys"`

	// Is this entity an agent's own host? Controls whether we display the entity as such and
	// track its connected status. Pointer allows nil for older agents which didn't send this field.
	IsAgent *bool `json:"isAgent"`

	Deltas []*RawDelta `json:"deltas"`
}

type PostDeltaResponse

type PostDeltaResponse struct {
	Version  int64         `json:"version"`
	StateMap DeltaStateMap `json:"state_map"`
	Reset    string        `json:"reset,omitempty"` // Set to inventoryapi.ResetAll (all) to reset everything, blank means nothing
}

PostDeltaResponse is the response to a post delta request.

func NewPostDeltaResponse

func NewPostDeltaResponse() *PostDeltaResponse

type PostDeltaVortexBody

type PostDeltaVortexBody struct {
	EntityID entity.ID `json:"entity_id"`

	// Is this entity an agent's own host? Controls whether we display the entity as such and
	// track its connected status. Pointer allows nil for older agents which didn't send this field.
	IsAgent *bool `json:"isAgent"`

	Deltas []*RawDelta `json:"deltas"`
}

type RawDelta

type RawDelta struct {
	Source    string                 `json:"source"`
	ID        int64                  `json:"id"`
	Timestamp int64                  `json:"timestamp"`
	Diff      map[string]interface{} `json:"diff"`
	FullDiff  bool                   `json:"full_diff"` // See DiffType* constants
}

func NewRawDelta

func NewRawDelta(source string, deltaID int64, timestamp int64, diff map[string]interface{}, full bool) *RawDelta

type RawDeltaBlock

type RawDeltaBlock []*RawDelta

RawDeltaBlock groups RawDeltas to be processed in different blocks

Jump to

Keyboard shortcuts

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