diff --git a/.golangci.yml b/.golangci.yml index cd48ccbf4e1..c91681db34e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -205,10 +205,8 @@ linters: - AddProjectItemOptions - AuthorizationRequest - CodeScanningAlertState - - CodespaceCreateForUserOptions - ConfigApplyOptions - ConfigSettings - - CreateCodespaceOptions - CreateOrUpdateIssueTypesOptions - CreateOrgInvitationOptions - CreateUpdateEnvironment @@ -229,7 +227,6 @@ linters: - PagesUpdate - PagesUpdateWithoutCNAME - ProtectionRequest - - PublishCodespaceOptions - PullRequestBranchUpdateOptions - PullRequestReviewRequest - PullRequestReviewsEnforcementUpdate @@ -246,7 +243,6 @@ linters: - TeamAddTeamMembershipOptions - TeamAddTeamRepoOptions - TeamProjectOptions - - UpdateCodespaceOptions - UpdateDefaultSetupConfigurationOptions - UpdateProjectItemOptions - UserSuspendOptions @@ -256,18 +252,15 @@ linters: body-allowed-wrong-names: - AddProjectItemOptions - CheckSuitePreferenceOptions - - CodespaceCreateForUserOptions - ConfigApplyOptions - CreateCheckRunOptions - CreateCheckSuiteOptions - - CreateCodespaceOptions - CreateOrUpdateIssueTypesOptions - CreateOrgInvitationOptions - InstallationTokenListRepoOptions - InstallationTokenOptions - LockIssueOptions - MaintenanceOptions - - PublishCodespaceOptions - PullRequestBranchUpdateOptions - RepositoryAddCollaboratorOptions - RepositoryContentFileOptions @@ -278,7 +271,6 @@ linters: - TeamAddTeamRepoOptions - TeamProjectOptions - UpdateCheckRunOptions - - UpdateCodespaceOptions - UpdateDefaultSetupConfigurationOptions - UpdateProjectItemOptions - UserSuspendOptions diff --git a/github/codespaces.go b/github/codespaces.go index b3f9097196d..3299096ee55 100644 --- a/github/codespaces.go +++ b/github/codespaces.go @@ -150,8 +150,8 @@ func (s *CodespacesService) List(ctx context.Context, opts *ListCodespacesOption return codespaces, resp, nil } -// CreateCodespaceOptions represents options for the creation of a codespace in a repository. -type CreateCodespaceOptions struct { +// CreateCodespaceRequest represents a request to create a codespace in a repository. +type CreateCodespaceRequest struct { Ref *string `json:"ref,omitempty"` // Geo represents the geographic area for this codespace. // If not specified, the value is assigned by IP. @@ -212,11 +212,11 @@ type CodespacePullRequestOptions struct { RepositoryID int64 `json:"repository_id"` } -// CodespaceCreateForUserOptions represents options for creating a codespace for the authenticated user. -type CodespaceCreateForUserOptions struct { - PullRequest *CodespacePullRequestOptions `json:"pull_request"` +// CreateCodespaceForUserRequest represents a request to create a codespace for the authenticated user. +type CreateCodespaceForUserRequest struct { + PullRequest *CodespacePullRequestOptions `json:"pull_request,omitempty"` // RepositoryID represents the repository ID for this codespace. - RepositoryID int64 `json:"repository_id"` + RepositoryID *int64 `json:"repository_id,omitempty"` Ref *string `json:"ref,omitempty"` Geo *string `json:"geo,omitempty"` ClientIP *string `json:"client_ip,omitempty"` @@ -230,10 +230,12 @@ type CodespaceCreateForUserOptions struct { DisplayName *string `json:"display_name,omitempty"` } -// UpdateCodespaceOptions represents options for updating a codespace. -type UpdateCodespaceOptions struct { +// UpdateCodespaceRequest represents a request to update a codespace. +type UpdateCodespaceRequest struct { // Machine represents a valid machine to transition this codespace to. Machine *string `json:"machine,omitempty"` + // DisplayName represents the display name for this codespace. + DisplayName *string `json:"display_name,omitempty"` // RecentFolders represents the recently opened folders inside the codespace. // It is currently used by the clients to determine the folder path to load the codespace in. RecentFolders []string `json:"recent_folders,omitempty"` @@ -251,8 +253,8 @@ type CodespaceExport struct { HTMLURL *string `json:"html_url,omitempty"` } -// PublishCodespaceOptions represents options for creating a repository from an unpublished codespace. -type PublishCodespaceOptions struct { +// PublishCodespaceRequest represents a request to create a repository from an unpublished codespace. +type PublishCodespaceRequest struct { // Name represents the name of the new repository. Name *string `json:"name,omitempty"` // Private represents whether the new repository is private. Defaults to false. @@ -273,7 +275,7 @@ type CodespacePermissions struct { // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces?apiVersion=2022-11-28#create-a-codespace-in-a-repository // //meta:operation POST /repos/{owner}/{repo}/codespaces -func (s *CodespacesService) CreateInRepo(ctx context.Context, owner, repo string, body *CreateCodespaceOptions) (*Codespace, *Response, error) { +func (s *CodespacesService) CreateInRepo(ctx context.Context, owner, repo string, body CreateCodespaceRequest) (*Codespace, *Response, error) { u := fmt.Sprintf("repos/%v/%v/codespaces", owner, repo) req, err := s.client.NewRequest(ctx, "POST", u, body) if err != nil { @@ -444,7 +446,7 @@ func (s *CodespacesService) CheckPermissions(ctx context.Context, owner, repo, r // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces?apiVersion=2022-11-28#create-a-codespace-from-a-pull-request // //meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/codespaces -func (s *CodespacesService) CreateFromPullRequest(ctx context.Context, owner, repo string, pullNumber int, body *CreateCodespaceOptions) (*Codespace, *Response, error) { +func (s *CodespacesService) CreateFromPullRequest(ctx context.Context, owner, repo string, pullNumber int, body CreateCodespaceRequest) (*Codespace, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%v/codespaces", owner, repo, pullNumber) req, err := s.client.NewRequest(ctx, "POST", u, body) if err != nil { @@ -462,12 +464,12 @@ func (s *CodespacesService) CreateFromPullRequest(ctx context.Context, owner, re // Create creates a new codespace, owned by the authenticated user. // -// This method requires either RepositoryId OR a PullRequest but not both. +// This method requires either RepositoryID or PullRequest to be set, but not both. // // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces?apiVersion=2022-11-28#create-a-codespace-for-the-authenticated-user // //meta:operation POST /user/codespaces -func (s *CodespacesService) Create(ctx context.Context, body *CodespaceCreateForUserOptions) (*Codespace, *Response, error) { +func (s *CodespacesService) Create(ctx context.Context, body CreateCodespaceForUserRequest) (*Codespace, *Response, error) { u := "user/codespaces" req, err := s.client.NewRequest(ctx, "POST", u, body) if err != nil { @@ -511,7 +513,7 @@ func (s *CodespacesService) Get(ctx context.Context, codespaceName string) (*Cod // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces?apiVersion=2022-11-28#update-a-codespace-for-the-authenticated-user // //meta:operation PATCH /user/codespaces/{codespace_name} -func (s *CodespacesService) Update(ctx context.Context, codespaceName string, body *UpdateCodespaceOptions) (*Codespace, *Response, error) { +func (s *CodespacesService) Update(ctx context.Context, codespaceName string, body UpdateCodespaceRequest) (*Codespace, *Response, error) { u := fmt.Sprintf("user/codespaces/%v", codespaceName) req, err := s.client.NewRequest(ctx, "PATCH", u, body) if err != nil { @@ -574,7 +576,7 @@ func (s *CodespacesService) GetLatestCodespaceExport(ctx context.Context, codesp // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces?apiVersion=2022-11-28#create-a-repository-from-an-unpublished-codespace // //meta:operation POST /user/codespaces/{codespace_name}/publish -func (s *CodespacesService) Publish(ctx context.Context, codespaceName string, body *PublishCodespaceOptions) (*Codespace, *Response, error) { +func (s *CodespacesService) Publish(ctx context.Context, codespaceName string, body PublishCodespaceRequest) (*Codespace, *Response, error) { u := fmt.Sprintf("user/codespaces/%v/publish", codespaceName) req, err := s.client.NewRequest(ctx, "POST", u, body) if err != nil { diff --git a/github/codespaces_test.go b/github/codespaces_test.go index 709de4bc6ec..e8fdce22866 100644 --- a/github/codespaces_test.go +++ b/github/codespaces_test.go @@ -145,7 +145,7 @@ func TestCodespacesService_CreateInRepo(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &CreateCodespaceOptions{ + input := CreateCodespaceRequest{ Ref: new("main"), Geo: new("WestUs2"), Machine: new("standardLinux"), @@ -451,7 +451,7 @@ func TestCodespacesService_CreateFromPullRequest(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &CreateCodespaceOptions{ + input := CreateCodespaceRequest{ Machine: new("standardLinux"), IdleTimeoutMinutes: new(60), } @@ -497,25 +497,25 @@ func TestCodespacesService_Create(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &CodespaceCreateForUserOptions{ + input := CreateCodespaceForUserRequest{ Ref: new("main"), Geo: new("WestUs2"), Machine: new("standardLinux"), IdleTimeoutMinutes: new(60), - RepositoryID: int64(111), + RepositoryID: new(int64(111)), PullRequest: nil, } mux.HandleFunc("/user/codespaces", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) fmt.Fprint(w, `{"id":1,"repository":{"id":111}}`) }) ctx := t.Context() codespace, _, err := client.Codespaces.Create( ctx, - opt, + input, ) if err != nil { t.Fatalf("Codespaces.Create returned error: %v", err) @@ -536,7 +536,7 @@ func TestCodespacesService_Create(t *testing.T) { testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { got, resp, err := client.Codespaces.Create( ctx, - opt, + input, ) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) @@ -545,6 +545,24 @@ func TestCodespacesService_Create(t *testing.T) { }) } +func TestCreateCodespaceForUserRequest_Marshal(t *testing.T) { + t.Parallel() + + repoInput := CreateCodespaceForUserRequest{ + RepositoryID: new(int64(111)), + Ref: new("main"), + } + testJSONMarshal(t, repoInput, `{"repository_id":111,"ref":"main"}`) + + pullRequestInput := CreateCodespaceForUserRequest{ + PullRequest: &CodespacePullRequestOptions{ + PullRequestNumber: 42, + RepositoryID: 111, + }, + } + testJSONMarshal(t, pullRequestInput, `{"pull_request":{"pull_request_number":42,"repository_id":111}}`) +} + func TestCodespacesService_Get(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -585,8 +603,9 @@ func TestCodespacesService_Update(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &UpdateCodespaceOptions{ - Machine: new("standardLinux"), + input := UpdateCodespaceRequest{ + Machine: new("standardLinux"), + DisplayName: new("my codespace"), RecentFolders: []string{ "folder1", "folder2", @@ -595,7 +614,7 @@ func TestCodespacesService_Update(t *testing.T) { mux.HandleFunc("/user/codespaces/codespace_1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) fmt.Fprint(w, `{"id":1,"repository":{"id":111}}`) }) @@ -603,7 +622,7 @@ func TestCodespacesService_Update(t *testing.T) { codespace, _, err := client.Codespaces.Update( ctx, "codespace_1", - opt, + input, ) if err != nil { t.Fatalf("Codespaces.Update returned error: %v", err) @@ -625,7 +644,7 @@ func TestCodespacesService_Update(t *testing.T) { got, resp, err := client.Codespaces.Update( ctx, "codespace_1", - opt, + input, ) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) @@ -720,14 +739,14 @@ func TestCodespacesService_Publish(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - opt := &PublishCodespaceOptions{ + input := PublishCodespaceRequest{ Name: new("repo"), Private: new(true), } mux.HandleFunc("/user/codespaces/codespace_1/publish", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testJSONBody(t, r, opt) + testJSONBody(t, r, input) fmt.Fprint(w, `{"id":1,"repository":{"id":111}}`) }) @@ -735,7 +754,7 @@ func TestCodespacesService_Publish(t *testing.T) { repo, _, err := client.Codespaces.Publish( ctx, "codespace_1", - opt, + input, ) if err != nil { t.Fatalf("Codespaces.Publish returned error: %v", err) @@ -756,7 +775,7 @@ func TestCodespacesService_Publish(t *testing.T) { got, resp, err := client.Codespaces.Publish( ctx, "codespace_1", - opt, + input, ) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) diff --git a/github/github-accessors.go b/github/github-accessors.go index f23b7c4a17f..6dbe7453e1b 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6318,110 +6318,6 @@ func (c *Codespace) GetWebURL() string { return *c.WebURL } -// GetClientIP returns the ClientIP field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetClientIP() string { - if c == nil || c.ClientIP == nil { - return "" - } - return *c.ClientIP -} - -// GetDevcontainerPath returns the DevcontainerPath field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetDevcontainerPath() string { - if c == nil || c.DevcontainerPath == nil { - return "" - } - return *c.DevcontainerPath -} - -// GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetDisplayName() string { - if c == nil || c.DisplayName == nil { - return "" - } - return *c.DisplayName -} - -// GetGeo returns the Geo field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetGeo() string { - if c == nil || c.Geo == nil { - return "" - } - return *c.Geo -} - -// GetIdleTimeoutMinutes returns the IdleTimeoutMinutes field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetIdleTimeoutMinutes() int { - if c == nil || c.IdleTimeoutMinutes == nil { - return 0 - } - return *c.IdleTimeoutMinutes -} - -// GetLocation returns the Location field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetLocation() string { - if c == nil || c.Location == nil { - return "" - } - return *c.Location -} - -// GetMachine returns the Machine field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetMachine() string { - if c == nil || c.Machine == nil { - return "" - } - return *c.Machine -} - -// GetMultiRepoPermissionsOptOut returns the MultiRepoPermissionsOptOut field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetMultiRepoPermissionsOptOut() bool { - if c == nil || c.MultiRepoPermissionsOptOut == nil { - return false - } - return *c.MultiRepoPermissionsOptOut -} - -// GetPullRequest returns the PullRequest field. -func (c *CodespaceCreateForUserOptions) GetPullRequest() *CodespacePullRequestOptions { - if c == nil { - return nil - } - return c.PullRequest -} - -// GetRef returns the Ref field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetRef() string { - if c == nil || c.Ref == nil { - return "" - } - return *c.Ref -} - -// GetRepositoryID returns the RepositoryID field. -func (c *CodespaceCreateForUserOptions) GetRepositoryID() int64 { - if c == nil { - return 0 - } - return c.RepositoryID -} - -// GetRetentionPeriodMinutes returns the RetentionPeriodMinutes field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetRetentionPeriodMinutes() int { - if c == nil || c.RetentionPeriodMinutes == nil { - return 0 - } - return *c.RetentionPeriodMinutes -} - -// GetWorkingDirectory returns the WorkingDirectory field if it's non-nil, zero value otherwise. -func (c *CodespaceCreateForUserOptions) GetWorkingDirectory() string { - if c == nil || c.WorkingDirectory == nil { - return "" - } - return *c.WorkingDirectory -} - // GetBillableOwner returns the BillableOwner field. func (c *CodespaceDefaultAttributes) GetBillableOwner() *User { if c == nil { @@ -12055,7 +11951,7 @@ func (c *CreateCheckSuiteOptions) GetHeadSHA() string { } // GetClientIP returns the ClientIP field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetClientIP() string { +func (c *CreateCodespaceForUserRequest) GetClientIP() string { if c == nil || c.ClientIP == nil { return "" } @@ -12063,7 +11959,7 @@ func (c *CreateCodespaceOptions) GetClientIP() string { } // GetDevcontainerPath returns the DevcontainerPath field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetDevcontainerPath() string { +func (c *CreateCodespaceForUserRequest) GetDevcontainerPath() string { if c == nil || c.DevcontainerPath == nil { return "" } @@ -12071,7 +11967,7 @@ func (c *CreateCodespaceOptions) GetDevcontainerPath() string { } // GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetDisplayName() string { +func (c *CreateCodespaceForUserRequest) GetDisplayName() string { if c == nil || c.DisplayName == nil { return "" } @@ -12079,7 +11975,7 @@ func (c *CreateCodespaceOptions) GetDisplayName() string { } // GetGeo returns the Geo field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetGeo() string { +func (c *CreateCodespaceForUserRequest) GetGeo() string { if c == nil || c.Geo == nil { return "" } @@ -12087,7 +11983,7 @@ func (c *CreateCodespaceOptions) GetGeo() string { } // GetIdleTimeoutMinutes returns the IdleTimeoutMinutes field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetIdleTimeoutMinutes() int { +func (c *CreateCodespaceForUserRequest) GetIdleTimeoutMinutes() int { if c == nil || c.IdleTimeoutMinutes == nil { return 0 } @@ -12095,7 +11991,7 @@ func (c *CreateCodespaceOptions) GetIdleTimeoutMinutes() int { } // GetLocation returns the Location field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetLocation() string { +func (c *CreateCodespaceForUserRequest) GetLocation() string { if c == nil || c.Location == nil { return "" } @@ -12103,7 +11999,7 @@ func (c *CreateCodespaceOptions) GetLocation() string { } // GetMachine returns the Machine field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetMachine() string { +func (c *CreateCodespaceForUserRequest) GetMachine() string { if c == nil || c.Machine == nil { return "" } @@ -12111,7 +12007,111 @@ func (c *CreateCodespaceOptions) GetMachine() string { } // GetMultiRepoPermissionsOptOut returns the MultiRepoPermissionsOptOut field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetMultiRepoPermissionsOptOut() bool { +func (c *CreateCodespaceForUserRequest) GetMultiRepoPermissionsOptOut() bool { + if c == nil || c.MultiRepoPermissionsOptOut == nil { + return false + } + return *c.MultiRepoPermissionsOptOut +} + +// GetPullRequest returns the PullRequest field. +func (c *CreateCodespaceForUserRequest) GetPullRequest() *CodespacePullRequestOptions { + if c == nil { + return nil + } + return c.PullRequest +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceForUserRequest) GetRef() string { + if c == nil || c.Ref == nil { + return "" + } + return *c.Ref +} + +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceForUserRequest) GetRepositoryID() int64 { + if c == nil || c.RepositoryID == nil { + return 0 + } + return *c.RepositoryID +} + +// GetRetentionPeriodMinutes returns the RetentionPeriodMinutes field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceForUserRequest) GetRetentionPeriodMinutes() int { + if c == nil || c.RetentionPeriodMinutes == nil { + return 0 + } + return *c.RetentionPeriodMinutes +} + +// GetWorkingDirectory returns the WorkingDirectory field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceForUserRequest) GetWorkingDirectory() string { + if c == nil || c.WorkingDirectory == nil { + return "" + } + return *c.WorkingDirectory +} + +// GetClientIP returns the ClientIP field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetClientIP() string { + if c == nil || c.ClientIP == nil { + return "" + } + return *c.ClientIP +} + +// GetDevcontainerPath returns the DevcontainerPath field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetDevcontainerPath() string { + if c == nil || c.DevcontainerPath == nil { + return "" + } + return *c.DevcontainerPath +} + +// GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetDisplayName() string { + if c == nil || c.DisplayName == nil { + return "" + } + return *c.DisplayName +} + +// GetGeo returns the Geo field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetGeo() string { + if c == nil || c.Geo == nil { + return "" + } + return *c.Geo +} + +// GetIdleTimeoutMinutes returns the IdleTimeoutMinutes field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetIdleTimeoutMinutes() int { + if c == nil || c.IdleTimeoutMinutes == nil { + return 0 + } + return *c.IdleTimeoutMinutes +} + +// GetLocation returns the Location field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetLocation() string { + if c == nil || c.Location == nil { + return "" + } + return *c.Location +} + +// GetMachine returns the Machine field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetMachine() string { + if c == nil || c.Machine == nil { + return "" + } + return *c.Machine +} + +// GetMultiRepoPermissionsOptOut returns the MultiRepoPermissionsOptOut field if it's non-nil, zero value otherwise. +func (c *CreateCodespaceRequest) GetMultiRepoPermissionsOptOut() bool { if c == nil || c.MultiRepoPermissionsOptOut == nil { return false } @@ -12119,7 +12119,7 @@ func (c *CreateCodespaceOptions) GetMultiRepoPermissionsOptOut() bool { } // GetRef returns the Ref field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetRef() string { +func (c *CreateCodespaceRequest) GetRef() string { if c == nil || c.Ref == nil { return "" } @@ -12127,7 +12127,7 @@ func (c *CreateCodespaceOptions) GetRef() string { } // GetRetentionPeriodMinutes returns the RetentionPeriodMinutes field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetRetentionPeriodMinutes() int { +func (c *CreateCodespaceRequest) GetRetentionPeriodMinutes() int { if c == nil || c.RetentionPeriodMinutes == nil { return 0 } @@ -12135,7 +12135,7 @@ func (c *CreateCodespaceOptions) GetRetentionPeriodMinutes() int { } // GetWorkingDirectory returns the WorkingDirectory field if it's non-nil, zero value otherwise. -func (c *CreateCodespaceOptions) GetWorkingDirectory() string { +func (c *CreateCodespaceRequest) GetWorkingDirectory() string { if c == nil || c.WorkingDirectory == nil { return "" } @@ -32199,7 +32199,7 @@ func (p *PublicKey) GetURL() string { } // GetName returns the Name field if it's non-nil, zero value otherwise. -func (p *PublishCodespaceOptions) GetName() string { +func (p *PublishCodespaceRequest) GetName() string { if p == nil || p.Name == nil { return "" } @@ -32207,7 +32207,7 @@ func (p *PublishCodespaceOptions) GetName() string { } // GetPrivate returns the Private field if it's non-nil, zero value otherwise. -func (p *PublishCodespaceOptions) GetPrivate() bool { +func (p *PublishCodespaceRequest) GetPrivate() bool { if p == nil || p.Private == nil { return false } @@ -45310,8 +45310,16 @@ func (u *UpdateCheckRunOptions) GetStatus() string { return *u.Status } +// GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. +func (u *UpdateCodespaceRequest) GetDisplayName() string { + if u == nil || u.DisplayName == nil { + return "" + } + return *u.DisplayName +} + // GetMachine returns the Machine field if it's non-nil, zero value otherwise. -func (u *UpdateCodespaceOptions) GetMachine() string { +func (u *UpdateCodespaceRequest) GetMachine() string { if u == nil || u.Machine == nil { return "" } @@ -45319,7 +45327,7 @@ func (u *UpdateCodespaceOptions) GetMachine() string { } // GetRecentFolders returns the RecentFolders slice if it's non-nil, nil otherwise. -func (u *UpdateCodespaceOptions) GetRecentFolders() []string { +func (u *UpdateCodespaceRequest) GetRecentFolders() []string { if u == nil || u.RecentFolders == nil { return nil } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 6eb92308b58..c0eb4b2f8de 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8020,143 +8020,6 @@ func TestCodespace_GetWebURL(tt *testing.T) { c.GetWebURL() } -func TestCodespaceCreateForUserOptions_GetClientIP(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{ClientIP: &zeroValue} - c.GetClientIP() - c = &CodespaceCreateForUserOptions{} - c.GetClientIP() - c = nil - c.GetClientIP() -} - -func TestCodespaceCreateForUserOptions_GetDevcontainerPath(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{DevcontainerPath: &zeroValue} - c.GetDevcontainerPath() - c = &CodespaceCreateForUserOptions{} - c.GetDevcontainerPath() - c = nil - c.GetDevcontainerPath() -} - -func TestCodespaceCreateForUserOptions_GetDisplayName(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{DisplayName: &zeroValue} - c.GetDisplayName() - c = &CodespaceCreateForUserOptions{} - c.GetDisplayName() - c = nil - c.GetDisplayName() -} - -func TestCodespaceCreateForUserOptions_GetGeo(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{Geo: &zeroValue} - c.GetGeo() - c = &CodespaceCreateForUserOptions{} - c.GetGeo() - c = nil - c.GetGeo() -} - -func TestCodespaceCreateForUserOptions_GetIdleTimeoutMinutes(tt *testing.T) { - tt.Parallel() - var zeroValue int - c := &CodespaceCreateForUserOptions{IdleTimeoutMinutes: &zeroValue} - c.GetIdleTimeoutMinutes() - c = &CodespaceCreateForUserOptions{} - c.GetIdleTimeoutMinutes() - c = nil - c.GetIdleTimeoutMinutes() -} - -func TestCodespaceCreateForUserOptions_GetLocation(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{Location: &zeroValue} - c.GetLocation() - c = &CodespaceCreateForUserOptions{} - c.GetLocation() - c = nil - c.GetLocation() -} - -func TestCodespaceCreateForUserOptions_GetMachine(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{Machine: &zeroValue} - c.GetMachine() - c = &CodespaceCreateForUserOptions{} - c.GetMachine() - c = nil - c.GetMachine() -} - -func TestCodespaceCreateForUserOptions_GetMultiRepoPermissionsOptOut(tt *testing.T) { - tt.Parallel() - var zeroValue bool - c := &CodespaceCreateForUserOptions{MultiRepoPermissionsOptOut: &zeroValue} - c.GetMultiRepoPermissionsOptOut() - c = &CodespaceCreateForUserOptions{} - c.GetMultiRepoPermissionsOptOut() - c = nil - c.GetMultiRepoPermissionsOptOut() -} - -func TestCodespaceCreateForUserOptions_GetPullRequest(tt *testing.T) { - tt.Parallel() - c := &CodespaceCreateForUserOptions{} - c.GetPullRequest() - c = nil - c.GetPullRequest() -} - -func TestCodespaceCreateForUserOptions_GetRef(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{Ref: &zeroValue} - c.GetRef() - c = &CodespaceCreateForUserOptions{} - c.GetRef() - c = nil - c.GetRef() -} - -func TestCodespaceCreateForUserOptions_GetRepositoryID(tt *testing.T) { - tt.Parallel() - c := &CodespaceCreateForUserOptions{} - c.GetRepositoryID() - c = nil - c.GetRepositoryID() -} - -func TestCodespaceCreateForUserOptions_GetRetentionPeriodMinutes(tt *testing.T) { - tt.Parallel() - var zeroValue int - c := &CodespaceCreateForUserOptions{RetentionPeriodMinutes: &zeroValue} - c.GetRetentionPeriodMinutes() - c = &CodespaceCreateForUserOptions{} - c.GetRetentionPeriodMinutes() - c = nil - c.GetRetentionPeriodMinutes() -} - -func TestCodespaceCreateForUserOptions_GetWorkingDirectory(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CodespaceCreateForUserOptions{WorkingDirectory: &zeroValue} - c.GetWorkingDirectory() - c = &CodespaceCreateForUserOptions{} - c.GetWorkingDirectory() - c = nil - c.GetWorkingDirectory() -} - func TestCodespaceDefaultAttributes_GetBillableOwner(tt *testing.T) { tt.Parallel() c := &CodespaceDefaultAttributes{} @@ -15199,122 +15062,262 @@ func TestCreateCheckSuiteOptions_GetHeadSHA(tt *testing.T) { c.GetHeadSHA() } -func TestCreateCodespaceOptions_GetClientIP(tt *testing.T) { +func TestCreateCodespaceForUserRequest_GetClientIP(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{ClientIP: &zeroValue} + c.GetClientIP() + c = &CreateCodespaceForUserRequest{} + c.GetClientIP() + c = nil + c.GetClientIP() +} + +func TestCreateCodespaceForUserRequest_GetDevcontainerPath(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{DevcontainerPath: &zeroValue} + c.GetDevcontainerPath() + c = &CreateCodespaceForUserRequest{} + c.GetDevcontainerPath() + c = nil + c.GetDevcontainerPath() +} + +func TestCreateCodespaceForUserRequest_GetDisplayName(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{ClientIP: &zeroValue} + c := &CreateCodespaceForUserRequest{DisplayName: &zeroValue} + c.GetDisplayName() + c = &CreateCodespaceForUserRequest{} + c.GetDisplayName() + c = nil + c.GetDisplayName() +} + +func TestCreateCodespaceForUserRequest_GetGeo(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{Geo: &zeroValue} + c.GetGeo() + c = &CreateCodespaceForUserRequest{} + c.GetGeo() + c = nil + c.GetGeo() +} + +func TestCreateCodespaceForUserRequest_GetIdleTimeoutMinutes(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CreateCodespaceForUserRequest{IdleTimeoutMinutes: &zeroValue} + c.GetIdleTimeoutMinutes() + c = &CreateCodespaceForUserRequest{} + c.GetIdleTimeoutMinutes() + c = nil + c.GetIdleTimeoutMinutes() +} + +func TestCreateCodespaceForUserRequest_GetLocation(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{Location: &zeroValue} + c.GetLocation() + c = &CreateCodespaceForUserRequest{} + c.GetLocation() + c = nil + c.GetLocation() +} + +func TestCreateCodespaceForUserRequest_GetMachine(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{Machine: &zeroValue} + c.GetMachine() + c = &CreateCodespaceForUserRequest{} + c.GetMachine() + c = nil + c.GetMachine() +} + +func TestCreateCodespaceForUserRequest_GetMultiRepoPermissionsOptOut(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &CreateCodespaceForUserRequest{MultiRepoPermissionsOptOut: &zeroValue} + c.GetMultiRepoPermissionsOptOut() + c = &CreateCodespaceForUserRequest{} + c.GetMultiRepoPermissionsOptOut() + c = nil + c.GetMultiRepoPermissionsOptOut() +} + +func TestCreateCodespaceForUserRequest_GetPullRequest(tt *testing.T) { + tt.Parallel() + c := &CreateCodespaceForUserRequest{} + c.GetPullRequest() + c = nil + c.GetPullRequest() +} + +func TestCreateCodespaceForUserRequest_GetRef(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{Ref: &zeroValue} + c.GetRef() + c = &CreateCodespaceForUserRequest{} + c.GetRef() + c = nil + c.GetRef() +} + +func TestCreateCodespaceForUserRequest_GetRepositoryID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + c := &CreateCodespaceForUserRequest{RepositoryID: &zeroValue} + c.GetRepositoryID() + c = &CreateCodespaceForUserRequest{} + c.GetRepositoryID() + c = nil + c.GetRepositoryID() +} + +func TestCreateCodespaceForUserRequest_GetRetentionPeriodMinutes(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CreateCodespaceForUserRequest{RetentionPeriodMinutes: &zeroValue} + c.GetRetentionPeriodMinutes() + c = &CreateCodespaceForUserRequest{} + c.GetRetentionPeriodMinutes() + c = nil + c.GetRetentionPeriodMinutes() +} + +func TestCreateCodespaceForUserRequest_GetWorkingDirectory(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceForUserRequest{WorkingDirectory: &zeroValue} + c.GetWorkingDirectory() + c = &CreateCodespaceForUserRequest{} + c.GetWorkingDirectory() + c = nil + c.GetWorkingDirectory() +} + +func TestCreateCodespaceRequest_GetClientIP(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCodespaceRequest{ClientIP: &zeroValue} c.GetClientIP() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetClientIP() c = nil c.GetClientIP() } -func TestCreateCodespaceOptions_GetDevcontainerPath(tt *testing.T) { +func TestCreateCodespaceRequest_GetDevcontainerPath(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{DevcontainerPath: &zeroValue} + c := &CreateCodespaceRequest{DevcontainerPath: &zeroValue} c.GetDevcontainerPath() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetDevcontainerPath() c = nil c.GetDevcontainerPath() } -func TestCreateCodespaceOptions_GetDisplayName(tt *testing.T) { +func TestCreateCodespaceRequest_GetDisplayName(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{DisplayName: &zeroValue} + c := &CreateCodespaceRequest{DisplayName: &zeroValue} c.GetDisplayName() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetDisplayName() c = nil c.GetDisplayName() } -func TestCreateCodespaceOptions_GetGeo(tt *testing.T) { +func TestCreateCodespaceRequest_GetGeo(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{Geo: &zeroValue} + c := &CreateCodespaceRequest{Geo: &zeroValue} c.GetGeo() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetGeo() c = nil c.GetGeo() } -func TestCreateCodespaceOptions_GetIdleTimeoutMinutes(tt *testing.T) { +func TestCreateCodespaceRequest_GetIdleTimeoutMinutes(tt *testing.T) { tt.Parallel() var zeroValue int - c := &CreateCodespaceOptions{IdleTimeoutMinutes: &zeroValue} + c := &CreateCodespaceRequest{IdleTimeoutMinutes: &zeroValue} c.GetIdleTimeoutMinutes() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetIdleTimeoutMinutes() c = nil c.GetIdleTimeoutMinutes() } -func TestCreateCodespaceOptions_GetLocation(tt *testing.T) { +func TestCreateCodespaceRequest_GetLocation(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{Location: &zeroValue} + c := &CreateCodespaceRequest{Location: &zeroValue} c.GetLocation() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetLocation() c = nil c.GetLocation() } -func TestCreateCodespaceOptions_GetMachine(tt *testing.T) { +func TestCreateCodespaceRequest_GetMachine(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{Machine: &zeroValue} + c := &CreateCodespaceRequest{Machine: &zeroValue} c.GetMachine() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetMachine() c = nil c.GetMachine() } -func TestCreateCodespaceOptions_GetMultiRepoPermissionsOptOut(tt *testing.T) { +func TestCreateCodespaceRequest_GetMultiRepoPermissionsOptOut(tt *testing.T) { tt.Parallel() var zeroValue bool - c := &CreateCodespaceOptions{MultiRepoPermissionsOptOut: &zeroValue} + c := &CreateCodespaceRequest{MultiRepoPermissionsOptOut: &zeroValue} c.GetMultiRepoPermissionsOptOut() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetMultiRepoPermissionsOptOut() c = nil c.GetMultiRepoPermissionsOptOut() } -func TestCreateCodespaceOptions_GetRef(tt *testing.T) { +func TestCreateCodespaceRequest_GetRef(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{Ref: &zeroValue} + c := &CreateCodespaceRequest{Ref: &zeroValue} c.GetRef() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetRef() c = nil c.GetRef() } -func TestCreateCodespaceOptions_GetRetentionPeriodMinutes(tt *testing.T) { +func TestCreateCodespaceRequest_GetRetentionPeriodMinutes(tt *testing.T) { tt.Parallel() var zeroValue int - c := &CreateCodespaceOptions{RetentionPeriodMinutes: &zeroValue} + c := &CreateCodespaceRequest{RetentionPeriodMinutes: &zeroValue} c.GetRetentionPeriodMinutes() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetRetentionPeriodMinutes() c = nil c.GetRetentionPeriodMinutes() } -func TestCreateCodespaceOptions_GetWorkingDirectory(tt *testing.T) { +func TestCreateCodespaceRequest_GetWorkingDirectory(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CreateCodespaceOptions{WorkingDirectory: &zeroValue} + c := &CreateCodespaceRequest{WorkingDirectory: &zeroValue} c.GetWorkingDirectory() - c = &CreateCodespaceOptions{} + c = &CreateCodespaceRequest{} c.GetWorkingDirectory() c = nil c.GetWorkingDirectory() @@ -40332,23 +40335,23 @@ func TestPublicKey_GetURL(tt *testing.T) { p.GetURL() } -func TestPublishCodespaceOptions_GetName(tt *testing.T) { +func TestPublishCodespaceRequest_GetName(tt *testing.T) { tt.Parallel() var zeroValue string - p := &PublishCodespaceOptions{Name: &zeroValue} + p := &PublishCodespaceRequest{Name: &zeroValue} p.GetName() - p = &PublishCodespaceOptions{} + p = &PublishCodespaceRequest{} p.GetName() p = nil p.GetName() } -func TestPublishCodespaceOptions_GetPrivate(tt *testing.T) { +func TestPublishCodespaceRequest_GetPrivate(tt *testing.T) { tt.Parallel() var zeroValue bool - p := &PublishCodespaceOptions{Private: &zeroValue} + p := &PublishCodespaceRequest{Private: &zeroValue} p.GetPrivate() - p = &PublishCodespaceOptions{} + p = &PublishCodespaceRequest{} p.GetPrivate() p = nil p.GetPrivate() @@ -56546,23 +56549,34 @@ func TestUpdateCheckRunOptions_GetStatus(tt *testing.T) { u.GetStatus() } -func TestUpdateCodespaceOptions_GetMachine(tt *testing.T) { +func TestUpdateCodespaceRequest_GetDisplayName(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateCodespaceRequest{DisplayName: &zeroValue} + u.GetDisplayName() + u = &UpdateCodespaceRequest{} + u.GetDisplayName() + u = nil + u.GetDisplayName() +} + +func TestUpdateCodespaceRequest_GetMachine(tt *testing.T) { tt.Parallel() var zeroValue string - u := &UpdateCodespaceOptions{Machine: &zeroValue} + u := &UpdateCodespaceRequest{Machine: &zeroValue} u.GetMachine() - u = &UpdateCodespaceOptions{} + u = &UpdateCodespaceRequest{} u.GetMachine() u = nil u.GetMachine() } -func TestUpdateCodespaceOptions_GetRecentFolders(tt *testing.T) { +func TestUpdateCodespaceRequest_GetRecentFolders(tt *testing.T) { tt.Parallel() zeroValue := []string{} - u := &UpdateCodespaceOptions{RecentFolders: zeroValue} + u := &UpdateCodespaceRequest{RecentFolders: zeroValue} u.GetRecentFolders() - u = &UpdateCodespaceOptions{} + u = &UpdateCodespaceRequest{} u.GetRecentFolders() u = nil u.GetRecentFolders()