model

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EngineStatusFetching = "fetching"
	EngineStatusSuccess  = "success"
	EngineStatusFailed   = "failed"
)
View Source
const NotNullValue = "(not null)"

NullValue used in a query, means that the resource should have this field defined

View Source
const NullValue = "(null)"

NullValue used in a query, means that the resource should not have this field defined

Variables

This section is empty.

Functions

This section is empty.

Types

type EngineStatus added in v0.0.10

type EngineStatus struct {
	ResourceType string    `json:"resourceType" gorm:"primaryKey"`
	ErrorMessage string    `json:"errorMessage"`
	Status       string    `json:"status"`
	FetchedAt    time.Time `json:"fetchedAt"`
}

func NewEngineStatus added in v0.0.10

func NewEngineStatus(status string, resource string, err error) EngineStatus

type Field added in v0.0.10

type Field struct {
	Name   string      `json:"name"`
	Count  int         `json:"count"`
	Values FieldValues `json:"values"`
}

Field is a searchable attribute on a resource. It also includes the possible values and their respective count.

type FieldGroup added in v0.0.10

type FieldGroup struct {
	Name   string `json:"name"`
	Fields Fields `json:"fields"`
}

FieldGroup regroups some fields. Ex: "Tags"

type FieldGroups added in v0.0.10

type FieldGroups []FieldGroup

func (FieldGroups) AddNullValues added in v0.0.10

func (fgs FieldGroups) AddNullValues() FieldGroups

AddNullValues adds the (null) value for each Field, it is used by the API to allow filtering on resources without the field. If a field is always defined (ex: type), do not include the (null) value as it would mean excluding all resources from a query.

func (FieldGroups) FindField added in v0.0.10

func (fgs FieldGroups) FindField(group string, name string) *Field

func (FieldGroups) FindGroup added in v0.0.10

func (fgs FieldGroups) FindGroup(group string) *FieldGroup

type FieldValue added in v0.0.10

type FieldValue struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

FieldValue is a value associated with a field. The count is the number of resources with this field value.

type FieldValues added in v0.0.10

type FieldValues []FieldValue

type Fields added in v0.0.10

type Fields []Field

type Resource

type Resource struct {
	Id        string         `json:"id" gorm:"primaryKey"`
	Region    string         `json:"region"`
	Type      string         `json:"type"`
	Tags      Tags           `json:"tags"`
	RawData   datatypes.JSON `json:"rawData"`
	UpdatedAt time.Time      `json:"updatedAt"`
}

TODO store provider info in resource (needed when we can have more than one provider)

func (Resource) MarshalLogObject added in v0.0.3

func (r Resource) MarshalLogObject(enc zapcore.ObjectEncoder) error

type ResourceId added in v0.0.10

type ResourceId string

type Resources added in v0.0.3

type Resources []*Resource

func (Resources) Clean added in v0.0.10

func (rs Resources) Clean() Resources

Clean removes the generated fields - useful for testing where the same instance is reused

func (Resources) FindById added in v0.0.3

func (rs Resources) FindById(id string) *Resource

FindById finds a resource by ID, return nil if not found

func (Resources) Ids added in v0.0.10

func (rs Resources) Ids() []ResourceId

type ResourcesResponse added in v0.0.10

type ResourcesResponse struct {
	Count     int       `json:"count"`
	Resources Resources `json:"resources"`
}

type Stats added in v0.0.3

type Stats struct {
	ResourcesCount int `json:"resourcesCount"`
}

type Tag

type Tag struct {
	ResourceId string `json:"-" gorm:"primaryKey"`
	Key        string `json:"key" gorm:"primaryKey"`
	Value      string `json:"value"`
}

func (Tag) MarshalLogObject added in v0.0.3

func (t Tag) MarshalLogObject(enc zapcore.ObjectEncoder) error

type Tags added in v0.0.3

type Tags []Tag

func (Tags) Add added in v0.0.10

func (t Tags) Add(key string, value string) Tags

func (Tags) Clean added in v0.0.3

func (t Tags) Clean() Tags

func (Tags) Delete added in v0.0.10

func (t Tags) Delete(key string) Tags

Delete deletes a tag from the list by it's key

func (Tags) Empty added in v0.0.3

func (t Tags) Empty() bool

func (Tags) Find added in v0.0.10

func (t Tags) Find(key string) *Tag

func (Tags) MarshalLogArray added in v0.0.3

func (t Tags) MarshalLogArray(enc zapcore.ArrayEncoder) error

Jump to

Keyboard shortcuts

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