Documentation
¶
Overview ¶
Package models contains data types that will be received in a request or data that will be sent in a response. For example, this is a good place to store the format of the datasource settings.
Index ¶
- Constants
- type Client
- type CommitsQuery
- type ContributorsQuery
- type Filter
- type IssueTimeField
- type IssuesQuery
- type LabelsQuery
- type ListCommitsOptions
- type ListContributorsOptions
- type ListIssuesOptions
- type ListLabelsOptions
- type ListMilestonesOptions
- type ListPackagesOptions
- type ListPullRequestsOptions
- type ListReleasesOptions
- type ListRepositoriesOptions
- type ListStargazersOptions
- type ListTagsOptions
- type ListVulnerabilitiesOptions
- type ListWorkflowsOptions
- type Milestone
- type MilestonesQuery
- type PackagesQuery
- type PageInfo
- type ProjectOptions
- type ProjectQuery
- type ProjectsQuery
- type PullRequestTimeField
- type PullRequestsQuery
- type Query
- type ReleasesQuery
- type RepositoriesQuery
- type Repository
- type Settings
- type StargazersQuery
- type TagsQuery
- type User
- type VulnerabilityQuery
- type WorkflowTimeField
- type WorkflowUsage
- type WorkflowUsageOptions
- type WorkflowUsageQuery
- type WorkflowsQuery
Constants ¶
const ( // QueryTypeCommits is sent by the frontend when querying commits in a GitHub repository QueryTypeCommits = "Commits" // QueryTypeIssues is used when querying issues in a GitHub repository QueryTypeIssues = "Issues" // QueryTypeContributors is used when querying contributors in a GitHub repository QueryTypeContributors = "Contributors" // QueryTypeTags is used when querying tags in a GitHub repository QueryTypeTags = "Tags" // QueryTypeReleases is used when querying releases in a GitHub repository QueryTypeReleases = "Releases" // QueryTypePullRequests is used when querying pull requests in a GitHub repository QueryTypePullRequests = "Pull_Requests" // QueryTypeLabels is used when querying labels in a GitHub repository QueryTypeLabels = "Labels" // QueryTypeRepositories is used when querying for a GitHub repository QueryTypeRepositories = "Repositories" // QueryTypeOrganizations is used when querying for GitHub organizations QueryTypeOrganizations = "Organizations" // QueryTypeGraphQL is used when sending an ad-hoc graphql query QueryTypeGraphQL = "GraphQL" // QueryTypePackages is used when querying for NPM / Docker / etc packages QueryTypePackages = "Packages" // QueryTypeMilestones is used when querying for milestones in a repository QueryTypeMilestones = "Milestones" // QueryTypeVulnerabilities is used when querying a vulnerability for a repository QueryTypeVulnerabilities = "Vulnerabilities" // QueryTypeProjects is used when querying projects for an organization QueryTypeProjects = "Projects" // QueryTypeProjectItems is used when querying projects for an organization QueryTypeProjectItems = "ProjectItems" // QueryTypeStargazers is used when querying stargazers for a repository QueryTypeStargazers = "Stargazers" // QueryTypeWorkflows is used when querying workflows for an organization QueryTypeWorkflows = "Workflows" // QueryTypeWorkflowUsage is used when querying a specific workflow usage QueryTypeWorkflowUsage = "Workflow_Usage" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v1.3.0
type Client interface {
Query(ctx context.Context, q interface{}, variables map[string]interface{}) error
ListWorkflows(ctx context.Context, owner, repo string, opts *googlegithub.ListOptions) (*googlegithub.Workflows, *googlegithub.Response, error)
GetWorkflowUsage(ctx context.Context, owner, repo, workflow string, timeRange backend.TimeRange) (WorkflowUsage, error)
}
The Client interface is satisfied by the githubv4.Client type. Rather than accept the githubv4.Client type everywhere, we will follow the Go idiom of accepting interfaces / returning structs and accept this interface.
type CommitsQuery ¶
type CommitsQuery struct {
Query
Options ListCommitsOptions `json:"options"`
}
CommitsQuery is used when querying for GitHub commits
type ContributorsQuery ¶
type ContributorsQuery struct {
Query
Options ListContributorsOptions `json:"options"`
}
ContributorsQuery is used when querying for GitHub contributors
type Filter ¶ added in v1.3.0
type Filter struct {
// Key ...
Key string
// Value ...
Value string
// OP ...
OP string
// Conjunction ...
Conjunction string
}
Filter allows filtering by Key/Value
type IssueTimeField ¶
type IssueTimeField uint32
IssueTimeField defines what time field to filter issues by (closed, opened...)
const ( // IssueCreatedAt is used when filtering when an Issue was opened IssueCreatedAt IssueTimeField = iota // IssueClosedAt is used when filtering when an Issue was closed IssueClosedAt // IssueUpdatedAt is used when filtering when an Issue was updated (last time) IssueUpdatedAt )
func (IssueTimeField) String ¶
func (d IssueTimeField) String() string
type IssuesQuery ¶
type IssuesQuery struct {
Query
Options ListIssuesOptions `json:"options"`
}
IssuesQuery is used when querying for GitHub issues
type LabelsQuery ¶
type LabelsQuery struct {
Query
Options ListLabelsOptions `json:"options"`
}
LabelsQuery is used when querying for GitHub issue labels
type ListCommitsOptions ¶
type ListCommitsOptions struct {
Repository string `json:"repository"`
Owner string `json:"owner"`
Ref string `json:"gitRef"`
}
ListCommitsOptions provides options when retrieving commits
func CommitsOptionsWithRepo ¶
func CommitsOptionsWithRepo(opt ListCommitsOptions, owner string, repo string) ListCommitsOptions
CommitsOptionsWithRepo adds Owner and Repo to a ListCommitsOptions. This is just for convenience
type ListContributorsOptions ¶
type ListContributorsOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
Query *string `json:"query,omitempty"`
}
ListContributorsOptions are the available arguments when listing contributor
type ListIssuesOptions ¶
type ListIssuesOptions struct {
Repository string `json:"repository"`
Owner string `json:"owner"`
Filters *githubv4.IssueFilters `json:"filters"`
Query *string `json:"query,omitempty"`
TimeField IssueTimeField `json:"timeField"`
}
ListIssuesOptions provides options when retrieving issues
func IssueOptionsWithRepo ¶
func IssueOptionsWithRepo(opt ListIssuesOptions, owner string, repo string) ListIssuesOptions
IssueOptionsWithRepo adds the Owner and Repository values to a ListIssuesOptions. This is a convenience function because this is a common operation
type ListLabelsOptions ¶
type ListLabelsOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// Query searches labels by name and description
Query string `json:"query"`
}
ListLabelsOptions is provided when listing Labels in a repository
type ListMilestonesOptions ¶
type ListMilestonesOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// Query searches milestones by name and description
Query string `json:"query"`
}
ListMilestonesOptions is provided when listing Labels in a repository
type ListPackagesOptions ¶
type ListPackagesOptions struct {
Repository string `json:"repository"`
Owner string `json:"owner"`
Names string `json:"names"`
PackageType githubv4.PackageType `json:"packageType"`
}
ListPackagesOptions provides options when retrieving commits
func PackagesOptionsWithRepo ¶
func PackagesOptionsWithRepo(opt ListPackagesOptions, owner string, repo string) ListPackagesOptions
PackagesOptionsWithRepo adds Owner and Repo to a ListPackagesOptions. This is just for convenience
type ListPullRequestsOptions ¶
type ListPullRequestsOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// TimeField defines what time field to filter by
TimeField PullRequestTimeField `json:"timeField"`
Query *string `json:"query,omitempty"`
}
ListPullRequestsOptions are the available options when listing pull requests in a time range
func PullRequestOptionsWithRepo ¶
func PullRequestOptionsWithRepo(opt ListPullRequestsOptions, owner string, repo string) ListPullRequestsOptions
PullRequestOptionsWithRepo adds the Owner and Repository options to a ListPullRequestsOptions type
type ListReleasesOptions ¶
type ListReleasesOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
}
ListReleasesOptions are the available options when listing releases
type ListRepositoriesOptions ¶
ListRepositoriesOptions is the options for listing repositories
type ListStargazersOptions ¶ added in v1.4.0
type ListStargazersOptions struct {
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
}
ListStargazersOptions is provided when fetching stargazers for a repository
type ListTagsOptions ¶
type ListTagsOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
}
ListTagsOptions are the available options when listing tags
type ListVulnerabilitiesOptions ¶ added in v1.3.0
type ListVulnerabilitiesOptions struct {
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
}
ListVulnerabilitiesOptions is provided when listing vulnerabilities in a repository
type ListWorkflowsOptions ¶ added in v1.4.7
type ListWorkflowsOptions struct {
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// The field used to check if an entry is in the requested range.
TimeField WorkflowTimeField `json:"timeField"`
}
ListWorkflowsOptions is provided when fetching workflows for a repository
type Milestone ¶ added in v1.3.0
type Milestone struct {
Closed bool
Creator struct {
User User `graphql:"... on User"`
}
DueOn githubv4.DateTime
ClosedAt githubv4.DateTime
CreatedAt githubv4.DateTime
State githubv4.MilestoneState
Title string
}
Milestone is a GitHub Milestone
type MilestonesQuery ¶
type MilestonesQuery struct {
Query
Options ListMilestonesOptions `json:"options"`
}
MilestonesQuery is used when querying for GitHub milestones
type PackagesQuery ¶
type PackagesQuery struct {
Query
Options ListPackagesOptions `json:"options"`
}
PackagesQuery is used when querying for GitHub packages, including NPM, Maven, PyPi, Rubygems, and Docker
type ProjectOptions ¶ added in v1.3.0
type ProjectOptions struct {
// Organization is the name of the organization being queried (ex: grafana)
Organization string `json:"organization"`
// Number is the project number
Number any `json:"number"`
// User is the name of the user who owns the project being queried
User string `json:"user"`
// Kind is the kind of query - Org vs User
Kind int `json:"kind"`
// Filters allow filtering the results
Filters []Filter `json:"filters"`
}
ProjectOptions are the available options when listing project items
type ProjectQuery ¶ added in v1.3.0
type ProjectQuery struct {
// Options ...
Options ProjectOptions `json:"options"`
}
ProjectQuery is used when querying for GitHub Project items
type ProjectsQuery ¶ added in v1.3.0
type ProjectsQuery struct {
// Options ...
Options ProjectOptions `json:"options"`
}
ProjectsQuery is used when querying for GitHub Projects
type PullRequestTimeField ¶
type PullRequestTimeField uint32
PullRequestTimeField defines what time field to filter pull requests by (closed, opened, merged...)
const ( // PullRequestClosedAt is used when filtering when a Pull Request was closed PullRequestClosedAt PullRequestTimeField = iota // PullRequestCreatedAt is used when filtering when a Pull Request was opened PullRequestCreatedAt // PullRequestMergedAt is used when filtering when a Pull Request was merged PullRequestMergedAt // PullRequestNone is used when the results are not filtered by time. Without any other filters, using this could easily cause an access token to be rate limited PullRequestNone )
func (PullRequestTimeField) String ¶
func (d PullRequestTimeField) String() string
type PullRequestsQuery ¶
type PullRequestsQuery struct {
Query
Options ListPullRequestsOptions `json:"options"`
}
PullRequestsQuery is used when querying for GitHub Pull Requests
type Query ¶
Query refers to the structure of a query built using the QueryEditor. Every query uses this query type and has to include options for each type of query. For example, listing commits can be filtered by author, but filtering contributors by author doesn't provide much value, but is included in the query schema anyways.
type ReleasesQuery ¶
type ReleasesQuery struct {
Query
Options ListReleasesOptions `json:"options"`
}
ReleasesQuery is used when querying for GitHub issue labels
type RepositoriesQuery ¶ added in v1.0.1
type RepositoriesQuery struct {
Query
}
RepositoriesQuery is used when querying for GitHub repositories
type Repository ¶ added in v1.3.0
type Repository struct {
Name string
Owner struct {
Login string
}
NameWithOwner string
URL string
ForkCount int64
IsFork bool
IsMirror bool
IsPrivate bool
CreatedAt githubv4.DateTime
}
Repository is a code repository
type Settings ¶
type Settings struct {
AccessToken string `json:"accessToken"`
GithubURL string `json:"githubUrl"`
CachingEnabled bool `json:"cachingEnabled"`
}
Settings represents the Datasource options in Grafana
func LoadSettings ¶
func LoadSettings(settings backend.DataSourceInstanceSettings) (Settings, error)
LoadSettings converts the DataSourceInLoadSettings to usable GitHub settings
type StargazersQuery ¶ added in v1.4.0
type StargazersQuery struct {
Query
}
StargazersQuery is used when querying stargazers for a repository
type TagsQuery ¶
type TagsQuery struct {
Query
Options ListTagsOptions `json:"options"`
}
TagsQuery is used when querying for GitHub tags
type VulnerabilityQuery ¶ added in v1.3.0
type VulnerabilityQuery struct {
Query
Options ListVulnerabilitiesOptions `json:"options"`
}
VulnerabilityQuery is used when querying for GitHub Repository Vulnerabilities
type WorkflowTimeField ¶ added in v1.4.7
type WorkflowTimeField uint32
WorkflowTimeField defines what time field to filter Workflows by.
const ( // WorkflowCreatedAt is used when filtering when an workflow was created WorkflowCreatedAt WorkflowTimeField = iota // WorkflowUpdatedAt is used when filtering when an Workflow was updated WorkflowUpdatedAt )
type WorkflowUsage ¶ added in v1.4.7
type WorkflowUsage struct {
CostUSD float64
UniqueActors uint64
Runs uint64
SuccessfulRuns uint64
FailedRuns uint64
CancelledRuns uint64
SkippedRuns uint64
LongestRunDuration time.Duration
TotalRunDuration time.Duration
P95RunDuration time.Duration
RunsPerWeekday map[time.Weekday]uint64
UsagePerRunner map[string]time.Duration
Name string
}
WorkflowUsage contains a specific workflow usage information.
type WorkflowUsageOptions ¶ added in v1.4.7
type WorkflowUsageOptions struct {
// Owner is the owner of the repository (ex: grafana)
Owner string `json:"owner"`
// Repository is the name of the repository being queried (ex: grafana)
Repository string `json:"repository"`
// Workflow is the id or the workflow file name.
Workflow string `json:"workflow"`
}
WorkflowUsageOptions is provided when fetching a specific workflow usage
type WorkflowUsageQuery ¶ added in v1.4.7
type WorkflowUsageQuery struct {
Query
Options WorkflowUsageOptions `json:"options"`
}
WorkflowUsageQuery is used when querying a workflow usage
type WorkflowsQuery ¶ added in v1.4.7
type WorkflowsQuery struct {
Query
Options ListWorkflowsOptions `json:"options"`
}
WorkflowsQuery is used when querying workflows for an organization