model

package
v0.8.2-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	ID                 uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	ProviderID         uuid.UUID
	ResourceID         uuid.UUID
	ProviderActivityID string
	AccountType        string
	AccountID          string
	Timestamp          time.Time
	Authorizations     pq.StringArray `gorm:"type:text[]"`
	RelatedPermissions pq.StringArray `gorm:"type:text[]"`
	Type               string
	Metadata           datatypes.JSON
	CreatedAt          time.Time `gorm:"autoCreateTime"`

	Provider *Provider `gorm:"ForeignKey:ProviderID;References:ID"`
	Resource *Resource `gorm:"ForeignKey:ResourceID;References:ID"`
}

func (*Activity) FromDomain

func (m *Activity) FromDomain(a *domain.Activity) error

func (Activity) TableName

func (Activity) TableName() string

func (*Activity) ToDomain

func (m *Activity) ToDomain(a *domain.Activity) error

type Appeal

type Appeal struct {
	ID            uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	ResourceID    string
	PolicyID      string
	PolicyVersion uint
	Status        string
	AccountID     string
	AccountType   string
	CreatedBy     string
	Creator       datatypes.JSON
	Role          string
	Permissions   pq.StringArray `gorm:"type:text[]"`
	Options       datatypes.JSON
	Labels        datatypes.JSON
	Details       datatypes.JSON
	Description   string

	Resource  *Resource `gorm:"ForeignKey:ResourceID;References:ID"`
	Policy    Policy    `gorm:"ForeignKey:PolicyID,PolicyVersion;References:ID,Version"`
	Approvals []*Approval
	Grant     *Grant

	CreatedAt time.Time      `gorm:"autoCreateTime"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Appeal database model

func (*Appeal) FromDomain

func (m *Appeal) FromDomain(a *domain.Appeal) error

FromDomain transforms *domain.Appeal values into the model

func (*Appeal) ToDomain

func (m *Appeal) ToDomain() (*domain.Appeal, error)

ToDomain transforms model into *domain.Appeal

type Approval

type Approval struct {
	ID            uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Name          string    `gorm:"index"`
	Index         int
	AppealID      string
	Status        string
	Actor         *string
	Reason        string
	PolicyID      string
	PolicyVersion uint

	Approvers []Approver
	Appeal    *Appeal

	CreatedAt time.Time      `gorm:"autoCreateTime"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Approval database model

func (*Approval) FromDomain

func (m *Approval) FromDomain(a *domain.Approval) error

FromDomain transforms *domain.Approval values into the model

func (*Approval) ToDomain

func (m *Approval) ToDomain() (*domain.Approval, error)

ToDomain transforms model into *domain.Approval

type Approver

type Approver struct {
	ID         uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	ApprovalID string
	AppealID   string `gorm:"index"`
	Email      string `gorm:"index"`

	CreatedAt time.Time      `gorm:"autoCreateTime"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Approver database model

func (*Approver) FromDomain

func (m *Approver) FromDomain(a *domain.Approver) error

FromDomain transforms *domain.Approver values into the model

func (*Approver) ToDomain

func (m *Approver) ToDomain() *domain.Approver

ToDomain transforms model into *domain.Approver

type Grant

type Grant struct {
	ID                      uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Status                  string
	StatusInProvider        string
	AccountID               string
	AccountType             string
	ResourceID              string
	Role                    string
	Permissions             pq.StringArray `gorm:"type:text[]"`
	IsPermanent             bool
	ExpirationDate          time.Time
	RequestedExpirationDate sql.NullTime
	ExpirationDateReason    sql.NullString
	AppealID                sql.NullString
	Source                  string
	RevokedBy               string
	RevokedAt               time.Time
	RevokeReason            string
	Owner                   string
	CreatedAt               time.Time      `gorm:"autoCreateTime"`
	UpdatedAt               time.Time      `gorm:"autoUpdateTime"`
	DeletedAt               gorm.DeletedAt `gorm:"index"`

	Resource *Resource `gorm:"ForeignKey:ResourceID;References:ID"`
	Appeal   *Appeal   `gorm:"ForeignKey:AppealID;References:ID"`
}

func (*Grant) FromDomain

func (m *Grant) FromDomain(g domain.Grant) error

func (Grant) ToDomain

func (m Grant) ToDomain() (*domain.Grant, error)

type Policy

type Policy struct {
	ID           string `gorm:"primaryKey"`
	Version      uint   `gorm:"primaryKey"`
	Description  string
	Steps        datatypes.JSON
	AppealConfig datatypes.JSON
	Labels       datatypes.JSON
	Requirements datatypes.JSON
	IAM          datatypes.JSON
	CreatedAt    time.Time      `gorm:"autoCreateTime"`
	UpdatedAt    time.Time      `gorm:"autoUpdateTime"`
	DeletedAt    gorm.DeletedAt `gorm:"index"`
}

Policy is the database model for policy

func (*Policy) FromDomain

func (m *Policy) FromDomain(p *domain.Policy) error

FromDomain transforms *domain.Policy values into the model

func (Policy) TableName

func (Policy) TableName() string

TableName overrides the table name

func (*Policy) ToDomain

func (m *Policy) ToDomain() (*domain.Policy, error)

ToDomain transforms model into *domain.Policy

type Provider

type Provider struct {
	ID        uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Type      string    `gorm:"uniqueIndex:provider_index"`
	URN       string    `gorm:"uniqueIndex:provider_index"`
	Config    datatypes.JSON
	CreatedAt time.Time      `gorm:"autoCreateTime"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Provider is the database model for provider

func (*Provider) FromDomain

func (m *Provider) FromDomain(p *domain.Provider) error

FromDomain uses *domain.Provider values as the model values

func (Provider) TableName

func (Provider) TableName() string

TableName overrides the table name

func (*Provider) ToDomain

func (m *Provider) ToDomain() (*domain.Provider, error)

ToDomain transforms model into *domain.Provider

type Resource

type Resource struct {
	ID           uuid.UUID `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	ParentID     *string   `gorm:"type:uuid"`
	ProviderType string    `gorm:"uniqueIndex:resource_index"`
	ProviderURN  string    `gorm:"uniqueIndex:resource_index"`
	Type         string    `gorm:"uniqueIndex:resource_index"`
	URN          string    `gorm:"uniqueIndex:resource_index"`
	Name         string
	Details      datatypes.JSON
	Labels       datatypes.JSON
	GlobalURN    *string `gorm:"uniqueIndex:resource_global_urn"`

	Children []Resource `gorm:"ForeignKey:ParentID;References:ID"`
	Provider Provider   `gorm:"ForeignKey:ProviderType,ProviderURN;References:Type,URN"`

	CreatedAt time.Time      `gorm:"autoCreateTime"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
	IsDeleted bool
}

Resource is the database model for resource

func (*Resource) BeforeCreate

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

func (*Resource) FromDomain

func (m *Resource) FromDomain(r *domain.Resource) error

FromDomain uses *domain.Resource values as the model values

func (Resource) TableName

func (Resource) TableName() string

TableName overrides the table name

func (*Resource) ToDomain

func (m *Resource) ToDomain() (*domain.Resource, error)

ToDomain transforms model into *domain.Provider

Jump to

Keyboard shortcuts

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