Documentation
¶
Index ¶
- Variables
- type Asset
- type AssetSource
- type AssetSummary
- type AssetTypeSummary
- type AvailableFilters
- type CreateInput
- type Environment
- type ExternalLink
- type Filter
- type ListResult
- type Logger
- type MetadataContext
- type MetadataFieldSuggestion
- type MetadataValueSuggestion
- type MetricsClient
- type PostgresRepository
- func (r *PostgresRepository) Create(ctx context.Context, asset *Asset) error
- func (r *PostgresRepository) Delete(ctx context.Context, id string) error
- func (r *PostgresRepository) Get(ctx context.Context, id string) (*Asset, error)
- func (r *PostgresRepository) GetByMRN(ctx context.Context, qualifiedName string) (*Asset, error)
- func (r *PostgresRepository) GetByMRNs(ctx context.Context, mrns []string) ([]*Asset, error)
- func (r *PostgresRepository) GetByTypeAndName(ctx context.Context, assetType, name string) (*Asset, error)
- func (r *PostgresRepository) GetMetadataFields(ctx context.Context) ([]MetadataFieldSuggestion, error)
- func (r *PostgresRepository) GetMetadataFieldsWithContext(ctx context.Context, queryContext *MetadataContext) ([]MetadataFieldSuggestion, error)
- func (r *PostgresRepository) GetMetadataValues(ctx context.Context, field string, prefix string, limit int) ([]MetadataValueSuggestion, error)
- func (r *PostgresRepository) GetMetadataValuesWithContext(ctx context.Context, field string, prefix string, limit int, ...) ([]MetadataValueSuggestion, error)
- func (r *PostgresRepository) GetTagSuggestions(ctx context.Context, prefix string, limit int) ([]string, error)
- func (r *PostgresRepository) List(ctx context.Context, offset, limit int) (*ListResult, error)
- func (r *PostgresRepository) ListByPattern(ctx context.Context, pattern string, assetType string) ([]*Asset, error)
- func (r *PostgresRepository) Search(ctx context.Context, filter SearchFilter, calculateCounts bool) ([]*Asset, int, AvailableFilters, error)
- func (r *PostgresRepository) Summary(ctx context.Context) (*AssetSummary, error)
- func (r *PostgresRepository) Update(ctx context.Context, asset *Asset) error
- type Repository
- type SearchFilter
- type Service
- type ServiceOption
- type UpdateInput
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
ID string `json:"id,omitempty"`
ParentMRN *string `json:"parent_mrn,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Type string `json:"type"`
Providers []string `json:"providers"`
MRN *string `json:"mrn,omitempty"`
Schema map[string]string `json:"schema,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Sources []AssetSource `json:"sources,omitempty"`
Tags []string `json:"tags,omitempty"`
Environments map[string]Environment `json:"environments,omitempty"`
ExternalLinks []ExternalLink `json:"external_links,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
LastSyncAt time.Time `json:"last_sync_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
}
type AssetSource ¶
type AssetSource struct {
Name string `json:"name"`
LastSyncAt time.Time `json:"last_sync_at"`
Properties map[string]interface{} `json:"properties"`
Priority int `json:"priority"`
}
func UpdateSources ¶
func UpdateSources(existing, new []AssetSource) []AssetSource
type AssetSummary ¶
type AssetTypeSummary ¶
type AvailableFilters ¶
type CreateInput ¶
type CreateInput struct {
Name *string `json:"name" validate:"required"`
MRN *string `json:"mrn" validate:"required"`
Type string `json:"type" validate:"required"`
Providers []string `json:"providers" validate:"required"`
Description *string `json:"description"`
Metadata map[string]interface{} `json:"metadata"`
Schema map[string]string `json:"schema"`
Tags []string `json:"tags"`
CreatedBy string `json:"created_by" validate:"required"`
Sources []AssetSource `json:"sources"`
Environments map[string]Environment `json:"environments"`
ExternalLinks []ExternalLink `json:"external_links"`
}
type Environment ¶
type ExternalLink ¶
type Filter ¶
type Filter struct {
Types []string `json:"types,omitempty"`
Providers []string `json:"providers,omitempty"`
Tags []string `json:"tags,omitempty"`
ParentMRN *string `json:"parent_mrn,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
UpdatedAfter *time.Time `json:"updated_after,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Environment *string `json:"environment,omitempty"`
}
type ListResult ¶
type ListResult struct {
Assets []*Asset
Total int
Filters AvailableFilters
}
type MetadataContext ¶
type MetadataFieldSuggestion ¶
type MetadataFieldSuggestion struct {
Field string `json:"field"`
Type string `json:"type"`
Count int `json:"count"`
Example interface{} `json:"example"`
PathParts []string `json:"path_parts"`
Types []string `json:"types"`
}
MetadataFieldSuggestion represents a suggestion for a metadata field
type MetadataValueSuggestion ¶
type MetadataValueSuggestion struct {
Value string `json:"value"`
Count int `json:"count"`
Example *Asset `json:"example,omitempty"`
}
MetadataValueSuggestion represents a suggestion for a metadata field value
type MetricsClient ¶
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(ctx context.Context, asset *Asset) error
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(ctx context.Context, id string) error
func (*PostgresRepository) GetByTypeAndName ¶
func (*PostgresRepository) GetMetadataFields ¶
func (r *PostgresRepository) GetMetadataFields(ctx context.Context) ([]MetadataFieldSuggestion, error)
func (*PostgresRepository) GetMetadataFieldsWithContext ¶
func (r *PostgresRepository) GetMetadataFieldsWithContext(ctx context.Context, queryContext *MetadataContext) ([]MetadataFieldSuggestion, error)
func (*PostgresRepository) GetMetadataValues ¶
func (r *PostgresRepository) GetMetadataValues(ctx context.Context, field string, prefix string, limit int) ([]MetadataValueSuggestion, error)
func (*PostgresRepository) GetMetadataValuesWithContext ¶
func (r *PostgresRepository) GetMetadataValuesWithContext(ctx context.Context, field string, prefix string, limit int, queryContext *MetadataContext) ([]MetadataValueSuggestion, error)
func (*PostgresRepository) GetTagSuggestions ¶
func (*PostgresRepository) List ¶
func (r *PostgresRepository) List(ctx context.Context, offset, limit int) (*ListResult, error)
func (*PostgresRepository) ListByPattern ¶
func (*PostgresRepository) Search ¶
func (r *PostgresRepository) Search(ctx context.Context, filter SearchFilter, calculateCounts bool) ([]*Asset, int, AvailableFilters, error)
This makes me want to cry, but it works and I'm too scared to touch it. Eventually this should be broken into smaller, more readable functions and DB transactions
func (*PostgresRepository) Summary ¶
func (r *PostgresRepository) Summary(ctx context.Context) (*AssetSummary, error)
type Repository ¶
type Repository interface {
Create(ctx context.Context, asset *Asset) error
Get(ctx context.Context, id string) (*Asset, error)
GetByMRN(ctx context.Context, qualifiedName string) (*Asset, error)
List(ctx context.Context, offset, limit int) (*ListResult, error)
Search(ctx context.Context, filter SearchFilter, calculateCounts bool) ([]*Asset, int, AvailableFilters, error)
Summary(ctx context.Context) (*AssetSummary, error)
Update(ctx context.Context, asset *Asset) error
Delete(ctx context.Context, id string) error
ListByPattern(ctx context.Context, pattern string, assetType string) ([]*Asset, error)
GetByMRNs(ctx context.Context, mrns []string) ([]*Asset, error)
GetByTypeAndName(ctx context.Context, assetType, name string) (*Asset, error)
GetMetadataFieldsWithContext(ctx context.Context, queryContext *MetadataContext) ([]MetadataFieldSuggestion, error)
GetMetadataValuesWithContext(ctx context.Context, field string, prefix string, limit int, queryContext *MetadataContext) ([]MetadataValueSuggestion, error)
GetMetadataFields(ctx context.Context) ([]MetadataFieldSuggestion, error)
GetMetadataValues(ctx context.Context, field string, prefix string, limit int) ([]MetadataValueSuggestion, error)
GetTagSuggestions(ctx context.Context, prefix string, limit int) ([]string, error)
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *pgxpool.Pool) Repository
type SearchFilter ¶
type SearchFilter struct {
Query string `json:"query" validate:"omitempty"`
Types []string `json:"types" validate:"omitempty"`
Providers []string `json:"providers" validate:"omitempty"`
Tags []string `json:"tags" validate:"omitempty"`
Limit int `json:"limit" validate:"omitempty,gte=0"`
Offset int `json:"offset" validate:"omitempty,gte=0"`
}
type Service ¶
type Service interface {
Create(ctx context.Context, input CreateInput) (*Asset, error)
Get(ctx context.Context, id string) (*Asset, error)
GetByMRN(ctx context.Context, qualifiedName string) (*Asset, error)
List(ctx context.Context, offset, limit int) (*ListResult, error)
Search(ctx context.Context, filter SearchFilter, calculateCounts bool) ([]*Asset, int, AvailableFilters, error)
Summary(ctx context.Context) (*AssetSummary, error)
Update(ctx context.Context, id string, input UpdateInput) (*Asset, error)
Delete(ctx context.Context, id string) error
AddTag(ctx context.Context, id string, tag string) (*Asset, error)
RemoveTag(ctx context.Context, id string, tag string) (*Asset, error)
ListByPattern(ctx context.Context, pattern string, assetType string) ([]*Asset, error)
GetByMRNs(ctx context.Context, mrns []string) (map[string]*Asset, error)
GetByTypeAndName(ctx context.Context, assetType, name string) (*Asset, error)
GetMetadataFields(ctx context.Context, queryContext *MetadataContext) ([]MetadataFieldSuggestion, error)
GetMetadataValues(ctx context.Context, field string, prefix string, limit int, queryContext *MetadataContext) ([]MetadataValueSuggestion, error)
GetTagSuggestions(ctx context.Context, prefix string, limit int) ([]string, error)
}
func NewService ¶
func NewService(repo Repository, opts ...ServiceOption) Service
type ServiceOption ¶
type ServiceOption func(*service)
func WithMetrics ¶
func WithMetrics(metrics MetricsClient) ServiceOption
type UpdateInput ¶
type UpdateInput struct {
Name *string `json:"name"`
Description *string `json:"description"`
Metadata map[string]interface{} `json:"metadata"`
Type string `json:"type"`
Providers []string `json:"providers"`
Schema map[string]string `json:"schema"`
Tags []string `json:"tags"`
Sources []AssetSource `json:"sources"`
Environments map[string]Environment `json:"environments"`
ExternalLinks []ExternalLink `json:"external_links"`
}
Click to show internal directories.
Click to hide internal directories.