inventory

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package inventory allows to interact with the Graph Asset Inventory REST API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when an entity cannot be found in the Asset
	// Inventory.
	ErrNotFound = errors.New("not found")

	// ErrAlreadyExists is returned when trying to create an entity that
	// already exists.
	ErrAlreadyExists = errors.New("already exists")

	// Unexpired is the [time.Time] expiration assigned to unexpired
	// entities.
	Unexpired = *strtime("9999-12-12T23:59:59Z")
)

Functions

This section is empty.

Types

type AssetReq

type AssetReq struct {
	Type       string     `json:"type"`
	Identifier string     `json:"identifier"`
	Timestamp  *time.Time `json:"timestamp,omitempty"`
	Expiration time.Time  `json:"expiration"`
}

AssetReq represents the "AssetReq" model as defined by the Graph Asset Inventory REST API.

type AssetResp

type AssetResp struct {
	ID         string    `json:"id"`
	Type       string    `json:"type"`
	Identifier string    `json:"identifier"`
	FirstSeen  time.Time `json:"first_seen"`
	LastSeen   time.Time `json:"last_seen"`
	Expiration time.Time `json:"expiration"`
}

AssetResp represents the "AssetResp" model as defined by the Graph Asset Inventory REST API.

type Client

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

Client represents a client of the Graph Asset Inventory REST API.

func NewClient

func NewClient(endpoint string, insecureSkipVerify bool) (Client, error)

NewClient returns a Client pointing to the given endpoint (for instance https://security-graph-asset-inventory/), and optionally skipping the verification of the endpoint server certificate.

func (Client) Assets

func (cli Client) Assets(typ, identifier string, validAt time.Time, pag Pagination) ([]AssetResp, error)

Assets returns a list of assets filtered by type and identifier. If typ, identifier are empty and validAt is zero, no filter is applied. The pag parameter controls pagination.

func (Client) Children

func (cli Client) Children(assetID string, pag Pagination) ([]ParentOfResp, error)

Children returns the outgoing "parent of" relations of the asset with the given ID. The pag parameter controls pagination.

func (Client) CreateAsset

func (cli Client) CreateAsset(typ, identifier string, timestamp, expiration time.Time) (AssetResp, error)

CreateAsset creates an asset with the given type, identifier and expiration. It returns the the created asset.

func (Client) CreateTeam

func (cli Client) CreateTeam(identifier, name string) (TeamResp, error)

CreateTeam creates a team with the given identifier and name. It returns the the created team.

func (Client) Owners

func (cli Client) Owners(assetID string, pag Pagination) ([]OwnsResp, error)

Owners returns the "owns" relations of the asset with the provided ID. The pag parameter controls pagination.

func (Client) Parents

func (cli Client) Parents(assetID string, pag Pagination) ([]ParentOfResp, error)

Parents returns the "parent of" relations of the asset with the given ID. The pag parameter controls pagination.

func (Client) Teams

func (cli Client) Teams(identifier string, pag Pagination) ([]TeamResp, error)

Teams returns a list of teams filtered by identifier. If identifier is empty, no filter is applied. The pag parameter controls pagination.

func (Client) UpdateAsset

func (cli Client) UpdateAsset(id, typ, identifier string, timestamp, expiration time.Time) (AssetResp, error)

UpdateAsset updates an asset with a given ID. The type and the identifier must match the asset ID. This method will only update the time attributes of the asset if the corresponding parameter is not zero.

func (Client) UpdateTeam

func (cli Client) UpdateTeam(id, identifier, name string) (TeamResp, error)

UpdateTeam updates a team with a given ID. The identifier must match the asset ID.

func (Client) UpsertOwner

func (cli Client) UpsertOwner(assetID, teamID string, startTime, endTime time.Time) (OwnsResp, error)

UpsertOwner creates or updates the "owns" relation between the provided team and asset. If endTime is zero, it is ignored.

func (Client) UpsertParent

func (cli Client) UpsertParent(childID, parentID string, timestamp, expiration time.Time) (ParentOfResp, error)

UpsertParent creates or updates the "parent of" relation between the provided assets. If timestamp is zero, it is ignored.

type InvalidStatusError

type InvalidStatusError struct {
	Expected []int
	Returned int
}

InvalidStatusError is returned when a call to an endpoint of the Graph Asset Inventory did not return the expected status code.

func (InvalidStatusError) Error

func (w InvalidStatusError) Error() string

type OwnsReq

type OwnsReq struct {
	StartTime time.Time  `json:"start_time"`
	EndTime   *time.Time `json:"end_time,omitempty"`
}

OwnsReq represents the "OwnsReq" model as defined by the Graph Asset Inventory REST API.

type OwnsResp

type OwnsResp struct {
	ID        string     `json:"id"`
	TeamID    string     `json:"team_id"`
	AssetID   string     `json:"asset_id"`
	StartTime time.Time  `json:"start_time"`
	EndTime   *time.Time `json:"end_time,omitempty"`
}

OwnsResp represents the "OwnsResp" model as defined by the Graph Asset Inventory REST API.

type Pagination

type Pagination struct {
	Page int
	Size int
}

Pagination contains the pagination parameters. If the Size field is zero, pagination is disabled.

type ParentOfReq

type ParentOfReq struct {
	Timestamp  *time.Time `json:"timestamp,omitempty"`
	Expiration time.Time  `json:"expiration"`
}

ParentOfReq represents the "ParentOfReq" model as defined by the Graph Asset Inventory REST API.

type ParentOfResp

type ParentOfResp struct {
	ID         string    `json:"id"`
	ParentID   string    `json:"parent_id"`
	ChildID    string    `json:"child_id"`
	FirstSeen  time.Time `json:"first_seen"`
	LastSeen   time.Time `json:"last_seen"`
	Expiration time.Time `json:"expiration"`
}

ParentOfResp represents the "ParentOfResp" model as defined by the Graph Asset Inventory REST API.

type TeamReq

type TeamReq struct {
	Identifier string `json:"identifier"`
	Name       string `json:"name"`
}

TeamReq represents the "TeamReq" model as defined by the Graph Asset Inventory REST API.

type TeamResp

type TeamResp struct {
	ID         string `json:"id"`
	Identifier string `json:"identifier"`
	Name       string `json:"name"`
}

TeamResp represents the "TeamResp" model as defined by the Graph Asset Inventory REST API.

Jump to

Keyboard shortcuts

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