Skip to content

Commit

Permalink
Merge branch 'master' into google#2579
Browse files Browse the repository at this point in the history
  • Loading branch information
XaurDesu committed Feb 6, 2023
2 parents 68995d1 + c855eb5 commit f47debd
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 11 deletions.
32 changes: 23 additions & 9 deletions github/actions_artifacts.go
Expand Up @@ -12,20 +12,34 @@ import (
"net/url"
)

// Artifact reprents a GitHub artifact. Artifacts allow sharing
// ArtifactWorkflowRun represents a GitHub artifact's workflow run.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
type ArtifactWorkflowRun struct {
ID *int64 `json:"id,omitempty"`
RepositoryID *int64 `json:"repository_id,omitempty"`
HeadRepositoryID *int64 `json:"head_repository_id,omitempty"`
HeadBranch *string `json:"head_branch,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"`
}

// Artifact represents a GitHub artifact. Artifacts allow sharing
// data between jobs in a workflow and provide storage for data
// once a workflow is complete.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
type Artifact struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Name *string `json:"name,omitempty"`
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
Expired *bool `json:"expired,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Name *string `json:"name,omitempty"`
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
URL *string `json:"url,omitempty"`
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
Expired *bool `json:"expired,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"`
}

// ArtifactList represents a list of GitHub artifacts.
Expand Down
40 changes: 38 additions & 2 deletions github/actions_artifacts_test.go
Expand Up @@ -438,21 +438,39 @@ func TestArtifact_Marshal(t *testing.T) {
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
URL: String("u"),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
WorkflowRun: &ArtifactWorkflowRun{
ID: Int64(1),
RepositoryID: Int64(1),
HeadRepositoryID: Int64(1),
HeadBranch: String("b"),
HeadSHA: String("s"),
},
}

want := `{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
}
}`

testJSONMarshal(t, u, want)
Expand All @@ -469,10 +487,19 @@ func TestArtifactList_Marshal(t *testing.T) {
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
URL: String("u"),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
WorkflowRun: &ArtifactWorkflowRun{
ID: Int64(1),
RepositoryID: Int64(1),
HeadRepositoryID: Int64(1),
HeadBranch: String("b"),
HeadSHA: String("s"),
},
},
},
}
Expand All @@ -484,10 +511,19 @@ func TestArtifactList_Marshal(t *testing.T) {
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
}
}]
}`

Expand Down
12 changes: 12 additions & 0 deletions github/apps_marketplace.go
Expand Up @@ -46,6 +46,7 @@ type MarketplacePlan struct {

// MarketplacePurchase represents a GitHub Apps Marketplace Purchase.
type MarketplacePurchase struct {
Account *MarketplacePurchaseAccount `json:"account,omitempty"`
// BillingCycle can be one of the values "yearly", "monthly" or nil.
BillingCycle *string `json:"billing_cycle,omitempty"`
NextBillingDate *Timestamp `json:"next_billing_date,omitempty"`
Expand Down Expand Up @@ -75,6 +76,17 @@ type MarketplacePlanAccount struct {
MarketplacePendingChange *MarketplacePendingChange `json:"marketplace_pending_change,omitempty"`
}

// MarketplacePurchaseAccount represents a GitHub Account (user or organization) for a Purchase.
type MarketplacePurchaseAccount struct {
URL *string `json:"url,omitempty"`
Type *string `json:"type,omitempty"`
ID *int64 `json:"id,omitempty"`
Login *string `json:"login,omitempty"`
OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"`
Email *string `json:"email,omitempty"`
NodeID *string `json:"node_id,omitempty"`
}

// ListPlans lists all plans for your Marketplace listing.
//
// GitHub API docs: https://docs.github.com/en/rest/apps#list-plans
Expand Down
128 changes: 128 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f47debd

Please sign in to comment.