postgres

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 31 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"
)

Variables

This section is empty.

Functions

This section is empty.

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) Create

TODO this is actually an upsert

func (ActionRepository) Get

func (ActionRepository) List

func (ActionRepository) Update

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:"10ms"`
	MaxQueryTimeout time.Duration `yaml:"max_query_timeout" mapstructure:"max_query_timeout" default:"100ms"`
}

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 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) Create

TODO this is actually an upsert

func (NamespaceRepository) Get

func (NamespaceRepository) List

func (NamespaceRepository) Update

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) Create

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

TODO this is actually upsert

func (PolicyRepository) Get

func (PolicyRepository) List

func (PolicyRepository) Update

func (r PolicyRepository) Update(ctx context.Context, toUpdate 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 ResourceRepository

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

func NewResourceRepository

func NewResourceRepository(dbc *db.Client) *ResourceRepository

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) List

func (ResourceRepository) Update

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) Create

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

TODO this is actually an upsert

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)

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) 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