data

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "gitlab"
	Project    = "project"
	Group      = "group"
)
View Source
const (
	OrderAscending  = "asc"
	OrderDescending = "desc"
)

Variables

View Source
var Roles = map[int64]string{
	0:  "No access",
	10: "Guest",
	20: "Reporter",
	30: "Developer",
	40: "Maintainer",
	50: "Owner",
}
View Source
var RolesArray = []int64{0, 10, 20, 30, 40, 50}

Functions

func GetOffsetLinksForPGParams

func GetOffsetLinksForPGParams(r *http.Request, p pgdb.OffsetPageParams) *resources.Links

Types

type Link struct {
	Id   int64  `db:"id" structs:"-"`
	Link string `db:"link" structs:"link"`
}
type Links interface {
	New() Links

	Insert(link Link) error
	Delete() error
	Get() (*Link, error)
	Select() ([]Link, error)

	FilterByLinks(links ...string) Links
}

type ModulePayload

type ModulePayload struct {
	RequestId string `json:"request_id"`
	UserId    string `json:"user_id"`
	Action    string `json:"action"`

	//other fields that are required for module
	Type        string   `json:"type"`
	Link        string   `json:"link"`
	Links       []string `json:"links"`
	Username    string   `json:"username"`
	GitlabId    string   `json:"gitlab_id"`
	AccessLevel int64    `json:"access_level"`
}

type ModuleRequest

type ModuleRequest struct {
	ID            string    `db:"id" structs:"id"`
	UserID        int64     `db:"user_id" structs:"user_id"`
	Module        string    `db:"module" structs:"module"`
	Payload       string    `db:"payload" structs:"payload"`
	CreatedAt     time.Time `db:"created_at" structs:"created_at"`
	RequestStatus string    `db:"request_status" structs:"request_status"`
	Error         string    `db:"error" structs:"error"`
}

type OrderType

type OrderType string

OrderType - represents sorting order of the query

const (
	// OrderAsc - ascending order
	OrderAsc OrderType = "asc"
	// OrderDesc - descending order
	OrderDesc OrderType = "desc"
)

func (OrderType) Invert

func (o OrderType) Invert() OrderType

Invert - inverts order by

type Permission

type Permission struct {
	RequestId     string    `json:"request_id" db:"request_id" structs:"request_id"`
	UserId        *int64    `json:"user_id" db:"user_id" structs:"user_id"`
	Name          string    `json:"name" db:"name" structs:"name"`
	Username      string    `json:"username" db:"username" structs:"username"`
	GitlabId      int64     `json:"id" db:"gitlab_id" structs:"gitlab_id"`
	AccessLevel   int64     `json:"access_level" db:"access_level" structs:"access_level"`
	HasParent     bool      `json:"-" db:"has_parent" structs:"-"`
	HasChild      bool      `json:"-" db:"has_child" structs:"-"`
	Link          string    `json:"link" db:"link" structs:"link"`
	ParentLink    *string   `json:"-" db:"parent_link" structs:"parent_link"`
	Type          string    `json:"type" db:"type" structs:"type"`
	CreatedAt     time.Time `json:"created_at" db:"created_at" structs:"created_at"`
	UpdatedAt     time.Time `json:"updated_at" db:"updated_at" structs:"-"`
	ExpiresAt     time.Time `json:"-" db:"expires_at" structs:"expires_at"`
	ExpiresString string    `json:"expires_at" db:"-" structs:"-"`
	AvatarUrl     string    `json:"avatar_url" db:"-" structs:"-"`
}

type PermissionToUpdate

type PermissionToUpdate struct {
	Username    *string    `structs:"username,omitempty"`
	AccessLevel *int64     `structs:"access_level,omitempty"`
	UserId      *int64     `structs:"user_id,omitempty"`
	ParentLink  *string    `structs:"parent_link,omitempty"`
	HasParent   *bool      `structs:"has_parent,omitempty"`
	HasChild    *bool      `structs:"has_child,omitempty"`
	UpdatedAt   *time.Time `structs:"updated_at,omitempty"`
}

type Permissions

type Permissions interface {
	New() Permissions

	Upsert(permission Permission) error
	Update(permission PermissionToUpdate) error
	Delete() error
	Select() ([]Permission, error)
	Get() (*Permission, error)

	FilterByGitlabIds(gitlabIds ...int64) Permissions
	FilterByUsernames(usernames ...string) Permissions
	FilterByTypes(types ...string) Permissions
	FilterByLinks(links ...string) Permissions
	FilterByGreaterTime(time time.Time) Permissions
	FilterByLowerTime(time time.Time) Permissions
	FilterByParentLinks(parentLinks ...string) Permissions
	FilterByHasParent(hasParent bool) Permissions
}

type RequestParams

type RequestParams struct {
	Method  string
	Link    string
	Body    []byte
	Query   map[string]string
	Header  map[string]string
	Timeout time.Duration
}

type Response

type Response struct {
	ID        string          `json:"id" db:"id" structs:"id"`
	Status    string          `json:"status" db:"status" structs:"status"`
	Error     string          `json:"error" db:"error" structs:"error"`
	Payload   json.RawMessage `json:"payload" db:"payload" struct:"payload"`
	CreatedAt string          `json:"created_at" db:"created_at" structs:"-"`
}

type ResponseParams

type ResponseParams struct {
	Body       io.ReadCloser
	Header     http.Header
	StatusCode int
}

type Responses

type Responses interface {
	New() Responses

	Get() (*Response, error)
	Select() ([]Response, error)
	Insert(response Response) error
	Delete() error

	FilterByIds(ids ...string) Responses
}

type Sub

type Sub struct {
	Id          int64  `json:"id" db:"id" structs:"id"`
	Path        string `json:"path" db:"path" structs:"path"`
	Link        string `json:"link" db:"subs_link" structs:"link"`
	Type        string `json:"type" db:"subs_type" structs:"type"`
	ParentId    *int64 `json:"parent_id" db:"parent_id" structs:"parent_id"`
	*Permission `structs:",omitempty"`
}

type Subs

type Subs interface {
	New() Subs

	Insert(sub Sub) error
	Delete() error
	Select() ([]Sub, error)
	Get() (*Sub, error)

	FilterByLinks(links ...string) Subs
	FilterByTypes(types ...string) Subs
	FilterByIds(ids ...int64) Subs
	SearchBy(search string) Subs

	WithPermissions() Subs
	FilterByGitlabIds(gitlabIds ...int64) Subs
	FilterByParentLinks(parentLinks ...string) Subs
	FilterByParentIds(parentIds ...int64) Subs
	FilterByHasParent(hasParent bool) Subs
	FilterByUserIds(userIds ...int64) Subs
	FilterByUsernames(usernames ...string) Subs

	OrderBy(columns ...string) Subs

	Count() Subs
	CountWithPermissions() Subs
	GetTotalCount() (int64, error)

	Page(pageParams pgdb.OffsetPageParams) Subs
}

type UnverifiedPayload

type UnverifiedPayload struct {
	Action string           `json:"action"`
	Users  []UnverifiedUser `json:"users"`
}

type UnverifiedUser

type UnverifiedUser struct {
	CreatedAt time.Time `json:"created_at"`
	Module    string    `json:"module"`
	Submodule string    `json:"submodule"`
	ModuleId  string    `json:"module_id"`
	Email     *string   `json:"email,omitempty"`
	Name      *string   `json:"name,omitempty"`
	Phone     *string   `json:"phone,omitempty"`
	Username  *string   `json:"username,omitempty"`
}

type User

type User struct {
	Id             *int64    `json:"-" db:"id" structs:"id,omitempty"`
	GitlabUsername string    `json:"username" db:"username" structs:"username"`
	Name           string    `json:"name" db:"name" structs:"name"`
	GitlabId       int64     `json:"id" db:"gitlab_id" structs:"gitlab_id"`
	CreatedAt      time.Time `json:"created_at" db:"created_at" structs:"-"`
	UpdatedAt      time.Time `json:"updated_at" db:"updated_at" structs:"-"`
	AvatarUrl      string    `json:"avatar_url" db:"avatar_url" structs:"avatar_url"`
	Submodule      *string   `json:"-" db:"-" structs:"-"`
	AccessLevel    *string   `json:"-" db:"-" structs:"-"`
}

type Users

type Users interface {
	New() Users

	Upsert(user User) error
	Delete() error
	Select() ([]User, error)
	Get() (*User, error)

	FilterByLowerTime(time time.Time) Users
	FilterById(id *int64) Users
	FilterByUsernames(usernames ...string) Users
	FilterByGitlabIds(gitlabIds ...int64) Users
	SearchBy(search string) Users

	Count() Users
	GetTotalCount() (int64, error)

	Page(pageParams pgdb.OffsetPageParams) Users
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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