model

package
v0.0.0-...-feb181f Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GormDBDataType

func GormDBDataType(db *gorm.DB, field *schema.Field) string

func Scan

func Scan(value interface{}, data interface{}) error

Types

type GormDbAfterMigrationHook

type GormDbAfterMigrationHook interface {
	GormDbAfterMigration(*gorm.DB, *schema.Schema) error
}

type JsonObject

type JsonObject map[string]interface{}

func (JsonObject) GormDBDataType

func (JsonObject) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*JsonObject) Scan

func (data *JsonObject) Scan(value interface{}) error

func (JsonObject) Value

func (data JsonObject) Value() (driver.Value, error)

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Labels

type Labels []Label

func (Labels) GormDBDataType

func (Labels) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*Labels) Scan

func (data *Labels) Scan(value interface{}) error

func (Labels) Value

func (data Labels) Value() (driver.Value, error)

type LocalInventoryToResource

type LocalInventoryToResource struct {
	// Our local resource id
	ResourceId uuid.UUID  `gorm:"type:uuid;primarykey"`
	CreatedAt  *time.Time `gorm:"index"`

	ReporterResourceId
}

func (*LocalInventoryToResource) BeforeCreate

func (r *LocalInventoryToResource) BeforeCreate(db *gorm.DB) error

type OperationType

type OperationType string
const (
	OperationTypeCreate OperationType = "CREATE"
	OperationTypeUpdate OperationType = "UPDATE"
	OperationTypeDelete OperationType = "DELETE"
)

func (*OperationType) Scan

func (o *OperationType) Scan(value interface{}) error

func (OperationType) Value

func (o OperationType) Value() (driver.Value, error)

type Relationship

type Relationship struct {
	ID               uuid.UUID `gorm:"type:uuid;primarykey"`
	OrgId            string    `gorm:"index"`
	RelationshipData JsonObject
	RelationshipType string
	SubjectId        uuid.UUID `gorm:"type:uuid;index;not null"`
	ObjectId         uuid.UUID `gorm:"type:uuid;index;not null"`
	Reporter         RelationshipReporter
	CreatedAt        *time.Time
	UpdatedAt        *time.Time

	// Used to create FKs
	Subject Resource `gorm:"foreignKey:SubjectId"`
	Object  Resource `gorm:"foreignKey:ObjectId"`
}

func (*Relationship) BeforeCreate

func (r *Relationship) BeforeCreate(db *gorm.DB) error

type RelationshipHistory

type RelationshipHistory struct {
	ID               uuid.UUID `gorm:"type:uuid;primarykey"`
	OrgId            string    `gorm:"index"`
	RelationshipData JsonObject
	RelationshipType string
	SubjectId        uuid.UUID `gorm:"type:uuid;index"`
	ObjectId         uuid.UUID `gorm:"type:uuid;index"`
	Reporter         RelationshipReporter
	Timestamp        *time.Time `gorm:"autoCreateTime"`

	RelationshipId uuid.UUID     `gorm:"type:uuid;index"`
	OperationType  OperationType `gorm:"index"`
}

func (*RelationshipHistory) BeforeCreate

func (r *RelationshipHistory) BeforeCreate(db *gorm.DB) error

func (*RelationshipHistory) TableName

func (*RelationshipHistory) TableName() string

type RelationshipReporter

type RelationshipReporter struct {
	Reporter
	SubjectLocalResourceId string `json:"subject_local_resource_id"`
	SubjectResourceType    string `json:"subject_resource_type"`
	ObjectLocalResourceId  string `json:"object_local_resource_id"`
	ObjectResourceType     string `json:"object_resource_type"`
}

func (RelationshipReporter) GormDBDataType

func (RelationshipReporter) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*RelationshipReporter) Scan

func (data *RelationshipReporter) Scan(value interface{}) error

func (RelationshipReporter) Value

func (data RelationshipReporter) Value() (driver.Value, error)

type Reporter

type Reporter struct {
	ReporterId      string `json:"reporter_id"`
	ReporterType    string `json:"reporter_type"`
	ReporterVersion string `json:"reporter_version"`
}

type ReporterRelationshipId

type ReporterRelationshipId struct {
	// Reporter identification
	ReporterId   string
	ReporterType string

	// Relationship data
	RelationshipType string

	ObjectId  ReporterResourceId
	SubjectId ReporterResourceId
}

func ReporterRelationshipIdFromRelationship

func ReporterRelationshipIdFromRelationship(relationship *Relationship) ReporterRelationshipId

type ReporterResourceId

type ReporterResourceId struct {
	// Id in reporter's side
	LocalResourceId string `gorm:"primarykey"`
	ResourceType    string `gorm:"primarykey"`

	// Reporter identification
	ReporterId   string `gorm:"primarykey"`
	ReporterType string `gorm:"primarykey"`
}

func ReporterResourceIdFromResource

func ReporterResourceIdFromResource(resource *Resource) ReporterResourceId

type Resource

type Resource struct {
	ID           uuid.UUID `gorm:"type:uuid;primarykey"`
	OrgId        string    `gorm:"index"`
	ResourceData JsonObject
	ResourceType string
	WorkspaceId  string
	Reporter     ResourceReporter
	ConsoleHref  string
	ApiHref      string
	Labels       Labels
	CreatedAt    *time.Time
	UpdatedAt    *time.Time
}

func (*Resource) BeforeCreate

func (r *Resource) BeforeCreate(db *gorm.DB) error

func (*Resource) GormDbAfterMigration

func (r *Resource) GormDbAfterMigration(db *gorm.DB, s *schema.Schema) error

type ResourceHistory

type ResourceHistory struct {
	ID           uuid.UUID `gorm:"type:uuid;primarykey"`
	OrgId        string    `gorm:"index"`
	ResourceData JsonObject
	ResourceType string
	WorkspaceId  string
	Reporter     ResourceReporter
	ConsoleHref  string
	ApiHref      string
	Labels       Labels
	Timestamp    *time.Time `gorm:"autoCreateTime"`

	ResourceId    uuid.UUID     `gorm:"type:uuid;index"`
	OperationType OperationType `gorm:"index"`
}

func (*ResourceHistory) BeforeCreate

func (r *ResourceHistory) BeforeCreate(db *gorm.DB) error

func (*ResourceHistory) ResourceHistory

func (r *ResourceHistory) ResourceHistory(db *gorm.DB, s *schema.Schema) error

func (*ResourceHistory) TableName

func (*ResourceHistory) TableName() string

type ResourceReporter

type ResourceReporter struct {
	Reporter
	LocalResourceId string `json:"local_resource_id"`
}

func (ResourceReporter) GormDBDataType

func (ResourceReporter) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*ResourceReporter) Scan

func (data *ResourceReporter) Scan(value interface{}) error

func (ResourceReporter) Value

func (data ResourceReporter) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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