Repository: google/go-github
Pull request #1817 (2021-03-04 18:01:39)

Apps.Installation: Add missing fields AppSlug, HasMultipleSingleFiles, SuspendedAt, SuspendedBy and SingleFilePaths
**What type of PR is this?**

feature

**What this PR does / why we need it**:

The `Installation` type in AppService is missing a few fields from the JSON response.
This PR adds the fields
- AppSlug
- HasMultipleSingleFiles
- SuspendedAt
- SuspendedBy
- SingleFilePaths

Here is a dump of the JSON response:

```json
[
  {
    "id": <APP-ID>,
    "account": {
      "login": "<USER>",
      "id": <ID>,
      "node_id": "...",
      "avatar_url": "https://avatars.githubusercontent.com/...",
      "gravatar_id": "",
      "url": "https://api.github.com/users/...",
      "html_url": "https://github.com/...",
      "followers_url": "https://api.github.com/users/.../followers",
      "following_url": "https://api.github.com/users/.../following{/other_user}",
      "gists_url": "https://api.github.com/users/.../gists{/gist_id}",
      "starred_url": "https://api.github.com/users/.../starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/.../subscriptions",
      "organizations_url": "https://api.github.com/users/.../orgs",
      "repos_url": "https://api.github.com/users/.../repos",
      "events_url": "https://api.github.com/users/.../events{/privacy}",
      "received_events_url": "https://api.github.com/users/.../received_events",
      "type": "User",
      "site_admin": false
    },
    "repository_selection": "all",
    "access_tokens_url": "https://api.github.com/app/installations/<ID>/access_tokens",
    "repositories_url": "https://api.github.com/installation/repositories",
    "html_url": "https://github.com/settings/installations/<ID>",
    "app_id": <APP-ID>,
    "app_slug": "test-without-oauth",
    "target_id": <USER-ID>,
    "target_type": "User",
    "permissions": {
      "metadata": "read",
      "administration": "read"
    },
    "events": [

    ],
    "created_at": "2021-03-04T11:45:22.000Z",
    "updated_at": "2021-03-04T17:34:14.000Z",
    "single_file_name": null,
    "has_multiple_single_files": false,
    "single_file_paths": [

    ],
    "suspended_by": {
      "login": "<USER>",
      "id": <ID>,
      "node_id": "...",
      "avatar_url": "https://avatars.githubusercontent.com/u/...",
      "gravatar_id": "",
      "url": "https://api.github.com/users/...",
      "html_url": "https://github.com/...",
      "followers_url": "https://api.github.com/users/.../followers",
      "following_url": "https://api.github.com/users/.../following{/other_user}",
      "gists_url": "https://api.github.com/users/.../gists{/gist_id}",
      "starred_url": "https://api.github.com/users/.../starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/.../subscriptions",
      "organizations_url": "https://api.github.com/users/.../orgs",
      "repos_url": "https://api.github.com/users/.../repos",
      "events_url": "https://api.github.com/users/.../events{/privacy}",
      "received_events_url": "https://api.github.com/users/.../received_events",
      "type": "User",
      "site_admin": false
    },
    "suspended_at": "2021-03-04T17:34:14Z"
  }
]
```

**Special notes for your reviewer**:

None

**Does this PR introduce a user-facing change?**:

None

**Additional documentation e.g., usage docs, etc.**:

- [API: List installations for the authenticated app](https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app)


codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=h1) Report
> Merging [#1817](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=desc) (156b619) into [master](https://codecov.io/gh/google/go-github/commit/b06cfbb1abc090e2ff47cac2f0d2d1750f847293?el=desc) (b06cfbb) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1817/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1817   +/-   ##
=======================================
  Coverage   97.59%   97.59%           
=======================================
  Files         100      100           
  Lines        6521     6521           
=======================================
  Hits         6364     6364           
  Misses         85       85           
  Partials       72       72           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/apps.go](https://codecov.io/gh/google/go-github/pull/1817/diff?src=pr&el=tree#diff-Z2l0aHViL2FwcHMuZ28=) | `95.29% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=footer). Last update [b06cfbb...156b619](https://codecov.io/gh/google/go-github/pull/1817?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/apps.go b/github/apps.go
index 12df54dd..cb0069de 100644
--- a/github/apps.go
+++ b/github/apps.go
@@ -90,21 +90,26 @@ type InstallationPermissions struct {
 
 // Installation represents a GitHub Apps installation.
 type Installation struct {
-	ID                  *int64                   `json:"id,omitempty"`
-	NodeID              *string                  `json:"node_id,omitempty"`
-	AppID               *int64                   `json:"app_id,omitempty"`
-	TargetID            *int64                   `json:"target_id,omitempty"`
-	Account             *User                    `json:"account,omitempty"`
-	AccessTokensURL     *string                  `json:"access_tokens_url,omitempty"`
-	RepositoriesURL     *string                  `json:"repositories_url,omitempty"`
-	HTMLURL             *string                  `json:"html_url,omitempty"`
-	TargetType          *string                  `json:"target_type,omitempty"`
-	SingleFileName      *string                  `json:"single_file_name,omitempty"`
-	RepositorySelection *string                  `json:"repository_selection,omitempty"`
-	Events              []string                 `json:"events,omitempty"`
-	Permissions         *InstallationPermissions `json:"permissions,omitempty"`
-	CreatedAt           *Timestamp               `json:"created_at,omitempty"`
-	UpdatedAt           *Timestamp               `json:"updated_at,omitempty"`
+	ID                     *int64                   `json:"id,omitempty"`
+	NodeID                 *string                  `json:"node_id,omitempty"`
+	AppID                  *int64                   `json:"app_id,omitempty"`
+	AppSlug                *string                  `json:"app_slug,omitempty"`
+	TargetID               *int64                   `json:"target_id,omitempty"`
+	Account                *User                    `json:"account,omitempty"`
+	AccessTokensURL        *string                  `json:"access_tokens_url,omitempty"`
+	RepositoriesURL        *string                  `json:"repositories_url,omitempty"`
+	HTMLURL                *string                  `json:"html_url,omitempty"`
+	TargetType             *string                  `json:"target_type,omitempty"`
+	SingleFileName         *string                  `json:"single_file_name,omitempty"`
+	RepositorySelection    *string                  `json:"repository_selection,omitempty"`
+	Events                 []string                 `json:"events,omitempty"`
+	SingleFilePaths        []string                 `json:"single_file_paths,omitempty"`
+	Permissions            *InstallationPermissions `json:"permissions,omitempty"`
+	CreatedAt              *Timestamp               `json:"created_at,omitempty"`
+	UpdatedAt              *Timestamp               `json:"updated_at,omitempty"`
+	HasMultipleSingleFiles *bool                    `json:"has_multiple_single_files,omitempty"`
+	SuspendedBy            *User                    `json:"suspended_by,omitempty"`
+	SuspendedAt            *Timestamp               `json:"suspended_at,omitempty"`
 }
 
 // Attachment represents a GitHub Apps attachment.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 4f82cd10..88f82e31 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -4268,6 +4268,14 @@ func (i *Installation) GetAppID() int64 {
 	return *i.AppID
 }
 
+// GetAppSlug returns the AppSlug field if it's non-nil, zero value otherwise.
+func (i *Installation) GetAppSlug() string {
+	if i == nil || i.AppSlug == nil {
+		return ""
+	}
+	return *i.AppSlug
+}
+
 // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
 func (i *Installation) GetCreatedAt() Timestamp {
 	if i == nil || i.CreatedAt == nil {
@@ -4276,6 +4284,14 @@ func (i *Installation) GetCreatedAt() Timestamp {
 	return *i.CreatedAt
 }
 
+// GetHasMultipleSingleFiles returns the HasMultipleSingleFiles field if it's non-nil, zero value otherwise.
+func (i *Installation) GetHasMultipleSingleFiles() bool {
+	if i == nil || i.HasMultipleSingleFiles == nil {
+		return false
+	}
+	return *i.HasMultipleSingleFiles
+}
+
 // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
 func (i *Installation) GetHTMLURL() string {
 	if i == nil || i.HTMLURL == nil {
@@ -4332,6 +4348,22 @@ func (i *Installation) GetSingleFileName() string {
 	return *i.SingleFileName
 }
 
+// GetSuspendedAt returns the SuspendedAt field if it's non-nil, zero value otherwise.
+func (i *Installation) GetSuspendedAt() Timestamp {
+	if i == nil || i.SuspendedAt == nil {
+		return Timestamp{}
+	}
+	return *i.SuspendedAt
+}
+
+// GetSuspendedBy returns the SuspendedBy field.
+func (i *Installation) GetSuspendedBy() *User {
+	if i == nil {
+		return nil
+	}
+	return i.SuspendedBy
+}
+
 // GetTargetID returns the TargetID field if it's non-nil, zero value otherwise.
 func (i *Installation) GetTargetID() int64 {
 	if i == nil || i.TargetID == nil {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 24610c53..c41e574a 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -5003,6 +5003,16 @@ func TestInstallation_GetAppID(tt *testing.T) {
 	i.GetAppID()
 }
 
+func TestInstallation_GetAppSlug(tt *testing.T) {
+	var zeroValue string
+	i := &Installation{AppSlug: &zeroValue}
+	i.GetAppSlug()
+	i = &Installation{}
+	i.GetAppSlug()
+	i = nil
+	i.GetAppSlug()
+}
+
 func TestInstallation_GetCreatedAt(tt *testing.T) {
 	var zeroValue Timestamp
 	i := &Installation{CreatedAt: &zeroValue}
@@ -5013,6 +5023,16 @@ func TestInstallation_GetCreatedAt(tt *testing.T) {
 	i.GetCreatedAt()
 }
 
+func TestInstallation_GetHasMultipleSingleFiles(tt *testing.T) {
+	var zeroValue bool
+	i := &Installation{HasMultipleSingleFiles: &zeroValue}
+	i.GetHasMultipleSingleFiles()
+	i = &Installation{}
+	i.GetHasMultipleSingleFiles()
+	i = nil
+	i.GetHasMultipleSingleFiles()
+}
+
 func TestInstallation_GetHTMLURL(tt *testing.T) {
 	var zeroValue string
 	i := &Installation{HTMLURL: &zeroValue}
@@ -5080,6 +5100,23 @@ func TestInstallation_GetSingleFileName(tt *testing.T) {
 	i.GetSingleFileName()
 }
 
+func TestInstallation_GetSuspendedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	i := &Installation{SuspendedAt: &zeroValue}
+	i.GetSuspendedAt()
+	i = &Installation{}
+	i.GetSuspendedAt()
+	i = nil
+	i.GetSuspendedAt()
+}
+
+func TestInstallation_GetSuspendedBy(tt *testing.T) {
+	i := &Installation{}
+	i.GetSuspendedBy()
+	i = nil
+	i.GetSuspendedBy()
+}
+
 func TestInstallation_GetTargetID(tt *testing.T) {
 	var zeroValue int64
 	i := &Installation{TargetID: &zeroValue}
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index d77747d8..8a1995d0 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -569,22 +569,26 @@ func TestImport_String(t *testing.T) {
 
 func TestInstallation_String(t *testing.T) {
 	v := Installation{
-		ID:                  Int64(0),
-		NodeID:              String(""),
-		AppID:               Int64(0),
-		TargetID:            Int64(0),
-		Account:             &User{},
-		AccessTokensURL:     String(""),
-		RepositoriesURL:     String(""),
-		HTMLURL:             String(""),
-		TargetType:          String(""),
-		SingleFileName:      String(""),
-		RepositorySelection: String(""),
-		Permissions:         &InstallationPermissions{},
-		CreatedAt:           &Timestamp{},
-		UpdatedAt:           &Timestamp{},
-	}
-	want := `github.Installation{ID:0, NodeID:"", AppID:0, TargetID:0, Account:github.User{}, AccessTokensURL:"", RepositoriesURL:"", HTMLURL:"", TargetType:"", SingleFileName:"", RepositorySelection:"", Permissions:github.InstallationPermissions{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
+		ID:                     Int64(0),
+		NodeID:                 String(""),
+		AppID:                  Int64(0),
+		AppSlug:                String(""),
+		TargetID:               Int64(0),
+		Account:                &User{},
+		AccessTokensURL:        String(""),
+		RepositoriesURL:        String(""),
+		HTMLURL:                String(""),
+		TargetType:             String(""),
+		SingleFileName:         String(""),
+		RepositorySelection:    String(""),
+		Permissions:            &InstallationPermissions{},
+		CreatedAt:              &Timestamp{},
+		UpdatedAt:              &Timestamp{},
+		HasMultipleSingleFiles: Bool(false),
+		SuspendedBy:            &User{},
+		SuspendedAt:            &Timestamp{},
+	}
+	want := `github.Installation{ID:0, NodeID:"", AppID:0, AppSlug:"", TargetID:0, Account:github.User{}, AccessTokensURL:"", RepositoriesURL:"", HTMLURL:"", TargetType:"", SingleFileName:"", RepositorySelection:"", Permissions:github.InstallationPermissions{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HasMultipleSingleFiles:false, SuspendedBy:github.User{}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
 	if got := v.String(); got != want {
 		t.Errorf("Installation.String = %v, want %v", got, want)
 	}