postgres

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TABLE_ACTIONS           = "actions"
	TABLE_GROUPS            = "groups"
	TABLE_NAMESPACES        = "namespaces"
	TABLE_ORGANIZATIONS     = "organizations"
	TABLE_POLICIES          = "policies"
	TABLE_PROJECTS          = "projects"
	TABLE_RELATIONS         = "relations"
	TABLE_RESOURCES         = "resources"
	TABLE_ROLES             = "roles"
	TABLE_USERS             = "users"
	TABLE_METADATA          = "metadata"
	TABLE_METADATA_KEYS     = "metadata_keys"
	TABLE_ACTIVITY          = "activities"
	TABLE_SERVICE_DATA      = "servicedata"
	TABLE_SERVICE_DATA_KEYS = "servicedata_keys"
	TABLE_RULE_CONFIGS      = "rule_configs"
	TABLE_RESOURCE_CONFIGS  = "resource_configs"
)

Variables

This section is empty.

Functions

func GetAll added in v0.6.34

func GetAll(ctx context.Context) ([]resource.YAML, error)

Types

type Action

type Action struct {
	ID          string    `db:"id"`
	Name        string    `db:"name"`
	Namespace   Namespace `db:"namespace"`
	NamespaceID string    `db:"namespace_id"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

type ActionRepository

type ActionRepository struct {
	// contains filtered or unexported fields
}

func NewActionRepository

func NewActionRepository(dbc *db.Client) *ActionRepository

func (ActionRepository) Get

func (ActionRepository) List

func (ActionRepository) Update

func (ActionRepository) Upsert added in v0.6.25

type ActivityRepository added in v0.6.15

type ActivityRepository struct {
	// contains filtered or unexported fields
}

func NewActivityRepository added in v0.6.15

func NewActivityRepository(dbc *db.Client) *ActivityRepository

func (ActivityRepository) Insert added in v0.6.15

func (r ActivityRepository) Insert(ctx context.Context, log *audit.Log) error

func (ActivityRepository) List added in v0.6.17

func (r ActivityRepository) List(ctx context.Context, filter activity.Filter) ([]audit.Log, error)

type Config

type Config struct {
	Driver          string        `yaml:"driver" mapstructure:"driver"`
	URL             string        `yaml:"url" mapstructure:"url"`
	MaxIdleConns    int           `yaml:"max_idle_conns" mapstructure:"max_idle_conns" default:"10"`
	MaxOpenConns    int           `yaml:"max_open_conns" mapstructure:"max_open_conns" default:"10"`
	ConnMaxLifeTime time.Duration `yaml:"conn_max_life_time" mapstructure:"conn_max_life_time" default:"300s"`
	MaxQueryTimeout time.Duration `yaml:"max_query_timeout" mapstructure:"max_query_timeout" default:"1s"`
}

type Group

type Group struct {
	ID        string       `db:"id"`
	Name      string       `db:"name"`
	Slug      string       `db:"slug"`
	OrgID     string       `db:"org_id"`
	Metadata  []byte       `db:"metadata"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

type GroupRepository

type GroupRepository struct {
	// contains filtered or unexported fields
}

func NewGroupRepository

func NewGroupRepository(dbc *db.Client) *GroupRepository

func (GroupRepository) Create

func (r GroupRepository) Create(ctx context.Context, grp group.Group) (group.Group, error)

func (GroupRepository) GetByID

func (r GroupRepository) GetByID(ctx context.Context, id string) (group.Group, error)

func (GroupRepository) GetByIDs

func (r GroupRepository) GetByIDs(ctx context.Context, groupIDs []string) ([]group.Group, error)

func (GroupRepository) GetBySlug

func (r GroupRepository) GetBySlug(ctx context.Context, slug string) (group.Group, error)

func (GroupRepository) List

func (r GroupRepository) List(ctx context.Context, flt group.Filter) ([]group.Group, error)

func (GroupRepository) ListGroupRelations

func (r GroupRepository) ListGroupRelations(ctx context.Context, objectId string, subject_type string, role string) ([]relation.RelationV2, error)

func (GroupRepository) ListUserGroups

func (r GroupRepository) ListUserGroups(ctx context.Context, userID string, roleID string) ([]group.Group, error)

func (GroupRepository) UpdateByID

func (r GroupRepository) UpdateByID(ctx context.Context, grp group.Group) (group.Group, error)

func (GroupRepository) UpdateBySlug

func (r GroupRepository) UpdateBySlug(ctx context.Context, grp group.Group) (group.Group, error)

type Key added in v0.6.20

type Key struct {
	ID          string       `db:"id"`
	URN         string       `db:"urn"`
	ProjectID   string       `db:"project_id"`
	Name        string       `db:"name"`
	Description string       `db:"description"`
	ResourceID  string       `db:"resource_id"`
	CreatedAt   time.Time    `db:"created_at"`
	UpdatedAt   time.Time    `db:"updated_at"`
	DeletedAt   sql.NullTime `db:"deleted_at"`
}

type Namespace

type Namespace struct {
	ID           string       `db:"id"`
	Name         string       `db:"name"`
	Backend      string       `db:"backend"`
	ResourceType string       `db:"resource_type"`
	CreatedAt    time.Time    `db:"created_at"`
	UpdatedAt    time.Time    `db:"updated_at"`
	DeletedAt    sql.NullTime `db:"deleted_at"`
}

type NamespaceRepository

type NamespaceRepository struct {
	// contains filtered or unexported fields
}

func NewNamespaceRepository

func NewNamespaceRepository(dbc *db.Client) *NamespaceRepository

func (NamespaceRepository) Get

func (NamespaceRepository) List

func (NamespaceRepository) Update

func (NamespaceRepository) Upsert added in v0.6.25

type Organization

type Organization struct {
	ID        string       `db:"id"`
	Name      string       `db:"name"`
	Slug      string       `db:"slug"`
	Metadata  []byte       `db:"metadata"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

type OrganizationRepository

type OrganizationRepository struct {
	// contains filtered or unexported fields
}

func NewOrganizationRepository

func NewOrganizationRepository(dbc *db.Client) *OrganizationRepository

func (OrganizationRepository) Create

func (OrganizationRepository) GetByID

func (OrganizationRepository) GetBySlug

func (OrganizationRepository) List

func (OrganizationRepository) ListAdminsByOrgID

func (r OrganizationRepository) ListAdminsByOrgID(ctx context.Context, orgID string) ([]user.User, error)

func (OrganizationRepository) UpdateByID

func (OrganizationRepository) UpdateBySlug

type Policy

type Policy struct {
	ID          string         `db:"id"`
	Role        Role           `db:"role"`
	RoleID      string         `db:"role_id"`
	Namespace   Namespace      `db:"namespace"`
	NamespaceID string         `db:"namespace_id"`
	Action      Action         `db:"action"`
	ActionID    sql.NullString `db:"action_id"`
	CreatedAt   time.Time      `db:"created_at"`
	UpdatedAt   time.Time      `db:"updated_at"`
}

type PolicyCols

type PolicyCols struct {
	ID          string         `db:"id"`
	RoleID      string         `db:"role_id"`
	NamespaceID string         `db:"namespace_id"`
	ActionID    sql.NullString `db:"action_id"`
}

type PolicyRepository

type PolicyRepository struct {
	// contains filtered or unexported fields
}

func NewPolicyRepository

func NewPolicyRepository(dbc *db.Client) *PolicyRepository

func (PolicyRepository) Get

func (PolicyRepository) List

func (r PolicyRepository) List(ctx context.Context, filter policy.Filters) ([]policy.Policy, error)

func (PolicyRepository) Update

func (r PolicyRepository) Update(ctx context.Context, toUpdate *policy.Policy) (string, error)

func (PolicyRepository) Upsert added in v0.6.25

func (r PolicyRepository) Upsert(ctx context.Context, pol *policy.Policy) (string, error)

type Project

type Project struct {
	ID        string       `db:"id"`
	Name      string       `db:"name"`
	Slug      string       `db:"slug"`
	OrgID     string       `db:"org_id"`
	Metadata  []byte       `db:"metadata"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

type ProjectRepository

type ProjectRepository struct {
	// contains filtered or unexported fields
}

func NewProjectRepository

func NewProjectRepository(dbc *db.Client) *ProjectRepository

func (ProjectRepository) Create

func (ProjectRepository) GetByID

func (ProjectRepository) GetBySlug

func (r ProjectRepository) GetBySlug(ctx context.Context, slug string) (project.Project, error)

func (ProjectRepository) List

func (ProjectRepository) ListAdmins

func (r ProjectRepository) ListAdmins(ctx context.Context, projectID string) ([]user.User, error)

func (ProjectRepository) UpdateByID

func (ProjectRepository) UpdateBySlug

func (r ProjectRepository) UpdateBySlug(ctx context.Context, prj project.Project) (project.Project, error)

type Relation

type Relation struct {
	ID                 string       `db:"id"`
	SubjectNamespaceID string       `db:"subject_namespace_id"`
	SubjectNamespace   Namespace    `db:"subject_namespace"`
	SubjectID          string       `db:"subject_id"`
	ObjectNamespaceID  string       `db:"object_namespace_id"`
	ObjectNamespace    Namespace    `db:"object_namespace"`
	ObjectID           string       `db:"object_id"`
	RoleID             string       `db:"role_id"`
	Role               Role         `db:"role"`
	CreatedAt          time.Time    `db:"created_at"`
	UpdatedAt          time.Time    `db:"updated_at"`
	DeletedAt          sql.NullTime `db:"deleted_at"`
}

type RelationRepository

type RelationRepository struct {
	// contains filtered or unexported fields
}

func NewRelationRepository

func NewRelationRepository(dbc *db.Client) *RelationRepository

func (RelationRepository) Create

func (r RelationRepository) Create(ctx context.Context, relationToCreate relation.RelationV2) (relation.RelationV2, error)

func (RelationRepository) DeleteByID

func (r RelationRepository) DeleteByID(ctx context.Context, id string) error

func (RelationRepository) Get

func (RelationRepository) GetByFields

func (RelationRepository) List

func (RelationRepository) Update

Update TO_DEPRECIATE

type Resource

type Resource struct {
	ID             string         `db:"id"`
	URN            string         `db:"urn"`
	Name           string         `db:"name"`
	ProjectID      string         `db:"project_id"`
	Project        Project        `db:"project"`
	OrganizationID string         `db:"org_id"`
	Organization   Organization   `db:"organization"`
	NamespaceID    string         `db:"namespace_id"`
	Namespace      Namespace      `db:"namespace"`
	User           User           `db:"user"`
	UserID         sql.NullString `db:"user_id"`
	CreatedAt      time.Time      `db:"created_at"`
	UpdatedAt      time.Time      `db:"updated_at"`
	DeletedAt      sql.NullTime   `db:"deleted_at"`
}

type ResourceCols

type ResourceCols struct {
	ID             string         `db:"id"`
	URN            string         `db:"urn"`
	Name           string         `db:"name"`
	ProjectID      string         `db:"project_id"`
	OrganizationID string         `db:"org_id"`
	NamespaceID    string         `db:"namespace_id"`
	UserID         sql.NullString `db:"user_id"`
	CreatedAt      time.Time      `db:"created_at"`
	UpdatedAt      time.Time      `db:"updated_at"`
}

type ResourceConfig added in v0.6.34

type ResourceConfig struct {
	ID        uint32    `db:"id"`
	Name      string    `db:"name"`
	Config    string    `db:"config"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type ResourceRepository

type ResourceRepository struct {
	// contains filtered or unexported fields
}

func NewResourceRepository

func NewResourceRepository(dbc *db.Client) *ResourceRepository

func (*ResourceRepository) Commit added in v0.6.34

func (r *ResourceRepository) Commit(ctx context.Context) error

func (ResourceRepository) Create

func (ResourceRepository) GetByID

func (ResourceRepository) GetByNamespace

func (r ResourceRepository) GetByNamespace(ctx context.Context, name string, ns string) (resource.Resource, error)

func (ResourceRepository) GetByURN

func (ResourceRepository) GetSchema added in v0.6.34

func (ResourceRepository) List

func (*ResourceRepository) Rollback added in v0.6.34

func (r *ResourceRepository) Rollback(ctx context.Context, err error) error

func (ResourceRepository) Update

func (ResourceRepository) Upsert added in v0.6.21

func (ResourceRepository) UpsertConfig added in v0.6.34

func (*ResourceRepository) WithTransaction added in v0.6.34

func (r *ResourceRepository) WithTransaction(ctx context.Context) context.Context

type Role

type Role struct {
	ID          string         `db:"id"`
	Name        string         `db:"name"`
	Types       pq.StringArray `db:"types"`
	Namespace   Namespace      `db:"namespace"`
	NamespaceID string         `db:"namespace_id"`
	Metadata    []byte         `db:"metadata"`
	CreatedAt   time.Time      `db:"created_at"`
	UpdatedAt   time.Time      `db:"updated_at"`
}

type RoleRepository

type RoleRepository struct {
	// contains filtered or unexported fields
}

func NewRoleRepository

func NewRoleRepository(dbc *db.Client) *RoleRepository

func (RoleRepository) Get

func (r RoleRepository) Get(ctx context.Context, id string) (role.Role, error)

func (RoleRepository) List

func (r RoleRepository) List(ctx context.Context) ([]role.Role, error)

func (RoleRepository) Update

func (r RoleRepository) Update(ctx context.Context, rl role.Role) (string, error)

func (RoleRepository) Upsert added in v0.6.25

func (r RoleRepository) Upsert(ctx context.Context, rl role.Role) (string, error)

type RuleConfig added in v0.6.34

type RuleConfig struct {
	ID        uint32    `db:"id"`
	Name      string    `db:"name"`
	Config    string    `db:"config"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type RuleRepository added in v0.6.34

type RuleRepository struct {
	// contains filtered or unexported fields
}

func NewRuleRepository added in v0.6.34

func NewRuleRepository(dbc *db.Client) *RuleRepository

func (*RuleRepository) Commit added in v0.6.34

func (r *RuleRepository) Commit(ctx context.Context) error

func (*RuleRepository) GetAll added in v0.6.34

func (r *RuleRepository) GetAll(ctx context.Context) ([]rule.Ruleset, error)

func (*RuleRepository) InitCache added in v0.6.34

func (r *RuleRepository) InitCache(ctx context.Context) error

func (*RuleRepository) Rollback added in v0.6.34

func (r *RuleRepository) Rollback(ctx context.Context, err error) error

func (*RuleRepository) Upsert added in v0.6.34

func (r *RuleRepository) Upsert(ctx context.Context, name string, config rule.Ruleset) (rule.Config, error)

func (*RuleRepository) WithTransaction added in v0.6.34

func (r *RuleRepository) WithTransaction(ctx context.Context) context.Context

type ServiceData added in v0.6.22

type ServiceData struct {
	URN         string         `db:"urn"`
	NamespaceID string         `db:"namespace_id"`
	EntityID    string         `db:"entity_id"`
	Value       sql.NullString `db:"value"`
	KeyName     string         `db:"key"`
	ProjectID   string         `db:"project_id"`
	ResourceID  string         `db:"resource_id"`
}

type ServiceDataRepository added in v0.6.20

type ServiceDataRepository struct {
	// contains filtered or unexported fields
}

func NewServiceDataRepository added in v0.6.20

func NewServiceDataRepository(dbc *db.Client) *ServiceDataRepository

func (ServiceDataRepository) Commit added in v0.6.20

func (ServiceDataRepository) CreateKey added in v0.6.20

func (ServiceDataRepository) Get added in v0.6.22

func (ServiceDataRepository) GetKeyByURN added in v0.6.22

func (r ServiceDataRepository) GetKeyByURN(ctx context.Context, URN string) (servicedata.Key, error)

func (ServiceDataRepository) Rollback added in v0.6.20

func (r ServiceDataRepository) Rollback(ctx context.Context, err error) error

func (ServiceDataRepository) Upsert added in v0.6.22

func (ServiceDataRepository) WithTransaction added in v0.6.20

func (r ServiceDataRepository) WithTransaction(ctx context.Context) context.Context

type User

type User struct {
	ID        string       `db:"id"`
	Name      string       `db:"name"`
	Email     string       `db:"email"`
	Metadata  []byte       `db:"metadata"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

type UserMetadataKey

type UserMetadataKey struct {
	Key         string    `db:"key"`
	Description string    `db:"description"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(dbc *db.Client) *UserRepository

func (UserRepository) Create

func (r UserRepository) Create(ctx context.Context, usr user.User) (user.User, error)

func (UserRepository) CreateMetadataKey

func (r UserRepository) CreateMetadataKey(ctx context.Context, key user.UserMetadataKey) (user.UserMetadataKey, error)

func (UserRepository) DeleteByEmail added in v0.6.35

func (r UserRepository) DeleteByEmail(ctx context.Context, email string, emailTag string) error

func (UserRepository) DeleteByID added in v0.6.35

func (r UserRepository) DeleteByID(ctx context.Context, id string, emailTag string) error

func (UserRepository) GetByEmail

func (r UserRepository) GetByEmail(ctx context.Context, email string) (user.User, error)

func (UserRepository) GetByID

func (r UserRepository) GetByID(ctx context.Context, id string) (user.User, error)

func (UserRepository) GetByIDs

func (r UserRepository) GetByIDs(ctx context.Context, userIDs []string) ([]user.User, error)

func (UserRepository) List

func (r UserRepository) List(ctx context.Context, flt user.Filter) ([]user.User, error)

func (UserRepository) UpdateByEmail

func (r UserRepository) UpdateByEmail(ctx context.Context, usr user.User) (user.User, error)

func (UserRepository) UpdateByID

func (r UserRepository) UpdateByID(ctx context.Context, usr user.User) (user.User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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