assetdb

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 4 Imported by: 5

README

asset-db

GoDoc License Contribute Yes

Chat on Discord Follow on Twitter

This repository offers services and repositories to interact with an asset database. It aims to foster the development of an ecosystem of scanning tools, allowing them to store assets (from open-asset-model and their relationships.

Contributing

If you have interest in contributing, please refer to the contributing doc

Documentation

Overview

Package assetdb provides a service to interacting with an asset database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetDB added in v0.1.1

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

AssetDB represents the asset database service.

func New

func New(dbType repository.DBType, dsn string) *AssetDB

New creates a new assetDB instance. It initializes the asset database with the specified database type and DSN.

func (*AssetDB) Create added in v0.1.1

func (as *AssetDB) Create(source *types.Asset, relation string, discovered oam.Asset) (*types.Asset, error)

Create creates a new asset in the database. If source is nil, the discovered asset will be created and relation will be ignored If source and relation are provided, the asset is created and linked to the source asset using the specified relation. It returns the newly created asset and an error, if any.

func (*AssetDB) DeleteAsset added in v0.2.0

func (as *AssetDB) DeleteAsset(id string) error

DeleteAsset removes an asset in the database by its ID.

func (*AssetDB) DeleteRelation added in v0.2.0

func (as *AssetDB) DeleteRelation(id string) error

DeleteRelation removes a relation in the database by its ID.

func (*AssetDB) FindByContent added in v0.1.1

func (as *AssetDB) FindByContent(asset oam.Asset, since time.Time) ([]*types.Asset, error)

FindByContent finds assets in the database based on their content and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns a list of matching assets and an error, if any.

func (*AssetDB) FindById added in v0.1.1

func (as *AssetDB) FindById(id string, since time.Time) (*types.Asset, error)

FindById finds an asset in the database by its ID and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching asset and an error, if any.

func (*AssetDB) FindByScope added in v0.2.0

func (as *AssetDB) FindByScope(constraints []oam.Asset, since time.Time) ([]*types.Asset, error)

FindByScope finds assets in the database by applying all the scope constraints provided and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching assets and an error, if any.

func (*AssetDB) FindByType added in v0.2.0

func (as *AssetDB) FindByType(atype oam.AssetType, since time.Time) ([]*types.Asset, error)

FindByType finds all assets in the database of the provided asset type and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching assets and an error, if any.

func (*AssetDB) IncomingRelations added in v0.1.1

func (as *AssetDB) IncomingRelations(asset *types.Asset, since time.Time, relationTypes ...string) ([]*types.Relation, error)

IncomingRelations finds all relations pointing to `asset“ for the specified `relationTypes`, if any. If since.IsZero(), the parameter will be ignored. If no `relationTypes` are specified, all incoming relations are returned.

func (*AssetDB) OutgoingRelations added in v0.1.1

func (as *AssetDB) OutgoingRelations(asset *types.Asset, since time.Time, relationTypes ...string) ([]*types.Relation, error)

OutgoingRelations finds all relations from `asset“ to another asset for the specified `relationTypes`, if any. If since.IsZero(), the parameter will be ignored. If no `relationTypes` are specified, all outgoing relations are returned.

Directories

Path Synopsis
migrations
postgres
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in Postgres.
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in Postgres.
sqlite3
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in SQLite3.
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in SQLite3.
Package repository provides a database repository implementation for managing assets and relations.
Package repository provides a database repository implementation for managing assets and relations.
Package types provides types that represent models in databases but are not tied to a specific database implementation.
Package types provides types that represent models in databases but are not tied to a specific database implementation.

Jump to

Keyboard shortcuts

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