Repository: google/go-github
Pull request #1862 (2021-05-05 13:34:38)

Add download token and sha to ListRunnerApplicationDownloads
See https://github.com/google/go-github/issues/1861

When using Git Hub Enterprise APIs a temp_download_token is included when querying runner downloads via the API.

This PR updates the response structure to include the necessary token and SHA checksum.

```
>:~$ curl -k -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3+json" https://HOST/api/v3/orgs/actions-sauron/actions/runners/downloads
[
  {
    "os": "osx",
    "architecture": "x64",
    "download_url": "https://HOST/_services/pipelines/_apis/distributedtask/packagedownload/agent/osx-x64/2.277.1",
    "filename": "actions-runner-osx-x64-2.277.1.tar.gz",
    "temp_download_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...",
    "sha256_checksum": "f1fa173889dc9036cd5294..."
  },
  {
    "os": "linux",
    "architecture": "x64",
    "download_url": "https://HOST/_services/pipelines/_apis/distributedtask/packagedownload/agent/linux-x64/2.277.1",
    "filename": "actions-runner-linux-x64-2.277.1.tar.gz",
    "temp_download_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1...",
    "sha256_checksum": "02d710fc9e0008e641274bb7da7fde61f7c9a..."
  },
  ...
]
```

google-cla[bot]: 
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here with `@googlebot I signed it!` and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](http://go/cla#troubleshoot) ([Public version](https://opensource.google/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

ℹ️ **Googlers: [Go here](https://goto.google.com/prinfo/https%3A%2F%2Fgithub.com%2Fgoogle%2Fgo-github%2Fpull%2F1862) for more info**.

<!-- need_sender_cla -->
lupine86: @googlebot I signed it!
gmlewis: Thank you, @lupine86 !
Please run `go generate ./...` and commit/push (not force-push) the changes to this PR.
(More details can be found in `CONTRIBUTING.md`.)
codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#1862](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (554c464) into [master](https://codecov.io/gh/google/go-github/commit/576e460080e5b71ded235f390a847cd74bbf314f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (576e460) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1862/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #1862   +/-   ##
=======================================
  Coverage   97.65%   97.65%           
=======================================
  Files         105      105           
  Lines        6769     6769           
=======================================
  Hits         6610     6610           
  Misses         86       86           
  Partials       73       73           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/actions\_runners.go](https://codecov.io/gh/google/go-github/pull/1862/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FjdGlvbnNfcnVubmVycy5nbw==) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [576e460...554c464](https://codecov.io/gh/google/go-github/pull/1862?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/actions_runners.go b/github/actions_runners.go
index 66d9c309..5bdebb31 100644
--- a/github/actions_runners.go
+++ b/github/actions_runners.go
@@ -12,10 +12,12 @@ import (
 
 // RunnerApplicationDownload represents a binary for the self-hosted runner application that can be downloaded.
 type RunnerApplicationDownload struct {
-	OS           *string `json:"os,omitempty"`
-	Architecture *string `json:"architecture,omitempty"`
-	DownloadURL  *string `json:"download_url,omitempty"`
-	Filename     *string `json:"filename,omitempty"`
+	OS                *string `json:"os,omitempty"`
+	Architecture      *string `json:"architecture,omitempty"`
+	DownloadURL       *string `json:"download_url,omitempty"`
+	Filename          *string `json:"filename,omitempty"`
+	TempDownloadToken *string `json:"temp_download_token,omitempty"`
+	SHA256Checksum    *string `json:"sha256_checksum,omitempty"`
 }
 
 // ActionsEnabledOnOrgRepos represents all the repositories in an organization for which Actions is enabled.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index d39473a0..37ddb180 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -13612,6 +13612,22 @@ func (r *RunnerApplicationDownload) GetOS() string {
 	return *r.OS
 }
 
+// GetSHA256Checksum returns the SHA256Checksum field if it's non-nil, zero value otherwise.
+func (r *RunnerApplicationDownload) GetSHA256Checksum() string {
+	if r == nil || r.SHA256Checksum == nil {
+		return ""
+	}
+	return *r.SHA256Checksum
+}
+
+// GetTempDownloadToken returns the TempDownloadToken field if it's non-nil, zero value otherwise.
+func (r *RunnerApplicationDownload) GetTempDownloadToken() string {
+	if r == nil || r.TempDownloadToken == nil {
+		return ""
+	}
+	return *r.TempDownloadToken
+}
+
 // GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise.
 func (r *RunnerGroup) GetAllowsPublicRepositories() bool {
 	if r == nil || r.AllowsPublicRepositories == nil {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index b3d31306..3da8dda1 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -15939,6 +15939,26 @@ func TestRunnerApplicationDownload_GetOS(tt *testing.T) {
 	r.GetOS()
 }
 
+func TestRunnerApplicationDownload_GetSHA256Checksum(tt *testing.T) {
+	var zeroValue string
+	r := &RunnerApplicationDownload{SHA256Checksum: &zeroValue}
+	r.GetSHA256Checksum()
+	r = &RunnerApplicationDownload{}
+	r.GetSHA256Checksum()
+	r = nil
+	r.GetSHA256Checksum()
+}
+
+func TestRunnerApplicationDownload_GetTempDownloadToken(tt *testing.T) {
+	var zeroValue string
+	r := &RunnerApplicationDownload{TempDownloadToken: &zeroValue}
+	r.GetTempDownloadToken()
+	r = &RunnerApplicationDownload{}
+	r.GetTempDownloadToken()
+	r = nil
+	r.GetTempDownloadToken()
+}
+
 func TestRunnerGroup_GetAllowsPublicRepositories(tt *testing.T) {
 	var zeroValue bool
 	r := &RunnerGroup{AllowsPublicRepositories: &zeroValue}