Documentation ¶
Overview ¶
Package inventory allows to interact with the Graph Asset Inventory REST API.
Index ¶
- Variables
- type AssetReq
- type AssetResp
- type Client
- func (cli Client) Assets(typ, identifier string, validAt time.Time, pag Pagination) ([]AssetResp, error)
- func (cli Client) Children(assetID string, pag Pagination) ([]ParentOfResp, error)
- func (cli Client) CreateAsset(typ, identifier string, timestamp, expiration time.Time) (AssetResp, error)
- func (cli Client) CreateTeam(identifier, name string) (TeamResp, error)
- func (cli Client) Owners(assetID string, pag Pagination) ([]OwnsResp, error)
- func (cli Client) Parents(assetID string, pag Pagination) ([]ParentOfResp, error)
- func (cli Client) Teams(identifier string, pag Pagination) ([]TeamResp, error)
- func (cli Client) UpdateAsset(id, typ, identifier string, timestamp, expiration time.Time) (AssetResp, error)
- func (cli Client) UpdateTeam(id, identifier, name string) (TeamResp, error)
- func (cli Client) UpsertOwner(assetID, teamID string, startTime, endTime time.Time) (OwnsResp, error)
- func (cli Client) UpsertParent(childID, parentID string, timestamp, expiration time.Time) (ParentOfResp, error)
- type InvalidStatusError
- type OwnsReq
- type OwnsResp
- type Pagination
- type ParentOfReq
- type ParentOfResp
- type TeamReq
- type TeamResp
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.