structs

package
v0.0.0-...-a9e2aaa Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMe

type APIMe struct {
	Authenticated bool             `json:"authenticated"`
	User          *User            `json:"user"`
	Projects      []PartialProject `json:"projects"`
}

APIMe is the structure of the /api/me endpoint.

type APIProject

type APIProject struct {
	Project      *Project              `json:"project"`
	Elevated     bool                  `json:"elevated"`
	Contributors map[int64]PartialUser `json:"contributors"`
}

APIProject is the structure of the GET /api/project/{id} endpoint.

type APIProjectExecutor

type APIProjectExecutor struct {
	Issues      []IssueEntry `json:"issues"`
	Unavailable []int64      `json:"unavailable"`
	Project     *Project     `json:"project"`
}

APIProjectExecutor is the structure of the POST /api/project/{id}/execute endpoint.

type APIProjectInviteGet

type APIProjectInviteGet struct {
	ValidInvite bool   `json:"valid_invite"`
	ProjectName string `json:"project_name"`
}

APIProjectInviteGet is the structure of the GET /api/project/{id}/invite/{code}

type APIProjectIssueComments

type APIProjectIssueComments struct {
	Page     int       `json:"page"`
	Comments []Comment `json:"comments"`
	End      bool      `json:"end"`
}

APIProjectIssueComments is the structure of the GET /api/project/{id}/issues/{issue_id}/comments endpoint.

type APIProjectIssueCreate

type APIProjectIssueCreate struct {
	New   bool        `json:"new"`
	Issue *IssueEntry `json:"issue"`
}

APIProjectIssueCreate is the structure of the POST /api/project/{id}/issues endpoint.

type APIProjectIssues

type APIProjectIssues struct {
	Page        int          `json:"page"`
	TotalIssues int          `json:"total_issues"`
	Issues      []IssueEntry `json:"issues,omitempty"`
	Issue       *IssueEntry  `json:"issue,omitempty"`
}

APIProjectIssues is the structure of the GET /api/project/{id}/issues endpoint.

type APIProjectLazy

type APIProjectLazy struct {
	Users map[int64]PartialUser `json:"users"`
	IDs   []int64               `json:"ids,omitempty"`
}

APIProjectLazy is the structure of the GET /api/project/{id}/lazy endpoint and /api/project/{id}/contributors.

type APIProjectUpdate

type APIProjectUpdate struct {
	Settings ProjectSettings `json:"settings"`
}

APIProjectUpdate is the structure of the POST /api/project/{id}.

type ActionType

type ActionType uint8

ActionType signifies the action type of a task.

const (
	// ActionStar signifies the issue will be starred/un-starred.
	ActionStar ActionType = iota
	// ActionAssign signifies that someone is being assigned/unassigned.
	ActionAssign
	// ActionLockComments signifies the comments for an issue is about
	// to be locked/unlocked.
	ActionLockComments
	// ActionMarkStatus signifies the status of an issue is changing.
	ActionMarkStatus
)

func ParseActionType

func ParseActionType(actionTypeStr string) (ActionType, error)

ParseActionType converts a response string into a ActionType value. Returns an error if the input string does not match known values.

type BaseResponse

type BaseResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
}

BaseResponse is the structure of all REST requests.

type Comment

type Comment struct {
	ID      int64 `json:"id"`
	IssueID int64 `json:"issue_id"`

	CreatedAt   time.Time `json:"created_at" pg:"default:now()"`
	CreatedBy   *User     `json:"created_by,omitempty" pg:"rel:has-one"`
	CreatedByID int64     `json:"created_by_id" pg:",use_zero"`

	Type           ContentType `json:"type"`
	Content        *string     `json:"content,omitempty"`
	IssueMarked    *EntryType  `json:"issue_marked,omitempty" pg:",use_zero"`
	CommentsOpened *bool       `json:"comments_opened,omitempty" pg:",use_zero"`
}

Comment contains the structure of an issue comment.

type ContentType

type ContentType uint8

ContentType signifies the comment type.

const (
	// Message denotes the comment is a regular message.
	Message ContentType = iota
	// IssueMarked denotes the issue status has changed. The flag is
	// available in data.
	IssueMarked
	// CommentsLocked denotes comments have been locked or unlocked.
	// Marked by a boolean as data.
	CommentsLocked
)

type EntryType

type EntryType uint8

EntryType signifies the entry status type.

const (
	// EntryActive means an issue has not been fixed and not assigned yet.
	EntryActive EntryType = iota
	// EntryOpen means an issue has been assigned but not fixed yet.
	EntryOpen
	// EntryInvalid means an issue is likely incorrect or false positive.
	EntryInvalid
	// EntryResolved means an issue has been fixed.
	EntryResolved
)

func ParseEntryType

func ParseEntryType(entryTypeStr string) (EntryType, error)

ParseEntryType converts a response string into a EntryType value. Returns an error if the input string does not match known values.

func (EntryType) String

func (eT EntryType) String() string

type InviteCode

type InviteCode struct {
	ID   int64  `json:"id"`
	Code string `json:"code"`

	CreatedAt   time.Time `json:"created_at" pg:"default:now()"`
	CreatedBy   *User     `json:"created_by,omitempty" pg:"rel:has-one"`
	CreatedByID int64     `json:"created_by_id" pg:",use_zero"`

	Uses    int64 `json:"uses" pg:",use_zero"`
	MaxUses int64 `json:"max_uses" pg:",use_zero"`

	ProjectID int64     `json:"project_id"`
	ExpiresBy time.Time `json:"expires_by" pg:",use_zero"`
}

InviteCode is the structure of an invite.

type IssueEntry

type IssueEntry struct {
	ID        int64 `json:"id"`
	ProjectID int64 `json:"project_id"`

	Starred bool `json:"starred" pg:",use_zero"`

	Type        EntryType `json:"type"`
	Occurrences int       `json:"occurrences"`
	Assignee    *User     `json:"assignee,omitempty" pg:"rel:has-one"`
	AssigneeID  int64     `json:"assignee_id" pg:",use_zero"`

	Error       string `json:"error"`
	Function    string `json:"function"`
	Checkpoint  string `json:"checkpoint"`
	Description string `json:"description"`
	Traceback   string `json:"traceback"`

	LastModified time.Time `json:"last_modified" pg:"default:now()"`

	CreatedAt   time.Time `json:"created_at" pg:"default:now()"`
	CreatedBy   *User     `json:"created_by,omitempty" pg:"rel:has-one"`
	CreatedByID int64     `json:"created_by_id" pg:",use_zero"`

	CommentCount   int64      `json:"comment_count" pg:",use_zero"`
	CommentsLocked bool       `json:"comments_locked" pg:",use_zero"`
	Comments       []*Comment `json:"comment_ids,omitempty" pg:"rel:has-many,join_fk:issue_id"`
}

IssueEntry contains the structure of an issue entry.

type PartialProject

type PartialProject struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`

	Archived bool `json:"archived"`
	Private  bool `json:"private"`

	OpenIssues     int `json:"open_issues"`
	ActiveIssues   int `json:"active_issues"`
	ResolvedIssues int `json:"resolved_issues"`
}

PartialProject is a partial version of a project object.

type PartialUser

type PartialUser struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Avatar      string `json:"avatar,omitempty"`
	Integration bool   `json:"integration"`
}

PartialUser is the partial version of a user object.

type Project

type Project struct {
	ID int64 `json:"id"`

	CreatedAt   time.Time `json:"created_at" pg:"default:now()"`
	CreatedBy   *User     `json:"created_by,omitempty" pg:"rel:has-one"`
	CreatedByID int64     `json:"created_by_id" pg:",use_zero"`

	Integrations []*User       `json:"integrations" pg:"rel:has-many,join_fk:project_id"`
	Webhooks     []*Webhook    `json:"webhooks" pg:"rel:has-many,join_fk:project_id"`
	InviteCodes  []*InviteCode `json:"invite_codes" pg:"rel:has-many,join_fk:project_id"`
	Issues       []*IssueEntry `json:"issues,omitempty" pg:"rel:has-many,join_fk:project_id"`

	Settings ProjectSettings `json:"settings"`

	// Cached values to quickly lookup issues.
	StarredIssues int `json:"starred_issues"`

	// Cached values that change on an event in order to reduce lookup times.
	OpenIssues     int `json:"open_issues"`
	ActiveIssues   int `json:"active_issues"`
	ResolvedIssues int `json:"resolved_issues"`
}

Project contains the structure of a project.

type ProjectSettings

type ProjectSettings struct {
	DisplayName string `json:"display_name"` // Display Name
	Background  string `json:"background"`   // URI for background of image

	Description string `json:"description"`
	URL         string `json:"url"` // Link to a project appropriate URL. Will not show if left blank.

	Archived bool `json:"archived" pg:",use_zero"` // When archived, no new issues can be made until unarchived by creator
	Private  bool `json:"private" pg:",use_zero"`  // If a project is private, users can only view

	Limited        bool    `json:"limited" pg:",use_zero"`        // When enabled, only contributes can create errors
	ContributorIDs []int64 `json:"contributor_ids" pg:",notnull"` // Contributors for project
}

ProjectSettings contains the structure of project settings.

type User

type User struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`

	Avatar   string   `json:"avatar,omitempty"`
	UserType UserType `json:"-"`

	CreatedAt time.Time `json:"created_at" pg:"default:now()"`

	// User values
	HookID     int64   `json:"-"` // Used with usertype to reference an external ID (such as a discord id)
	ProjectIDs []int64 `json:"-"`

	// Integration values
	ProjectID   int64 `json:"project_id,omitempty"`
	CreatedByID int64 `json:"created_by_id,omitempty" pg:",use_zero"`
	CreatedBy   *User `json:"created_by,omitempty" pg:"rel:has-one"`
	Integration bool  `json:"integration" pg:",use_zero"`

	Token string `json:"-"`
}

User contains the structure of a user.

type UserType

type UserType uint8

UserType signifies how they have authenticated into Errorly.

const (
	// DiscordUser is a user who has authenticated with discord
	// OAuth2.
	DiscordUser UserType = iota
	// IntegrationUser is a 3rd party managed application.
	IntegrationUser
)

type Webhook

type Webhook struct {
	ID        int64 `json:"id"`
	ProjectID int64 `json:"project_id"`

	CreatedAt   time.Time `json:"created_at" pg:"default:now()"`
	CreatedBy   *User     `json:"created_by,omitempty" pg:"rel:has-one"`
	CreatedByID int64     `json:"created_by_id" pg:",use_zero"`

	Secret      string      `json:"secret"` // Secret to send in the header to confirm origin
	URL         string      `json:"url"`
	Type        WebhookType `json:"type"`
	JSONContent bool        `json:"json_content" pg:",use_zero"` // When true, uses json else urlencoded
	Active      bool        `json:"active" pg:",use_zero"`       // Boolean if it is enabled

	Failures uint8 `json:"failures"` // If 4 failures sending webhook, will disable webhook
}

Webhook contains the structure of a webhook integration.

type WebhookEventType

type WebhookEventType int8

WebhookEventType signifies what type of event occurred for the webhook.

const (
	// TestWebhooks should not be shown however still properly handled, if
	// possible however by default will still display a message. It will
	// have a code of -1.
	TestWebhook WebhookEventType = iota - 1
	// IssueCreate signifies a new issue was made. The project,
	// issue ands author are attached.
	IssueCreate
	// IssueComment signifies a user sent a new comment. The
	// project, issue, author and comment are attached.
	IssueComment
	// IssueStarred signifies a message was starred/unstarred.
	// The project, issue and author are attached.
	IssueStarred
	// IssueAssigned signifies a user was assigned to an issue.
	// The project, issue, author and assignee are attached.
	IssueAssigned
	// IssueLocked signifies comments on an issue was locked/unlocked.
	// The project, issue and author are attached.
	IssueLocked
	// IssueMarkStatus signifies the status of an issue has changed.
	// The project, issue and invoauthorkee are attached.
	IssueMarkStatus
)

type WebhookMessage

type WebhookMessage struct {
	Type WebhookEventType `json:"type"`

	Project *Project    `json:"project,omitempty"`
	Issue   *IssueEntry `json:"issue,omitempty"`
	Comment *Comment    `json:"comment,omitempty"`

	Author *User `json:"author,omitempty"`
}

WebhookMessage is the generic payload for all webhook messages.

type WebhookTest

type WebhookTest struct {
	OK    bool   `json:"ok"`
	Error string `json:"error"`

	Webhook *Webhook `json:"webhook"`
}

WebhookTest is the structure of the /api/project/{project_id}/webhook/{webhook_id}/test request

type WebhookType

type WebhookType uint8

WebhookType signifies how the payload should be sent.

const (
	// RegularPayload denotes the payload should be similar to a
	// REST response.
	RegularPayload WebhookType = iota
	// DiscordWebhook denotes the payload should supply a payload
	// that would accept by a discord webhook.
	DiscordWebhook
)

Jump to

Keyboard shortcuts

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