data

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ModuleName             = "github"
	Organization           = "org"
	Repository             = "repo"
	UserOwned              = "User"
	OrganizationOwned      = "Organization"
	Push                   = "push"
	AcceptHeader           = "application/vnd.Github+json"
	GithubApiVersionHeader = "2022-11-28"
)
View Source
const (
	OrderAscending  = "asc"
	OrderDescending = "desc"
)

Variables

View Source
var Roles = map[string]string{
	"":         "No access",
	"read":     "Read",
	"triage":   "Triage",
	"write":    "Write",
	"maintain": "Maintain",
	"admin":    "Admin",
	"member":   "Member",
}

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"`
	Link        string   `json:"link"`
	Links       []string `json:"links"`
	Username    string   `json:"username"`
	AccessLevel string   `json:"access_level"`
	Type        string   `json:"type"`
}

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"`
	Username    string    `json:"login" db:"username" structs:"username"`
	GithubId    int64     `json:"id" db:"github_id" structs:"github_id"`
	AccessLevel string    `json:"role_name" 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"`
	Type        string    `json:"type" db:"type" structs:"type"`
	ParentLink  *string   `json:"-" db:"parent_link" structs:"parent_link"`
	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:"expires_at" db:"expires_at" structs:"expires_at"`
	AvatarUrl   string    `json:"avatar_url" db:"-" structs:"-"`
}

type PermissionToUpdate

type PermissionToUpdate struct {
	Username    *string    `structs:"username,omitempty"`
	AccessLevel *string    `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)

	FilterByGithubIds(githubIds ...int64) Permissions
	FilterByUsernames(usernames ...string) Permissions
	FilterByLinks(links ...string) Permissions
	FilterByTypes(types ...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" structs:"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:"name" db:"path" structs:"path"`
	Link        string `json:"full_name" 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

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

	FilterByParentLinks(parentLinks ...string) Subs
	FilterByParentIds(parentIds ...int64) Subs
	FilterByLinks(links ...string) Subs
	FilterByIds(ids ...int64) Subs
	SearchBy(search string) Subs

	WithPermissions() Subs
	FilterByGithubIds(githubIds ...int64) Subs
	FilterByUserIds(userIds ...int64) Subs
	FilterByUsernames(usernames ...string) Subs
	FilterByHasParent(level bool) 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    `db:"id" structs:"id,omitempty"`
	Username    string    `json:"login" db:"username" structs:"username"`
	GithubId    int64     `json:"id" db:"github_id" structs:"github_id"`
	AvatarUrl   string    `json:"avatar_url" db:"avatar_url" structs:"avatar_url"`
	CreatedAt   time.Time `json:"created_at" db:"created_at" structs:"-"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at" structs:"-"`
	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)

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

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

	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