model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//FieldMissing used in a query, means that the resource should not have this field defined
	FieldMissing = "(missing)"
	//NullValue used in a query, means that the resource should have this field defined
	FieldPresent = "(not null)"

	//CountValueIgnored means that the current value is ignored in the current query
	CountValueIgnored = "-"

	//name of the field groups as shown in API
	FieldGroupCore = "core"
	FieldGroupTags = "tags"

	//event status as shown in API
	EventStatusFetching string = "fetching"
	EventStatusFailed   string = "failed"
	EventStatusSuccess  string = "success"
	EventStatusLoaded   string = "loaded"

	//event type as shown in API
	EventTypeEngine   string = "engine"
	EventTypeProvider string = "provider"
	EventTypeResource string = "resource"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.0.11

type Event struct {
	Id           int64     `json:"-" gorm:"primaryKey;autoIncrement"`
	RunId        string    `json:"runId"`
	Type         string    `json:"eventType"`
	Status       string    `json:"status"`
	ProviderName string    `json:"providerName,omitempty"`
	ResourceType string    `json:"resourceType,omitempty"`
	Error        string    `json:"error"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
	ChildEvents  Events    `json:"childEvents" gorm:"-"`
}

func NewEngineEventEnd added in v0.0.11

func NewEngineEventEnd(err error) Event

func NewEngineEventStart added in v0.0.11

func NewEngineEventStart() Event

func NewProviderEventEnd added in v0.0.11

func NewProviderEventEnd(providerName string, err error) Event

func NewProviderEventStart added in v0.0.11

func NewProviderEventStart(providerName string) Event

func NewResourceEventEnd added in v0.0.11

func NewResourceEventEnd(providerName string, resourceType string, err error) Event

func NewResourceEventStart added in v0.0.11

func NewResourceEventStart(providerName string, resourceType string) Event

type Events added in v0.0.11

type Events []Event

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 (missing) 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 (missing) 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 string `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

func (FieldValues) Count added in v0.0.11

func (fv FieldValues) Count() int

func (*FieldValues) Find added in v0.0.11

func (fv *FieldValues) Find(value string) *FieldValue

type Fields added in v0.0.10

type Fields []*Field

type Resource

type Resource struct {
	Id        string         `json:"id" gorm:"primaryKey"`
	DisplayId string         `json:"displayId"`
	AccountId string         `json:"accountId"`
	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) EffectiveDisplayId added in v0.2.0

func (r Resource) EffectiveDisplayId() string

EffectiveDisplayId returns the ID displayed to the user, which is the DisplayId if set, else the Id

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

func ResourceIds added in v0.0.29

func ResourceIds(resources []*Resource) []ResourceId

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"`
	FieldGroups FieldGroups `json:"fieldGroups"`
	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