package api // Types mirror the schemas of the rickub JSON API (`/api/v1`). Clients must // ignore unknown JSON fields (additive changes may appear within v1), which // json unmarshalling does by default. // User is the identity that owns the presented PAT. type User struct { Handle string `json:"handle"` DisplayName string `json:"display_name"` Email string `json:"email"` EmailVerified bool `json:"email_verified"` Superadmin bool `json:"superadmin"` } // Repo is a repository. type Repo struct { Owner string `json:"owner"` Name string `json:"name"` FullName string `json:"full_name"` Visibility string `json:"visibility"` Description string `json:"description"` DefaultBranch string `json:"default_branch"` Fork bool `json:"fork"` ForkedFromOwner string `json:"forked_from_owner"` ForkedFromName string `json:"forked_from_name"` CreatedAt string `json:"created_at"` URL string `json:"url"` } // RepoCreate is the create-repo request body. type RepoCreate struct { Owner string `json:"owner,omitempty"` Name string `json:"name"` Visibility string `json:"visibility,omitempty"` Description string `json:"description,omitempty"` } // RepoUpdate is the patch-repo request body. type RepoUpdate struct { Visibility *string `json:"visibility,omitempty"` Description *string `json:"description,omitempty"` DefaultBranch *string `json:"default_branch,omitempty"` } // Collaborator is a repo collaborator grant. type Collaborator struct { Handle string `json:"handle"` DisplayName string `json:"display_name"` Permission string `json:"permission"` } // MergeRequest is a merge request (a.k.a. pull request). type MergeRequest struct { Number int `json:"number"` Title string `json:"title"` Body string `json:"body"` State string `json:"state"` Author string `json:"author"` BaseBranch string `json:"base_branch"` HeadBranch string `json:"head_branch"` HeadOwner string `json:"head_owner"` HeadRepo string `json:"head_repo"` CrossRepo bool `json:"cross_repo"` MergeSHA string `json:"merge_sha"` CreatedAt string `json:"created_at"` MergedAt string `json:"merged_at"` URL string `json:"url"` } // MergeRequestDetail adds comments/reviewers/assignees/reviews. type MergeRequestDetail struct { MergeRequest Comments []Comment `json:"comments"` Reviewers []Subject `json:"reviewers"` Assignees []Subject `json:"assignees"` Reviews []Review `json:"reviews"` } // MergeRequestCreate is the open-MR request body. type MergeRequestCreate struct { Base string `json:"base"` Head string `json:"head"` Title string `json:"title"` Body string `json:"body,omitempty"` HeadOwner string `json:"head_owner,omitempty"` HeadRepo string `json:"head_repo,omitempty"` } // Comment is an MR comment. type Comment struct { Author string `json:"author"` Body string `json:"body"` CreatedAt string `json:"created_at"` } // Subject is a reviewer/assignee (user or team). type Subject struct { Type string `json:"type"` Name string `json:"name"` Label string `json:"label"` } // Review is a review verdict. type Review struct { Reviewer string `json:"reviewer"` Verdict string `json:"verdict"` UpdatedAt string `json:"updated_at"` } // RunStep is a single step's status. type RunStep struct { Ordinal int `json:"ordinal"` Name string `json:"name"` Status string `json:"status"` } // RunJob is a job with its steps. type RunJob struct { Name string `json:"name"` Status string `json:"status"` Steps []RunStep `json:"steps"` } // Run is a workflow run. type Run struct { Number int `json:"number"` Workflow string `json:"workflow"` Event string `json:"event"` Branch string `json:"branch"` Status string `json:"status"` HeadSHA string `json:"head_sha"` SecretsWithheld bool `json:"secrets_withheld"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` URL string `json:"url"` Jobs []RunJob `json:"jobs"` } // RunLogsJob is one job's accumulated log. type RunLogsJob struct { Name string `json:"name"` Status string `json:"status"` Log string `json:"log"` } // RunLogs is the accumulated logs for a run. type RunLogs struct { Number int `json:"number"` Status string `json:"status"` Jobs []RunLogsJob `json:"jobs"` } // DispatchResult is the response of an actions dispatch. type DispatchResult struct { Dispatched int `json:"dispatched"` Runs []Run `json:"runs"` } // Org is basic org info. type Org struct { Handle string `json:"handle"` DisplayName string `json:"display_name"` CreatedAt string `json:"created_at"` } // OrgMember is an org membership. type OrgMember struct { Handle string `json:"handle"` DisplayName string `json:"display_name"` Role string `json:"role"` } // Team is an org team. type Team struct { Slug string `json:"slug"` Name string `json:"name"` Description string `json:"description"` SubTeam bool `json:"sub_team"` } // Ref is a branch or tag. type Ref struct { Name string `json:"name"` SHA string `json:"sha"` } // Refs is the ref inventory. type Refs struct { Branches []Ref `json:"branches"` Tags []Ref `json:"tags"` DefaultBranch string `json:"default_branch"` } // TreeEntry is one entry in a directory listing. type TreeEntry struct { Name string `json:"name"` Type string `json:"type"` // blob | tree Mode string `json:"mode"` SHA string `json:"sha"` Size int `json:"size"` } // Blob is a file's content. type Blob struct { Path string `json:"path"` Size int `json:"size"` IsBinary bool `json:"is_binary"` Truncated bool `json:"truncated"` Content string `json:"content"` } // Contents is a dir listing or file. type Contents struct { Type string `json:"type"` // dir | file Ref string `json:"ref"` Path string `json:"path"` Entries []TreeEntry `json:"entries"` File *Blob `json:"file"` } // Commit is a commit summary. type Commit struct { SHA string `json:"sha"` Short string `json:"short"` Author string `json:"author"` Date string `json:"date"` Subject string `json:"subject"` } // DiffFile is one file's diff. type DiffFile struct { Path string `json:"path"` Status string `json:"status"` Additions int `json:"additions"` Deletions int `json:"deletions"` Patch string `json:"patch"` } // CommitDetail is a single commit's metadata + diff. type CommitDetail struct { SHA string `json:"sha"` Short string `json:"short"` AuthorName string `json:"author_name"` AuthorEmail string `json:"author_email"` AuthorDate string `json:"author_date"` Subject string `json:"subject"` Body string `json:"body"` Parents []string `json:"parents"` Files []DiffFile `json:"files"` Truncated bool `json:"truncated"` } // Comparison is a base...head comparison. type Comparison struct { MergeBase string `json:"merge_base"` AheadBy int `json:"ahead_by"` BehindBy int `json:"behind_by"` Commits []Commit `json:"commits"` Files []DiffFile `json:"files"` Truncated bool `json:"truncated"` } // Page is the pagination envelope shared by list responses. type Page struct { Page int `json:"page"` PerPage int `json:"per_page"` HasNext bool `json:"has_next"` } // RepoPage is a page of repositories. type RepoPage struct { Page Items []Repo `json:"items"` } // MergeRequestPage is a page of merge requests. type MergeRequestPage struct { Page Items []MergeRequest `json:"items"` } // RunPage is a page of runs. type RunPage struct { Page Items []Run `json:"items"` } // CommitPage is a page of commits. type CommitPage struct { Page Items []Commit `json:"items"` } // --- issues / labels / milestones --------------------------------------------- // Label is a repo label. type Label struct { ID string `json:"id"` Name string `json:"name"` Color string `json:"color"` } // Milestone is a repo milestone with progress counts. type Milestone struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` State string `json:"state"` DueOn *string `json:"due_on,omitempty"` CreatedAt string `json:"created_at"` OpenCount int `json:"open_issues"` ClosedCount int `json:"closed_issues"` } // Issue is an issue list row. type Issue struct { Number int `json:"number"` Title string `json:"title"` State string `json:"state"` Author string `json:"author"` Labels []Label `json:"labels"` Milestone *Milestone `json:"milestone,omitempty"` CreatedAt string `json:"created_at"` ClosedAt *string `json:"closed_at,omitempty"` URL string `json:"url"` } // Assignee is a user assigned to an issue. type Assignee struct { Handle string `json:"handle"` DisplayName string `json:"display_name,omitempty"` } // IssueDetail adds body, comments, and assignees. type IssueDetail struct { Issue Body string `json:"body"` Comments []Comment `json:"comments"` Assignees []Assignee `json:"assignees"` } // IssuePage is a page of issues. type IssuePage struct { Page Items []Issue `json:"items"` } // --- device flow (web login) -------------------------------------------------- // DeviceCodeStart is the /device/code response: where to approve and how often // to poll. type DeviceCodeStart struct { DeviceCode string `json:"device_code"` UserCode string `json:"user_code"` VerificationURL string `json:"verification_url"` VerificationURIComplete string `json:"verification_uri_complete"` ExpiresIn int `json:"expires_in"` Interval int `json:"interval"` } // DeviceToken is the successful /device/token poll: a freshly minted PAT. type DeviceToken struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` Scope string `json:"scope"` }