diff --git a/github/event_types.go b/github/event_types.go index 5321a91f80b..37e62c2fab9 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1083,63 +1083,13 @@ type PingEvent struct { Installation *Installation `json:"installation,omitempty"` } -// ProjectEvent is triggered when project is created, modified or deleted. -// The webhook event name is "project". -// -// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project -type ProjectEvent struct { - Action *string `json:"action,omitempty"` - Changes *ProjectChange `json:"changes,omitempty"` - Project *Project `json:"project,omitempty"` - - // The following fields are only populated by Webhook events. - Repo *Repository `json:"repository,omitempty"` - Org *Organization `json:"organization,omitempty"` - Sender *User `json:"sender,omitempty"` - Installation *Installation `json:"installation,omitempty"` -} - -// ProjectCardEvent is triggered when a project card is created, updated, moved, converted to an issue, or deleted. -// The webhook event name is "project_card". -// -// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_card -type ProjectCardEvent struct { - Action *string `json:"action,omitempty"` - Changes *ProjectCardChange `json:"changes,omitempty"` - AfterID *int64 `json:"after_id,omitempty"` - ProjectCard *ProjectCard `json:"project_card,omitempty"` - - // The following fields are only populated by Webhook events. - Repo *Repository `json:"repository,omitempty"` - Org *Organization `json:"organization,omitempty"` - Sender *User `json:"sender,omitempty"` - Installation *Installation `json:"installation,omitempty"` -} - -// ProjectColumnEvent is triggered when a project column is created, updated, moved, or deleted. -// The webhook event name is "project_column". -// -// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_column -type ProjectColumnEvent struct { - Action *string `json:"action,omitempty"` - Changes *ProjectColumnChange `json:"changes,omitempty"` - AfterID *int64 `json:"after_id,omitempty"` - ProjectColumn *ProjectColumn `json:"project_column,omitempty"` - - // The following fields are only populated by Webhook events. - Repo *Repository `json:"repository,omitempty"` - Org *Organization `json:"organization,omitempty"` - Sender *User `json:"sender,omitempty"` - Installation *Installation `json:"installation,omitempty"` -} - // ProjectV2Event is triggered when there is activity relating to an organization-level project. // The Webhook event name is "projects_v2". // // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2 type ProjectV2Event struct { - Action *string `json:"action,omitempty"` - ProjectsV2 *ProjectsV2 `json:"projects_v2,omitempty"` + Action *string `json:"action,omitempty"` + ProjectsV2 *ProjectV2 `json:"projects_v2,omitempty"` // The following fields are only populated by Webhook events. Installation *Installation `json:"installation,omitempty"` @@ -1147,8 +1097,8 @@ type ProjectV2Event struct { Sender *User `json:"sender,omitempty"` } -// ProjectsV2 represents a projects v2 project. -type ProjectsV2 struct { +// ProjectV2 represents a v2 project. +type ProjectV2 struct { ID *int64 `json:"id,omitempty"` NodeID *string `json:"node_id,omitempty"` Owner *User `json:"owner,omitempty"` @@ -1163,6 +1113,17 @@ type ProjectsV2 struct { Number *int `json:"number,omitempty"` ShortDescription *string `json:"short_description,omitempty"` DeletedBy *User `json:"deleted_by,omitempty"` + + // Fields migrated from the Project (classic) struct: + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + ColumnsURL *string `json:"columns_url,omitempty"` + OwnerURL *string `json:"owner_url,omitempty"` + Name *string `json:"name,omitempty"` + Body *string `json:"body,omitempty"` + State *string `json:"state,omitempty"` + OrganizationPermission *string `json:"organization_permission,omitempty"` + Private *bool `json:"private,omitempty"` } // ProjectV2ItemEvent is triggered when there is activity relating to an item on an organization-level project. diff --git a/github/event_types_test.go b/github/event_types_test.go index fcf852336c6..66d4e4989a7 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -16898,888 +16898,13 @@ func TestPushEventRepoOwner_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } -func TestProjectEvent_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectEvent{}, "{}") - - u := &ProjectEvent{ - Project: &Project{ID: Ptr(int64(1))}, - Action: Ptr("a"), - Changes: &ProjectChange{ - Name: &ProjectName{From: Ptr("NameFrom")}, - Body: &ProjectBody{From: Ptr("BodyFrom")}, - }, - Repo: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("s"), - Name: Ptr("n"), - }, - Org: &Organization{ - BillingEmail: Ptr("be"), - Blog: Ptr("b"), - Company: Ptr("c"), - Email: Ptr("e"), - TwitterUsername: Ptr("tu"), - Location: Ptr("loc"), - Name: Ptr("n"), - Description: Ptr("d"), - IsVerified: Ptr(true), - HasOrganizationProjects: Ptr(true), - HasRepositoryProjects: Ptr(true), - DefaultRepoPermission: Ptr("drp"), - MembersCanCreateRepos: Ptr(true), - MembersCanCreateInternalRepos: Ptr(true), - MembersCanCreatePrivateRepos: Ptr(true), - MembersCanCreatePublicRepos: Ptr(false), - MembersAllowedRepositoryCreationType: Ptr("marct"), - MembersCanCreatePages: Ptr(true), - MembersCanCreatePublicPages: Ptr(false), - MembersCanCreatePrivatePages: Ptr(true), - }, - Sender: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - URL: Ptr("u"), - ReposURL: Ptr("r"), - EventsURL: Ptr("e"), - AvatarURL: Ptr("a"), - }, - Installation: &Installation{ - ID: Ptr(int64(1)), - NodeID: Ptr("nid"), - AppID: Ptr(int64(1)), - AppSlug: Ptr("as"), - TargetID: Ptr(int64(1)), - Account: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - AccessTokensURL: Ptr("atu"), - RepositoriesURL: Ptr("ru"), - HTMLURL: Ptr("hu"), - TargetType: Ptr("tt"), - SingleFileName: Ptr("sfn"), - RepositorySelection: Ptr("rs"), - Events: []string{"e"}, - SingleFilePaths: []string{"s"}, - Permissions: &InstallationPermissions{ - Actions: Ptr("a"), - Administration: Ptr("ad"), - Checks: Ptr("c"), - Contents: Ptr("co"), - ContentReferences: Ptr("cr"), - Deployments: Ptr("d"), - Environments: Ptr("e"), - Issues: Ptr("i"), - Metadata: Ptr("md"), - Members: Ptr("m"), - OrganizationAdministration: Ptr("oa"), - OrganizationHooks: Ptr("oh"), - OrganizationPlan: Ptr("op"), - OrganizationPreReceiveHooks: Ptr("opr"), - OrganizationProjects: Ptr("op"), - OrganizationSecrets: Ptr("os"), - OrganizationSelfHostedRunners: Ptr("osh"), - OrganizationUserBlocking: Ptr("oub"), - Packages: Ptr("pkg"), - Pages: Ptr("pg"), - PullRequests: Ptr("pr"), - RepositoryHooks: Ptr("rh"), - RepositoryProjects: Ptr("rp"), - RepositoryPreReceiveHooks: Ptr("rprh"), - Secrets: Ptr("s"), - SecretScanningAlerts: Ptr("ssa"), - SecurityEvents: Ptr("se"), - SingleFile: Ptr("sf"), - Statuses: Ptr("s"), - TeamDiscussions: Ptr("td"), - VulnerabilityAlerts: Ptr("va"), - Workflows: Ptr("w"), - }, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - HasMultipleSingleFiles: Ptr(false), - SuspendedBy: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - SuspendedAt: &Timestamp{referenceTime}, - }, - } - - want := `{ - "action": "a", - "changes": { - "name": { - "from": "NameFrom" - }, - "body": { - "from": "BodyFrom" - } - }, - "project": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "id": 1, - "node_id": "nid", - "app_id": 1, - "app_slug": "as", - "target_id": 1, - "account": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "access_tokens_url": "atu", - "repositories_url": "ru", - "html_url": "hu", - "target_type": "tt", - "single_file_name": "sfn", - "repository_selection": "rs", - "events": [ - "e" - ], - "single_file_paths": [ - "s" - ], - "permissions": { - "actions": "a", - "administration": "ad", - "checks": "c", - "contents": "co", - "content_references": "cr", - "deployments": "d", - "environments": "e", - "issues": "i", - "metadata": "md", - "members": "m", - "organization_administration": "oa", - "organization_hooks": "oh", - "organization_plan": "op", - "organization_pre_receive_hooks": "opr", - "organization_projects": "op", - "organization_secrets": "os", - "organization_self_hosted_runners": "osh", - "organization_user_blocking": "oub", - "packages": "pkg", - "pages": "pg", - "pull_requests": "pr", - "repository_hooks": "rh", - "repository_projects": "rp", - "repository_pre_receive_hooks": "rprh", - "secrets": "s", - "secret_scanning_alerts": "ssa", - "security_events": "se", - "single_file": "sf", - "statuses": "s", - "team_discussions": "td", - "vulnerability_alerts": "va", - "workflows": "w" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "has_multiple_single_files": false, - "suspended_by": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "suspended_at": ` + referenceTimeStr + ` - } - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectCardEvent_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectCardEvent{}, "{}") - - u := &ProjectCardEvent{ - Action: Ptr("a"), - Changes: &ProjectCardChange{ - Note: &ProjectCardNote{From: Ptr("NoteFrom")}, - }, - AfterID: Ptr(int64(1)), - ProjectCard: &ProjectCard{ID: Ptr(int64(1))}, - Repo: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("s"), - Name: Ptr("n"), - }, - Org: &Organization{ - BillingEmail: Ptr("be"), - Blog: Ptr("b"), - Company: Ptr("c"), - Email: Ptr("e"), - TwitterUsername: Ptr("tu"), - Location: Ptr("loc"), - Name: Ptr("n"), - Description: Ptr("d"), - IsVerified: Ptr(true), - HasOrganizationProjects: Ptr(true), - HasRepositoryProjects: Ptr(true), - DefaultRepoPermission: Ptr("drp"), - MembersCanCreateRepos: Ptr(true), - MembersCanCreateInternalRepos: Ptr(true), - MembersCanCreatePrivateRepos: Ptr(true), - MembersCanCreatePublicRepos: Ptr(false), - MembersAllowedRepositoryCreationType: Ptr("marct"), - MembersCanCreatePages: Ptr(true), - MembersCanCreatePublicPages: Ptr(false), - MembersCanCreatePrivatePages: Ptr(true), - }, - Sender: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - URL: Ptr("u"), - ReposURL: Ptr("r"), - EventsURL: Ptr("e"), - AvatarURL: Ptr("a"), - }, - Installation: &Installation{ - ID: Ptr(int64(1)), - NodeID: Ptr("nid"), - AppID: Ptr(int64(1)), - AppSlug: Ptr("as"), - TargetID: Ptr(int64(1)), - Account: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - AccessTokensURL: Ptr("atu"), - RepositoriesURL: Ptr("ru"), - HTMLURL: Ptr("hu"), - TargetType: Ptr("tt"), - SingleFileName: Ptr("sfn"), - RepositorySelection: Ptr("rs"), - Events: []string{"e"}, - SingleFilePaths: []string{"s"}, - Permissions: &InstallationPermissions{ - Actions: Ptr("a"), - Administration: Ptr("ad"), - Checks: Ptr("c"), - Contents: Ptr("co"), - ContentReferences: Ptr("cr"), - Deployments: Ptr("d"), - Environments: Ptr("e"), - Issues: Ptr("i"), - Metadata: Ptr("md"), - Members: Ptr("m"), - OrganizationAdministration: Ptr("oa"), - OrganizationHooks: Ptr("oh"), - OrganizationPlan: Ptr("op"), - OrganizationPreReceiveHooks: Ptr("opr"), - OrganizationProjects: Ptr("op"), - OrganizationSecrets: Ptr("os"), - OrganizationSelfHostedRunners: Ptr("osh"), - OrganizationUserBlocking: Ptr("oub"), - Packages: Ptr("pkg"), - Pages: Ptr("pg"), - PullRequests: Ptr("pr"), - RepositoryHooks: Ptr("rh"), - RepositoryProjects: Ptr("rp"), - RepositoryPreReceiveHooks: Ptr("rprh"), - Secrets: Ptr("s"), - SecretScanningAlerts: Ptr("ssa"), - SecurityEvents: Ptr("se"), - SingleFile: Ptr("sf"), - Statuses: Ptr("s"), - TeamDiscussions: Ptr("td"), - VulnerabilityAlerts: Ptr("va"), - Workflows: Ptr("w"), - }, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - HasMultipleSingleFiles: Ptr(false), - SuspendedBy: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - SuspendedAt: &Timestamp{referenceTime}, - }, - } - - want := `{ - "action": "a", - "changes": { - "note": { - "from": "NoteFrom" - } - }, - "after_id": 1, - "project_card": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "id": 1, - "node_id": "nid", - "app_id": 1, - "app_slug": "as", - "target_id": 1, - "account": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "access_tokens_url": "atu", - "repositories_url": "ru", - "html_url": "hu", - "target_type": "tt", - "single_file_name": "sfn", - "repository_selection": "rs", - "events": [ - "e" - ], - "single_file_paths": [ - "s" - ], - "permissions": { - "actions": "a", - "administration": "ad", - "checks": "c", - "contents": "co", - "content_references": "cr", - "deployments": "d", - "environments": "e", - "issues": "i", - "metadata": "md", - "members": "m", - "organization_administration": "oa", - "organization_hooks": "oh", - "organization_plan": "op", - "organization_pre_receive_hooks": "opr", - "organization_projects": "op", - "organization_secrets": "os", - "organization_self_hosted_runners": "osh", - "organization_user_blocking": "oub", - "packages": "pkg", - "pages": "pg", - "pull_requests": "pr", - "repository_hooks": "rh", - "repository_projects": "rp", - "repository_pre_receive_hooks": "rprh", - "secrets": "s", - "secret_scanning_alerts": "ssa", - "security_events": "se", - "single_file": "sf", - "statuses": "s", - "team_discussions": "td", - "vulnerability_alerts": "va", - "workflows": "w" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "has_multiple_single_files": false, - "suspended_by": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "suspended_at": ` + referenceTimeStr + ` - } - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectColumnEvent_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectColumnEvent{}, "{}") - - u := &ProjectColumnEvent{ - Action: Ptr("a"), - Changes: &ProjectColumnChange{ - Name: &ProjectColumnName{From: Ptr("NameFrom")}, - }, - AfterID: Ptr(int64(1)), - ProjectColumn: &ProjectColumn{ID: Ptr(int64(1))}, - Repo: &Repository{ - ID: Ptr(int64(1)), - URL: Ptr("s"), - Name: Ptr("n"), - }, - Org: &Organization{ - BillingEmail: Ptr("be"), - Blog: Ptr("b"), - Company: Ptr("c"), - Email: Ptr("e"), - TwitterUsername: Ptr("tu"), - Location: Ptr("loc"), - Name: Ptr("n"), - Description: Ptr("d"), - IsVerified: Ptr(true), - HasOrganizationProjects: Ptr(true), - HasRepositoryProjects: Ptr(true), - DefaultRepoPermission: Ptr("drp"), - MembersCanCreateRepos: Ptr(true), - MembersCanCreateInternalRepos: Ptr(true), - MembersCanCreatePrivateRepos: Ptr(true), - MembersCanCreatePublicRepos: Ptr(false), - MembersAllowedRepositoryCreationType: Ptr("marct"), - MembersCanCreatePages: Ptr(true), - MembersCanCreatePublicPages: Ptr(false), - MembersCanCreatePrivatePages: Ptr(true), - }, - Sender: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - NodeID: Ptr("n"), - URL: Ptr("u"), - ReposURL: Ptr("r"), - EventsURL: Ptr("e"), - AvatarURL: Ptr("a"), - }, - Installation: &Installation{ - ID: Ptr(int64(1)), - NodeID: Ptr("nid"), - AppID: Ptr(int64(1)), - AppSlug: Ptr("as"), - TargetID: Ptr(int64(1)), - Account: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - AccessTokensURL: Ptr("atu"), - RepositoriesURL: Ptr("ru"), - HTMLURL: Ptr("hu"), - TargetType: Ptr("tt"), - SingleFileName: Ptr("sfn"), - RepositorySelection: Ptr("rs"), - Events: []string{"e"}, - SingleFilePaths: []string{"s"}, - Permissions: &InstallationPermissions{ - Actions: Ptr("a"), - Administration: Ptr("ad"), - Checks: Ptr("c"), - Contents: Ptr("co"), - ContentReferences: Ptr("cr"), - Deployments: Ptr("d"), - Environments: Ptr("e"), - Issues: Ptr("i"), - Metadata: Ptr("md"), - Members: Ptr("m"), - OrganizationAdministration: Ptr("oa"), - OrganizationHooks: Ptr("oh"), - OrganizationPlan: Ptr("op"), - OrganizationPreReceiveHooks: Ptr("opr"), - OrganizationProjects: Ptr("op"), - OrganizationSecrets: Ptr("os"), - OrganizationSelfHostedRunners: Ptr("osh"), - OrganizationUserBlocking: Ptr("oub"), - Packages: Ptr("pkg"), - Pages: Ptr("pg"), - PullRequests: Ptr("pr"), - RepositoryHooks: Ptr("rh"), - RepositoryProjects: Ptr("rp"), - RepositoryPreReceiveHooks: Ptr("rprh"), - Secrets: Ptr("s"), - SecretScanningAlerts: Ptr("ssa"), - SecurityEvents: Ptr("se"), - SingleFile: Ptr("sf"), - Statuses: Ptr("s"), - TeamDiscussions: Ptr("td"), - VulnerabilityAlerts: Ptr("va"), - Workflows: Ptr("w"), - }, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - HasMultipleSingleFiles: Ptr(false), - SuspendedBy: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - SuspendedAt: &Timestamp{referenceTime}, - }, - } - - want := `{ - "action": "a", - "changes": { - "name": { - "from": "NameFrom" - } - }, - "after_id": 1, - "project_column": { - "id": 1 - }, - "repository": { - "id": 1, - "name": "n", - "url": "s" - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "sender": { - "login": "l", - "id": 1, - "node_id": "n", - "avatar_url": "a", - "url": "u", - "events_url": "e", - "repos_url": "r" - }, - "installation": { - "id": 1, - "node_id": "nid", - "app_id": 1, - "app_slug": "as", - "target_id": 1, - "account": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "access_tokens_url": "atu", - "repositories_url": "ru", - "html_url": "hu", - "target_type": "tt", - "single_file_name": "sfn", - "repository_selection": "rs", - "events": [ - "e" - ], - "single_file_paths": [ - "s" - ], - "permissions": { - "actions": "a", - "administration": "ad", - "checks": "c", - "contents": "co", - "content_references": "cr", - "deployments": "d", - "environments": "e", - "issues": "i", - "metadata": "md", - "members": "m", - "organization_administration": "oa", - "organization_hooks": "oh", - "organization_plan": "op", - "organization_pre_receive_hooks": "opr", - "organization_projects": "op", - "organization_secrets": "os", - "organization_self_hosted_runners": "osh", - "organization_user_blocking": "oub", - "packages": "pkg", - "pages": "pg", - "pull_requests": "pr", - "repository_hooks": "rh", - "repository_projects": "rp", - "repository_pre_receive_hooks": "rprh", - "secrets": "s", - "secret_scanning_alerts": "ssa", - "security_events": "se", - "single_file": "sf", - "statuses": "s", - "team_discussions": "td", - "vulnerability_alerts": "va", - "workflows": "w" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "has_multiple_single_files": false, - "suspended_by": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "suspended_at": ` + referenceTimeStr + ` - } - }` - - testJSONMarshal(t, u, want) -} - func TestProjectV2Event_Marshal(t *testing.T) { t.Parallel() testJSONMarshal(t, &ProjectV2Event{}, "{}") u := &ProjectV2Event{ Action: Ptr("a"), - ProjectsV2: &ProjectsV2{ + ProjectsV2: &ProjectV2{ ID: Ptr(int64(1)), NodeID: Ptr("nid"), Owner: &User{ diff --git a/github/github-accessors.go b/github/github-accessors.go index cc058414209..2d17414064f 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4878,14 +4878,6 @@ func (c *CreateUpdateRequiredWorkflowOptions) GetWorkflowFilePath() string { return *c.WorkflowFilePath } -// GetBody returns the Body field if it's non-nil, zero value otherwise. -func (c *CreateUserProjectOptions) GetBody() string { - if c == nil || c.Body == nil { - return "" - } - return *c.Body -} - // GetEmail returns the Email field if it's non-nil, zero value otherwise. func (c *CreateUserRequest) GetEmail() string { if c == nil || c.Email == nil { @@ -10830,14 +10822,6 @@ func (i *IssueEvent) GetPerformedViaGithubApp() *App { return i.PerformedViaGithubApp } -// GetProjectCard returns the ProjectCard field. -func (i *IssueEvent) GetProjectCard() *ProjectCard { - if i == nil { - return nil - } - return i.ProjectCard -} - // GetRename returns the Rename field. func (i *IssueEvent) GetRename() *Rename { if i == nil { @@ -11806,14 +11790,6 @@ func (l *ListCodespaces) GetTotalCount() int { return *l.TotalCount } -// GetAffiliation returns the Affiliation field if it's non-nil, zero value otherwise. -func (l *ListCollaboratorOptions) GetAffiliation() string { - if l == nil || l.Affiliation == nil { - return "" - } - return *l.Affiliation -} - // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. func (l *ListCustomDeploymentRuleIntegrationsResponse) GetTotalCount() int { if l == nil || l.TotalCount == nil { @@ -15750,16 +15726,88 @@ func (p *PRLinks) GetStatuses() *PRLink { return p.Statuses } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (p *ProjectBody) GetFrom() string { + if p == nil || p.From == nil { + return "" + } + return *p.From +} + +// GetNote returns the Note field. +func (p *ProjectCardChange) GetNote() *ProjectCardNote { + if p == nil { + return nil + } + return p.Note +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (p *ProjectCardNote) GetFrom() string { + if p == nil || p.From == nil { + return "" + } + return *p.From +} + +// GetBody returns the Body field. +func (p *ProjectChange) GetBody() *ProjectBody { + if p == nil { + return nil + } + return p.Body +} + +// GetName returns the Name field. +func (p *ProjectChange) GetName() *ProjectName { + if p == nil { + return nil + } + return p.Name +} + +// GetName returns the Name field. +func (p *ProjectColumnChange) GetName() *ProjectColumnName { + if p == nil { + return nil + } + return p.Name +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (p *ProjectColumnName) GetFrom() string { + if p == nil || p.From == nil { + return "" + } + return *p.From +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (p *ProjectName) GetFrom() string { + if p == nil || p.From == nil { + return "" + } + return *p.From +} + // GetBody returns the Body field if it's non-nil, zero value otherwise. -func (p *Project) GetBody() string { +func (p *ProjectV2) GetBody() string { if p == nil || p.Body == nil { return "" } return *p.Body } +// GetClosedAt returns the ClosedAt field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetClosedAt() Timestamp { + if p == nil || p.ClosedAt == nil { + return Timestamp{} + } + return *p.ClosedAt +} + // GetColumnsURL returns the ColumnsURL field if it's non-nil, zero value otherwise. -func (p *Project) GetColumnsURL() string { +func (p *ProjectV2) GetColumnsURL() string { if p == nil || p.ColumnsURL == nil { return "" } @@ -15767,7 +15815,7 @@ func (p *Project) GetColumnsURL() string { } // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *Project) GetCreatedAt() Timestamp { +func (p *ProjectV2) GetCreatedAt() Timestamp { if p == nil || p.CreatedAt == nil { return Timestamp{} } @@ -15775,15 +15823,39 @@ func (p *Project) GetCreatedAt() Timestamp { } // GetCreator returns the Creator field. -func (p *Project) GetCreator() *User { +func (p *ProjectV2) GetCreator() *User { if p == nil { return nil } return p.Creator } +// GetDeletedAt returns the DeletedAt field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetDeletedAt() Timestamp { + if p == nil || p.DeletedAt == nil { + return Timestamp{} + } + return *p.DeletedAt +} + +// GetDeletedBy returns the DeletedBy field. +func (p *ProjectV2) GetDeletedBy() *User { + if p == nil { + return nil + } + return p.DeletedBy +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetDescription() string { + if p == nil || p.Description == nil { + return "" + } + return *p.Description +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. -func (p *Project) GetHTMLURL() string { +func (p *ProjectV2) GetHTMLURL() string { if p == nil || p.HTMLURL == nil { return "" } @@ -15791,7 +15863,7 @@ func (p *Project) GetHTMLURL() string { } // GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *Project) GetID() int64 { +func (p *ProjectV2) GetID() int64 { if p == nil || p.ID == nil { return 0 } @@ -15799,7 +15871,7 @@ func (p *Project) GetID() int64 { } // GetName returns the Name field if it's non-nil, zero value otherwise. -func (p *Project) GetName() string { +func (p *ProjectV2) GetName() string { if p == nil || p.Name == nil { return "" } @@ -15807,7 +15879,7 @@ func (p *Project) GetName() string { } // GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (p *Project) GetNodeID() string { +func (p *ProjectV2) GetNodeID() string { if p == nil || p.NodeID == nil { return "" } @@ -15815,7 +15887,7 @@ func (p *Project) GetNodeID() string { } // GetNumber returns the Number field if it's non-nil, zero value otherwise. -func (p *Project) GetNumber() int { +func (p *ProjectV2) GetNumber() int { if p == nil || p.Number == nil { return 0 } @@ -15823,15 +15895,23 @@ func (p *Project) GetNumber() int { } // GetOrganizationPermission returns the OrganizationPermission field if it's non-nil, zero value otherwise. -func (p *Project) GetOrganizationPermission() string { +func (p *ProjectV2) GetOrganizationPermission() string { if p == nil || p.OrganizationPermission == nil { return "" } return *p.OrganizationPermission } +// GetOwner returns the Owner field. +func (p *ProjectV2) GetOwner() *User { + if p == nil { + return nil + } + return p.Owner +} + // GetOwnerURL returns the OwnerURL field if it's non-nil, zero value otherwise. -func (p *Project) GetOwnerURL() string { +func (p *ProjectV2) GetOwnerURL() string { if p == nil || p.OwnerURL == nil { return "" } @@ -15839,23 +15919,47 @@ func (p *Project) GetOwnerURL() string { } // GetPrivate returns the Private field if it's non-nil, zero value otherwise. -func (p *Project) GetPrivate() bool { +func (p *ProjectV2) GetPrivate() bool { if p == nil || p.Private == nil { return false } return *p.Private } +// GetPublic returns the Public field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetPublic() bool { + if p == nil || p.Public == nil { + return false + } + return *p.Public +} + +// GetShortDescription returns the ShortDescription field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetShortDescription() string { + if p == nil || p.ShortDescription == nil { + return "" + } + return *p.ShortDescription +} + // GetState returns the State field if it's non-nil, zero value otherwise. -func (p *Project) GetState() string { +func (p *ProjectV2) GetState() string { if p == nil || p.State == nil { return "" } return *p.State } +// GetTitle returns the Title field if it's non-nil, zero value otherwise. +func (p *ProjectV2) GetTitle() string { + if p == nil || p.Title == nil { + return "" + } + return *p.Title +} + // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *Project) GetUpdatedAt() Timestamp { +func (p *ProjectV2) GetUpdatedAt() Timestamp { if p == nil || p.UpdatedAt == nil { return Timestamp{} } @@ -15863,63 +15967,79 @@ func (p *Project) GetUpdatedAt() Timestamp { } // GetURL returns the URL field if it's non-nil, zero value otherwise. -func (p *Project) GetURL() string { +func (p *ProjectV2) GetURL() string { if p == nil || p.URL == nil { return "" } return *p.URL } -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (p *ProjectBody) GetFrom() string { - if p == nil || p.From == nil { +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (p *ProjectV2Event) GetAction() string { + if p == nil || p.Action == nil { return "" } - return *p.From + return *p.Action } -// GetArchived returns the Archived field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetArchived() bool { - if p == nil || p.Archived == nil { - return false +// GetInstallation returns the Installation field. +func (p *ProjectV2Event) GetInstallation() *Installation { + if p == nil { + return nil } - return *p.Archived + return p.Installation } -// GetColumnID returns the ColumnID field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetColumnID() int64 { - if p == nil || p.ColumnID == nil { - return 0 +// GetOrg returns the Org field. +func (p *ProjectV2Event) GetOrg() *Organization { + if p == nil { + return nil } - return *p.ColumnID + return p.Org } -// GetColumnName returns the ColumnName field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetColumnName() string { - if p == nil || p.ColumnName == nil { - return "" +// GetProjectsV2 returns the ProjectsV2 field. +func (p *ProjectV2Event) GetProjectsV2() *ProjectV2 { + if p == nil { + return nil + } + return p.ProjectsV2 +} + +// GetSender returns the Sender field. +func (p *ProjectV2Event) GetSender() *User { + if p == nil { + return nil + } + return p.Sender +} + +// GetArchivedAt returns the ArchivedAt field if it's non-nil, zero value otherwise. +func (p *ProjectV2Item) GetArchivedAt() Timestamp { + if p == nil || p.ArchivedAt == nil { + return Timestamp{} } - return *p.ColumnName + return *p.ArchivedAt } -// GetColumnURL returns the ColumnURL field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetColumnURL() string { - if p == nil || p.ColumnURL == nil { +// GetContentNodeID returns the ContentNodeID field if it's non-nil, zero value otherwise. +func (p *ProjectV2Item) GetContentNodeID() string { + if p == nil || p.ContentNodeID == nil { return "" } - return *p.ColumnURL + return *p.ContentNodeID } -// GetContentURL returns the ContentURL field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetContentURL() string { - if p == nil || p.ContentURL == nil { +// GetContentType returns the ContentType field if it's non-nil, zero value otherwise. +func (p *ProjectV2Item) GetContentType() string { + if p == nil || p.ContentType == nil { return "" } - return *p.ContentURL + return *p.ContentType } // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetCreatedAt() Timestamp { +func (p *ProjectV2Item) GetCreatedAt() Timestamp { if p == nil || p.CreatedAt == nil { return Timestamp{} } @@ -15927,7 +16047,7 @@ func (p *ProjectCard) GetCreatedAt() Timestamp { } // GetCreator returns the Creator field. -func (p *ProjectCard) GetCreator() *User { +func (p *ProjectV2Item) GetCreator() *User { if p == nil { return nil } @@ -15935,7 +16055,7 @@ func (p *ProjectCard) GetCreator() *User { } // GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetID() int64 { +func (p *ProjectV2Item) GetID() int64 { if p == nil || p.ID == nil { return 0 } @@ -15943,87 +16063,47 @@ func (p *ProjectCard) GetID() int64 { } // GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetNodeID() string { +func (p *ProjectV2Item) GetNodeID() string { if p == nil || p.NodeID == nil { return "" } return *p.NodeID } -// GetNote returns the Note field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetNote() string { - if p == nil || p.Note == nil { - return "" - } - return *p.Note -} - -// GetPreviousColumnName returns the PreviousColumnName field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetPreviousColumnName() string { - if p == nil || p.PreviousColumnName == nil { - return "" - } - return *p.PreviousColumnName -} - -// GetProjectID returns the ProjectID field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetProjectID() int64 { - if p == nil || p.ProjectID == nil { - return 0 - } - return *p.ProjectID -} - -// GetProjectURL returns the ProjectURL field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetProjectURL() string { - if p == nil || p.ProjectURL == nil { +// GetProjectNodeID returns the ProjectNodeID field if it's non-nil, zero value otherwise. +func (p *ProjectV2Item) GetProjectNodeID() string { + if p == nil || p.ProjectNodeID == nil { return "" } - return *p.ProjectURL + return *p.ProjectNodeID } // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetUpdatedAt() Timestamp { +func (p *ProjectV2Item) GetUpdatedAt() Timestamp { if p == nil || p.UpdatedAt == nil { return Timestamp{} } return *p.UpdatedAt } -// GetURL returns the URL field if it's non-nil, zero value otherwise. -func (p *ProjectCard) GetURL() string { - if p == nil || p.URL == nil { - return "" - } - return *p.URL -} - -// GetNote returns the Note field. -func (p *ProjectCardChange) GetNote() *ProjectCardNote { +// GetArchivedAt returns the ArchivedAt field. +func (p *ProjectV2ItemChange) GetArchivedAt() *ArchivedAt { if p == nil { return nil } - return p.Note + return p.ArchivedAt } // GetAction returns the Action field if it's non-nil, zero value otherwise. -func (p *ProjectCardEvent) GetAction() string { +func (p *ProjectV2ItemEvent) GetAction() string { if p == nil || p.Action == nil { return "" } return *p.Action } -// GetAfterID returns the AfterID field if it's non-nil, zero value otherwise. -func (p *ProjectCardEvent) GetAfterID() int64 { - if p == nil || p.AfterID == nil { - return 0 - } - return *p.AfterID -} - // GetChanges returns the Changes field. -func (p *ProjectCardEvent) GetChanges() *ProjectCardChange { +func (p *ProjectV2ItemEvent) GetChanges() *ProjectV2ItemChange { if p == nil { return nil } @@ -16031,7 +16111,7 @@ func (p *ProjectCardEvent) GetChanges() *ProjectCardChange { } // GetInstallation returns the Installation field. -func (p *ProjectCardEvent) GetInstallation() *Installation { +func (p *ProjectV2ItemEvent) GetInstallation() *Installation { if p == nil { return nil } @@ -16039,643 +16119,43 @@ func (p *ProjectCardEvent) GetInstallation() *Installation { } // GetOrg returns the Org field. -func (p *ProjectCardEvent) GetOrg() *Organization { +func (p *ProjectV2ItemEvent) GetOrg() *Organization { if p == nil { return nil } return p.Org } -// GetProjectCard returns the ProjectCard field. -func (p *ProjectCardEvent) GetProjectCard() *ProjectCard { +// GetProjectV2Item returns the ProjectV2Item field. +func (p *ProjectV2ItemEvent) GetProjectV2Item() *ProjectV2Item { if p == nil { return nil } - return p.ProjectCard + return p.ProjectV2Item } -// GetRepo returns the Repo field. -func (p *ProjectCardEvent) GetRepo() *Repository { +// GetSender returns the Sender field. +func (p *ProjectV2ItemEvent) GetSender() *User { if p == nil { return nil } - return p.Repo + return p.Sender } -// GetSender returns the Sender field. -func (p *ProjectCardEvent) GetSender() *User { +// GetAllowDeletions returns the AllowDeletions field. +func (p *Protection) GetAllowDeletions() *AllowDeletions { if p == nil { return nil } - return p.Sender + return p.AllowDeletions } -// GetArchivedState returns the ArchivedState field if it's non-nil, zero value otherwise. -func (p *ProjectCardListOptions) GetArchivedState() string { - if p == nil || p.ArchivedState == nil { - return "" +// GetAllowForcePushes returns the AllowForcePushes field. +func (p *Protection) GetAllowForcePushes() *AllowForcePushes { + if p == nil { + return nil } - return *p.ArchivedState -} - -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (p *ProjectCardNote) GetFrom() string { - if p == nil || p.From == nil { - return "" - } - return *p.From -} - -// GetArchived returns the Archived field if it's non-nil, zero value otherwise. -func (p *ProjectCardOptions) GetArchived() bool { - if p == nil || p.Archived == nil { - return false - } - return *p.Archived -} - -// GetBody returns the Body field. -func (p *ProjectChange) GetBody() *ProjectBody { - if p == nil { - return nil - } - return p.Body -} - -// GetName returns the Name field. -func (p *ProjectChange) GetName() *ProjectName { - if p == nil { - return nil - } - return p.Name -} - -// GetPermission returns the Permission field if it's non-nil, zero value otherwise. -func (p *ProjectCollaboratorOptions) GetPermission() string { - if p == nil || p.Permission == nil { - return "" - } - return *p.Permission -} - -// GetCardsURL returns the CardsURL field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetCardsURL() string { - if p == nil || p.CardsURL == nil { - return "" - } - return *p.CardsURL -} - -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetCreatedAt() Timestamp { - if p == nil || p.CreatedAt == nil { - return Timestamp{} - } - return *p.CreatedAt -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetID() int64 { - if p == nil || p.ID == nil { - return 0 - } - return *p.ID -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetName() string { - if p == nil || p.Name == nil { - return "" - } - return *p.Name -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetNodeID() string { - if p == nil || p.NodeID == nil { - return "" - } - return *p.NodeID -} - -// GetProjectURL returns the ProjectURL field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetProjectURL() string { - if p == nil || p.ProjectURL == nil { - return "" - } - return *p.ProjectURL -} - -// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetUpdatedAt() Timestamp { - if p == nil || p.UpdatedAt == nil { - return Timestamp{} - } - return *p.UpdatedAt -} - -// GetURL returns the URL field if it's non-nil, zero value otherwise. -func (p *ProjectColumn) GetURL() string { - if p == nil || p.URL == nil { - return "" - } - return *p.URL -} - -// GetName returns the Name field. -func (p *ProjectColumnChange) GetName() *ProjectColumnName { - if p == nil { - return nil - } - return p.Name -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (p *ProjectColumnEvent) GetAction() string { - if p == nil || p.Action == nil { - return "" - } - return *p.Action -} - -// GetAfterID returns the AfterID field if it's non-nil, zero value otherwise. -func (p *ProjectColumnEvent) GetAfterID() int64 { - if p == nil || p.AfterID == nil { - return 0 - } - return *p.AfterID -} - -// GetChanges returns the Changes field. -func (p *ProjectColumnEvent) GetChanges() *ProjectColumnChange { - if p == nil { - return nil - } - return p.Changes -} - -// GetInstallation returns the Installation field. -func (p *ProjectColumnEvent) GetInstallation() *Installation { - if p == nil { - return nil - } - return p.Installation -} - -// GetOrg returns the Org field. -func (p *ProjectColumnEvent) GetOrg() *Organization { - if p == nil { - return nil - } - return p.Org -} - -// GetProjectColumn returns the ProjectColumn field. -func (p *ProjectColumnEvent) GetProjectColumn() *ProjectColumn { - if p == nil { - return nil - } - return p.ProjectColumn -} - -// GetRepo returns the Repo field. -func (p *ProjectColumnEvent) GetRepo() *Repository { - if p == nil { - return nil - } - return p.Repo -} - -// GetSender returns the Sender field. -func (p *ProjectColumnEvent) GetSender() *User { - if p == nil { - return nil - } - return p.Sender -} - -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (p *ProjectColumnName) GetFrom() string { - if p == nil || p.From == nil { - return "" - } - return *p.From -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (p *ProjectEvent) GetAction() string { - if p == nil || p.Action == nil { - return "" - } - return *p.Action -} - -// GetChanges returns the Changes field. -func (p *ProjectEvent) GetChanges() *ProjectChange { - if p == nil { - return nil - } - return p.Changes -} - -// GetInstallation returns the Installation field. -func (p *ProjectEvent) GetInstallation() *Installation { - if p == nil { - return nil - } - return p.Installation -} - -// GetOrg returns the Org field. -func (p *ProjectEvent) GetOrg() *Organization { - if p == nil { - return nil - } - return p.Org -} - -// GetProject returns the Project field. -func (p *ProjectEvent) GetProject() *Project { - if p == nil { - return nil - } - return p.Project -} - -// GetRepo returns the Repo field. -func (p *ProjectEvent) GetRepo() *Repository { - if p == nil { - return nil - } - return p.Repo -} - -// GetSender returns the Sender field. -func (p *ProjectEvent) GetSender() *User { - if p == nil { - return nil - } - return p.Sender -} - -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (p *ProjectName) GetFrom() string { - if p == nil || p.From == nil { - return "" - } - return *p.From -} - -// GetBody returns the Body field if it's non-nil, zero value otherwise. -func (p *ProjectOptions) GetBody() string { - if p == nil || p.Body == nil { - return "" - } - return *p.Body -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (p *ProjectOptions) GetName() string { - if p == nil || p.Name == nil { - return "" - } - return *p.Name -} - -// GetOrganizationPermission returns the OrganizationPermission field if it's non-nil, zero value otherwise. -func (p *ProjectOptions) GetOrganizationPermission() string { - if p == nil || p.OrganizationPermission == nil { - return "" - } - return *p.OrganizationPermission -} - -// GetPrivate returns the Private field if it's non-nil, zero value otherwise. -func (p *ProjectOptions) GetPrivate() bool { - if p == nil || p.Private == nil { - return false - } - return *p.Private -} - -// GetState returns the State field if it's non-nil, zero value otherwise. -func (p *ProjectOptions) GetState() string { - if p == nil || p.State == nil { - return "" - } - return *p.State -} - -// GetPermission returns the Permission field if it's non-nil, zero value otherwise. -func (p *ProjectPermissionLevel) GetPermission() string { - if p == nil || p.Permission == nil { - return "" - } - return *p.Permission -} - -// GetUser returns the User field. -func (p *ProjectPermissionLevel) GetUser() *User { - if p == nil { - return nil - } - return p.User -} - -// GetClosedAt returns the ClosedAt field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetClosedAt() Timestamp { - if p == nil || p.ClosedAt == nil { - return Timestamp{} - } - return *p.ClosedAt -} - -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetCreatedAt() Timestamp { - if p == nil || p.CreatedAt == nil { - return Timestamp{} - } - return *p.CreatedAt -} - -// GetCreator returns the Creator field. -func (p *ProjectsV2) GetCreator() *User { - if p == nil { - return nil - } - return p.Creator -} - -// GetDeletedAt returns the DeletedAt field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetDeletedAt() Timestamp { - if p == nil || p.DeletedAt == nil { - return Timestamp{} - } - return *p.DeletedAt -} - -// GetDeletedBy returns the DeletedBy field. -func (p *ProjectsV2) GetDeletedBy() *User { - if p == nil { - return nil - } - return p.DeletedBy -} - -// GetDescription returns the Description field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetDescription() string { - if p == nil || p.Description == nil { - return "" - } - return *p.Description -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetID() int64 { - if p == nil || p.ID == nil { - return 0 - } - return *p.ID -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetNodeID() string { - if p == nil || p.NodeID == nil { - return "" - } - return *p.NodeID -} - -// GetNumber returns the Number field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetNumber() int { - if p == nil || p.Number == nil { - return 0 - } - return *p.Number -} - -// GetOwner returns the Owner field. -func (p *ProjectsV2) GetOwner() *User { - if p == nil { - return nil - } - return p.Owner -} - -// GetPublic returns the Public field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetPublic() bool { - if p == nil || p.Public == nil { - return false - } - return *p.Public -} - -// GetShortDescription returns the ShortDescription field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetShortDescription() string { - if p == nil || p.ShortDescription == nil { - return "" - } - return *p.ShortDescription -} - -// GetTitle returns the Title field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetTitle() string { - if p == nil || p.Title == nil { - return "" - } - return *p.Title -} - -// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectsV2) GetUpdatedAt() Timestamp { - if p == nil || p.UpdatedAt == nil { - return Timestamp{} - } - return *p.UpdatedAt -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (p *ProjectV2Event) GetAction() string { - if p == nil || p.Action == nil { - return "" - } - return *p.Action -} - -// GetInstallation returns the Installation field. -func (p *ProjectV2Event) GetInstallation() *Installation { - if p == nil { - return nil - } - return p.Installation -} - -// GetOrg returns the Org field. -func (p *ProjectV2Event) GetOrg() *Organization { - if p == nil { - return nil - } - return p.Org -} - -// GetProjectsV2 returns the ProjectsV2 field. -func (p *ProjectV2Event) GetProjectsV2() *ProjectsV2 { - if p == nil { - return nil - } - return p.ProjectsV2 -} - -// GetSender returns the Sender field. -func (p *ProjectV2Event) GetSender() *User { - if p == nil { - return nil - } - return p.Sender -} - -// GetArchivedAt returns the ArchivedAt field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetArchivedAt() Timestamp { - if p == nil || p.ArchivedAt == nil { - return Timestamp{} - } - return *p.ArchivedAt -} - -// GetContentNodeID returns the ContentNodeID field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetContentNodeID() string { - if p == nil || p.ContentNodeID == nil { - return "" - } - return *p.ContentNodeID -} - -// GetContentType returns the ContentType field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetContentType() string { - if p == nil || p.ContentType == nil { - return "" - } - return *p.ContentType -} - -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetCreatedAt() Timestamp { - if p == nil || p.CreatedAt == nil { - return Timestamp{} - } - return *p.CreatedAt -} - -// GetCreator returns the Creator field. -func (p *ProjectV2Item) GetCreator() *User { - if p == nil { - return nil - } - return p.Creator -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetID() int64 { - if p == nil || p.ID == nil { - return 0 - } - return *p.ID -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetNodeID() string { - if p == nil || p.NodeID == nil { - return "" - } - return *p.NodeID -} - -// GetProjectNodeID returns the ProjectNodeID field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetProjectNodeID() string { - if p == nil || p.ProjectNodeID == nil { - return "" - } - return *p.ProjectNodeID -} - -// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. -func (p *ProjectV2Item) GetUpdatedAt() Timestamp { - if p == nil || p.UpdatedAt == nil { - return Timestamp{} - } - return *p.UpdatedAt -} - -// GetArchivedAt returns the ArchivedAt field. -func (p *ProjectV2ItemChange) GetArchivedAt() *ArchivedAt { - if p == nil { - return nil - } - return p.ArchivedAt -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (p *ProjectV2ItemEvent) GetAction() string { - if p == nil || p.Action == nil { - return "" - } - return *p.Action -} - -// GetChanges returns the Changes field. -func (p *ProjectV2ItemEvent) GetChanges() *ProjectV2ItemChange { - if p == nil { - return nil - } - return p.Changes -} - -// GetInstallation returns the Installation field. -func (p *ProjectV2ItemEvent) GetInstallation() *Installation { - if p == nil { - return nil - } - return p.Installation -} - -// GetOrg returns the Org field. -func (p *ProjectV2ItemEvent) GetOrg() *Organization { - if p == nil { - return nil - } - return p.Org -} - -// GetProjectV2Item returns the ProjectV2Item field. -func (p *ProjectV2ItemEvent) GetProjectV2Item() *ProjectV2Item { - if p == nil { - return nil - } - return p.ProjectV2Item -} - -// GetSender returns the Sender field. -func (p *ProjectV2ItemEvent) GetSender() *User { - if p == nil { - return nil - } - return p.Sender -} - -// GetAllowDeletions returns the AllowDeletions field. -func (p *Protection) GetAllowDeletions() *AllowDeletions { - if p == nil { - return nil - } - return p.AllowDeletions -} - -// GetAllowForcePushes returns the AllowForcePushes field. -func (p *Protection) GetAllowForcePushes() *AllowForcePushes { - if p == nil { - return nil - } - return p.AllowForcePushes + return p.AllowForcePushes } // GetAllowForkSyncing returns the AllowForkSyncing field. @@ -25230,14 +24710,6 @@ func (t *Timeline) GetPerformedViaGithubApp() *App { return t.PerformedViaGithubApp } -// GetProjectCard returns the ProjectCard field. -func (t *Timeline) GetProjectCard() *ProjectCard { - if t == nil { - return nil - } - return t.ProjectCard -} - // GetRename returns the Rename field. func (t *Timeline) GetRename() *Rename { if t == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 71cef92fd5f..3cf970d33f2 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -6328,17 +6328,6 @@ func TestCreateUpdateRequiredWorkflowOptions_GetWorkflowFilePath(tt *testing.T) c.GetWorkflowFilePath() } -func TestCreateUserProjectOptions_GetBody(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CreateUserProjectOptions{Body: &zeroValue} - c.GetBody() - c = &CreateUserProjectOptions{} - c.GetBody() - c = nil - c.GetBody() -} - func TestCreateUserRequest_GetEmail(tt *testing.T) { tt.Parallel() var zeroValue string @@ -13978,14 +13967,6 @@ func TestIssueEvent_GetPerformedViaGithubApp(tt *testing.T) { i.GetPerformedViaGithubApp() } -func TestIssueEvent_GetProjectCard(tt *testing.T) { - tt.Parallel() - i := &IssueEvent{} - i.GetProjectCard() - i = nil - i.GetProjectCard() -} - func TestIssueEvent_GetRename(tt *testing.T) { tt.Parallel() i := &IssueEvent{} @@ -15251,17 +15232,6 @@ func TestListCodespaces_GetTotalCount(tt *testing.T) { l.GetTotalCount() } -func TestListCollaboratorOptions_GetAffiliation(tt *testing.T) { - tt.Parallel() - var zeroValue string - l := &ListCollaboratorOptions{Affiliation: &zeroValue} - l.GetAffiliation() - l = &ListCollaboratorOptions{} - l.GetAffiliation() - l = nil - l.GetAffiliation() -} - func TestListCustomDeploymentRuleIntegrationsResponse_GetTotalCount(tt *testing.T) { tt.Parallel() var zeroValue int @@ -20338,1104 +20308,485 @@ func TestPRLinks_GetStatuses(tt *testing.T) { p.GetStatuses() } -func TestProject_GetBody(tt *testing.T) { +func TestProjectBody_GetFrom(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectBody{From: &zeroValue} + p.GetFrom() + p = &ProjectBody{} + p.GetFrom() + p = nil + p.GetFrom() +} + +func TestProjectCardChange_GetNote(tt *testing.T) { + tt.Parallel() + p := &ProjectCardChange{} + p.GetNote() + p = nil + p.GetNote() +} + +func TestProjectCardNote_GetFrom(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectCardNote{From: &zeroValue} + p.GetFrom() + p = &ProjectCardNote{} + p.GetFrom() + p = nil + p.GetFrom() +} + +func TestProjectChange_GetBody(tt *testing.T) { + tt.Parallel() + p := &ProjectChange{} + p.GetBody() + p = nil + p.GetBody() +} + +func TestProjectChange_GetName(tt *testing.T) { + tt.Parallel() + p := &ProjectChange{} + p.GetName() + p = nil + p.GetName() +} + +func TestProjectColumnChange_GetName(tt *testing.T) { + tt.Parallel() + p := &ProjectColumnChange{} + p.GetName() + p = nil + p.GetName() +} + +func TestProjectColumnName_GetFrom(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectColumnName{From: &zeroValue} + p.GetFrom() + p = &ProjectColumnName{} + p.GetFrom() + p = nil + p.GetFrom() +} + +func TestProjectName_GetFrom(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectName{From: &zeroValue} + p.GetFrom() + p = &ProjectName{} + p.GetFrom() + p = nil + p.GetFrom() +} + +func TestProjectV2_GetBody(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{Body: &zeroValue} + p := &ProjectV2{Body: &zeroValue} p.GetBody() - p = &Project{} + p = &ProjectV2{} p.GetBody() p = nil p.GetBody() } -func TestProject_GetColumnsURL(tt *testing.T) { +func TestProjectV2_GetClosedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + p := &ProjectV2{ClosedAt: &zeroValue} + p.GetClosedAt() + p = &ProjectV2{} + p.GetClosedAt() + p = nil + p.GetClosedAt() +} + +func TestProjectV2_GetColumnsURL(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{ColumnsURL: &zeroValue} + p := &ProjectV2{ColumnsURL: &zeroValue} p.GetColumnsURL() - p = &Project{} + p = &ProjectV2{} p.GetColumnsURL() p = nil p.GetColumnsURL() } -func TestProject_GetCreatedAt(tt *testing.T) { +func TestProjectV2_GetCreatedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp - p := &Project{CreatedAt: &zeroValue} + p := &ProjectV2{CreatedAt: &zeroValue} p.GetCreatedAt() - p = &Project{} + p = &ProjectV2{} p.GetCreatedAt() p = nil p.GetCreatedAt() } -func TestProject_GetCreator(tt *testing.T) { +func TestProjectV2_GetCreator(tt *testing.T) { tt.Parallel() - p := &Project{} + p := &ProjectV2{} p.GetCreator() p = nil p.GetCreator() } -func TestProject_GetHTMLURL(tt *testing.T) { +func TestProjectV2_GetDeletedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + p := &ProjectV2{DeletedAt: &zeroValue} + p.GetDeletedAt() + p = &ProjectV2{} + p.GetDeletedAt() + p = nil + p.GetDeletedAt() +} + +func TestProjectV2_GetDeletedBy(tt *testing.T) { + tt.Parallel() + p := &ProjectV2{} + p.GetDeletedBy() + p = nil + p.GetDeletedBy() +} + +func TestProjectV2_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectV2{Description: &zeroValue} + p.GetDescription() + p = &ProjectV2{} + p.GetDescription() + p = nil + p.GetDescription() +} + +func TestProjectV2_GetHTMLURL(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{HTMLURL: &zeroValue} + p := &ProjectV2{HTMLURL: &zeroValue} p.GetHTMLURL() - p = &Project{} + p = &ProjectV2{} p.GetHTMLURL() p = nil p.GetHTMLURL() } -func TestProject_GetID(tt *testing.T) { +func TestProjectV2_GetID(tt *testing.T) { tt.Parallel() var zeroValue int64 - p := &Project{ID: &zeroValue} + p := &ProjectV2{ID: &zeroValue} p.GetID() - p = &Project{} + p = &ProjectV2{} p.GetID() p = nil p.GetID() } -func TestProject_GetName(tt *testing.T) { +func TestProjectV2_GetName(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{Name: &zeroValue} + p := &ProjectV2{Name: &zeroValue} p.GetName() - p = &Project{} + p = &ProjectV2{} p.GetName() p = nil p.GetName() } -func TestProject_GetNodeID(tt *testing.T) { +func TestProjectV2_GetNodeID(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{NodeID: &zeroValue} + p := &ProjectV2{NodeID: &zeroValue} p.GetNodeID() - p = &Project{} + p = &ProjectV2{} p.GetNodeID() p = nil p.GetNodeID() } -func TestProject_GetNumber(tt *testing.T) { +func TestProjectV2_GetNumber(tt *testing.T) { tt.Parallel() var zeroValue int - p := &Project{Number: &zeroValue} + p := &ProjectV2{Number: &zeroValue} p.GetNumber() - p = &Project{} + p = &ProjectV2{} p.GetNumber() p = nil p.GetNumber() } -func TestProject_GetOrganizationPermission(tt *testing.T) { +func TestProjectV2_GetOrganizationPermission(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{OrganizationPermission: &zeroValue} + p := &ProjectV2{OrganizationPermission: &zeroValue} p.GetOrganizationPermission() - p = &Project{} + p = &ProjectV2{} p.GetOrganizationPermission() p = nil p.GetOrganizationPermission() } -func TestProject_GetOwnerURL(tt *testing.T) { +func TestProjectV2_GetOwner(tt *testing.T) { + tt.Parallel() + p := &ProjectV2{} + p.GetOwner() + p = nil + p.GetOwner() +} + +func TestProjectV2_GetOwnerURL(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{OwnerURL: &zeroValue} + p := &ProjectV2{OwnerURL: &zeroValue} p.GetOwnerURL() - p = &Project{} + p = &ProjectV2{} p.GetOwnerURL() p = nil p.GetOwnerURL() } -func TestProject_GetPrivate(tt *testing.T) { +func TestProjectV2_GetPrivate(tt *testing.T) { tt.Parallel() var zeroValue bool - p := &Project{Private: &zeroValue} + p := &ProjectV2{Private: &zeroValue} p.GetPrivate() - p = &Project{} + p = &ProjectV2{} p.GetPrivate() p = nil p.GetPrivate() } -func TestProject_GetState(tt *testing.T) { +func TestProjectV2_GetPublic(tt *testing.T) { + tt.Parallel() + var zeroValue bool + p := &ProjectV2{Public: &zeroValue} + p.GetPublic() + p = &ProjectV2{} + p.GetPublic() + p = nil + p.GetPublic() +} + +func TestProjectV2_GetShortDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectV2{ShortDescription: &zeroValue} + p.GetShortDescription() + p = &ProjectV2{} + p.GetShortDescription() + p = nil + p.GetShortDescription() +} + +func TestProjectV2_GetState(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{State: &zeroValue} + p := &ProjectV2{State: &zeroValue} p.GetState() - p = &Project{} + p = &ProjectV2{} p.GetState() p = nil p.GetState() } -func TestProject_GetUpdatedAt(tt *testing.T) { +func TestProjectV2_GetTitle(tt *testing.T) { + tt.Parallel() + var zeroValue string + p := &ProjectV2{Title: &zeroValue} + p.GetTitle() + p = &ProjectV2{} + p.GetTitle() + p = nil + p.GetTitle() +} + +func TestProjectV2_GetUpdatedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp - p := &Project{UpdatedAt: &zeroValue} + p := &ProjectV2{UpdatedAt: &zeroValue} p.GetUpdatedAt() - p = &Project{} + p = &ProjectV2{} p.GetUpdatedAt() p = nil p.GetUpdatedAt() } -func TestProject_GetURL(tt *testing.T) { +func TestProjectV2_GetURL(tt *testing.T) { tt.Parallel() var zeroValue string - p := &Project{URL: &zeroValue} + p := &ProjectV2{URL: &zeroValue} p.GetURL() - p = &Project{} + p = &ProjectV2{} p.GetURL() p = nil p.GetURL() } -func TestProjectBody_GetFrom(tt *testing.T) { +func TestProjectV2Event_GetAction(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectBody{From: &zeroValue} - p.GetFrom() - p = &ProjectBody{} - p.GetFrom() + p := &ProjectV2Event{Action: &zeroValue} + p.GetAction() + p = &ProjectV2Event{} + p.GetAction() p = nil - p.GetFrom() + p.GetAction() } -func TestProjectCard_GetArchived(tt *testing.T) { +func TestProjectV2Event_GetInstallation(tt *testing.T) { tt.Parallel() - var zeroValue bool - p := &ProjectCard{Archived: &zeroValue} - p.GetArchived() - p = &ProjectCard{} - p.GetArchived() + p := &ProjectV2Event{} + p.GetInstallation() p = nil - p.GetArchived() + p.GetInstallation() } -func TestProjectCard_GetColumnID(tt *testing.T) { +func TestProjectV2Event_GetOrg(tt *testing.T) { tt.Parallel() - var zeroValue int64 - p := &ProjectCard{ColumnID: &zeroValue} - p.GetColumnID() - p = &ProjectCard{} - p.GetColumnID() + p := &ProjectV2Event{} + p.GetOrg() p = nil - p.GetColumnID() + p.GetOrg() } -func TestProjectCard_GetColumnName(tt *testing.T) { +func TestProjectV2Event_GetProjectsV2(tt *testing.T) { tt.Parallel() - var zeroValue string - p := &ProjectCard{ColumnName: &zeroValue} - p.GetColumnName() - p = &ProjectCard{} - p.GetColumnName() + p := &ProjectV2Event{} + p.GetProjectsV2() + p = nil + p.GetProjectsV2() +} + +func TestProjectV2Event_GetSender(tt *testing.T) { + tt.Parallel() + p := &ProjectV2Event{} + p.GetSender() + p = nil + p.GetSender() +} + +func TestProjectV2Item_GetArchivedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + p := &ProjectV2Item{ArchivedAt: &zeroValue} + p.GetArchivedAt() + p = &ProjectV2Item{} + p.GetArchivedAt() p = nil - p.GetColumnName() + p.GetArchivedAt() } -func TestProjectCard_GetColumnURL(tt *testing.T) { +func TestProjectV2Item_GetContentNodeID(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectCard{ColumnURL: &zeroValue} - p.GetColumnURL() - p = &ProjectCard{} - p.GetColumnURL() + p := &ProjectV2Item{ContentNodeID: &zeroValue} + p.GetContentNodeID() + p = &ProjectV2Item{} + p.GetContentNodeID() p = nil - p.GetColumnURL() + p.GetContentNodeID() } -func TestProjectCard_GetContentURL(tt *testing.T) { +func TestProjectV2Item_GetContentType(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectCard{ContentURL: &zeroValue} - p.GetContentURL() - p = &ProjectCard{} - p.GetContentURL() + p := &ProjectV2Item{ContentType: &zeroValue} + p.GetContentType() + p = &ProjectV2Item{} + p.GetContentType() p = nil - p.GetContentURL() + p.GetContentType() } -func TestProjectCard_GetCreatedAt(tt *testing.T) { +func TestProjectV2Item_GetCreatedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp - p := &ProjectCard{CreatedAt: &zeroValue} + p := &ProjectV2Item{CreatedAt: &zeroValue} p.GetCreatedAt() - p = &ProjectCard{} + p = &ProjectV2Item{} p.GetCreatedAt() p = nil p.GetCreatedAt() } -func TestProjectCard_GetCreator(tt *testing.T) { +func TestProjectV2Item_GetCreator(tt *testing.T) { tt.Parallel() - p := &ProjectCard{} + p := &ProjectV2Item{} p.GetCreator() p = nil p.GetCreator() } -func TestProjectCard_GetID(tt *testing.T) { +func TestProjectV2Item_GetID(tt *testing.T) { tt.Parallel() var zeroValue int64 - p := &ProjectCard{ID: &zeroValue} + p := &ProjectV2Item{ID: &zeroValue} p.GetID() - p = &ProjectCard{} + p = &ProjectV2Item{} p.GetID() p = nil p.GetID() } -func TestProjectCard_GetNodeID(tt *testing.T) { +func TestProjectV2Item_GetNodeID(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectCard{NodeID: &zeroValue} + p := &ProjectV2Item{NodeID: &zeroValue} p.GetNodeID() - p = &ProjectCard{} + p = &ProjectV2Item{} p.GetNodeID() p = nil p.GetNodeID() } -func TestProjectCard_GetNote(tt *testing.T) { +func TestProjectV2Item_GetProjectNodeID(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectCard{Note: &zeroValue} - p.GetNote() - p = &ProjectCard{} - p.GetNote() + p := &ProjectV2Item{ProjectNodeID: &zeroValue} + p.GetProjectNodeID() + p = &ProjectV2Item{} + p.GetProjectNodeID() p = nil - p.GetNote() + p.GetProjectNodeID() } -func TestProjectCard_GetPreviousColumnName(tt *testing.T) { +func TestProjectV2Item_GetUpdatedAt(tt *testing.T) { tt.Parallel() - var zeroValue string - p := &ProjectCard{PreviousColumnName: &zeroValue} - p.GetPreviousColumnName() - p = &ProjectCard{} - p.GetPreviousColumnName() + var zeroValue Timestamp + p := &ProjectV2Item{UpdatedAt: &zeroValue} + p.GetUpdatedAt() + p = &ProjectV2Item{} + p.GetUpdatedAt() p = nil - p.GetPreviousColumnName() + p.GetUpdatedAt() } -func TestProjectCard_GetProjectID(tt *testing.T) { +func TestProjectV2ItemChange_GetArchivedAt(tt *testing.T) { tt.Parallel() - var zeroValue int64 - p := &ProjectCard{ProjectID: &zeroValue} - p.GetProjectID() - p = &ProjectCard{} - p.GetProjectID() + p := &ProjectV2ItemChange{} + p.GetArchivedAt() p = nil - p.GetProjectID() + p.GetArchivedAt() } -func TestProjectCard_GetProjectURL(tt *testing.T) { +func TestProjectV2ItemEvent_GetAction(tt *testing.T) { tt.Parallel() var zeroValue string - p := &ProjectCard{ProjectURL: &zeroValue} - p.GetProjectURL() - p = &ProjectCard{} - p.GetProjectURL() + p := &ProjectV2ItemEvent{Action: &zeroValue} + p.GetAction() + p = &ProjectV2ItemEvent{} + p.GetAction() p = nil - p.GetProjectURL() + p.GetAction() } -func TestProjectCard_GetUpdatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectCard{UpdatedAt: &zeroValue} - p.GetUpdatedAt() - p = &ProjectCard{} - p.GetUpdatedAt() - p = nil - p.GetUpdatedAt() -} - -func TestProjectCard_GetURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectCard{URL: &zeroValue} - p.GetURL() - p = &ProjectCard{} - p.GetURL() - p = nil - p.GetURL() -} - -func TestProjectCardChange_GetNote(tt *testing.T) { - tt.Parallel() - p := &ProjectCardChange{} - p.GetNote() - p = nil - p.GetNote() -} - -func TestProjectCardEvent_GetAction(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectCardEvent{Action: &zeroValue} - p.GetAction() - p = &ProjectCardEvent{} - p.GetAction() - p = nil - p.GetAction() -} - -func TestProjectCardEvent_GetAfterID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - p := &ProjectCardEvent{AfterID: &zeroValue} - p.GetAfterID() - p = &ProjectCardEvent{} - p.GetAfterID() - p = nil - p.GetAfterID() -} - -func TestProjectCardEvent_GetChanges(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetChanges() - p = nil - p.GetChanges() -} - -func TestProjectCardEvent_GetInstallation(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetInstallation() - p = nil - p.GetInstallation() -} - -func TestProjectCardEvent_GetOrg(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetOrg() - p = nil - p.GetOrg() -} - -func TestProjectCardEvent_GetProjectCard(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetProjectCard() - p = nil - p.GetProjectCard() -} - -func TestProjectCardEvent_GetRepo(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetRepo() - p = nil - p.GetRepo() -} - -func TestProjectCardEvent_GetSender(tt *testing.T) { - tt.Parallel() - p := &ProjectCardEvent{} - p.GetSender() - p = nil - p.GetSender() -} - -func TestProjectCardListOptions_GetArchivedState(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectCardListOptions{ArchivedState: &zeroValue} - p.GetArchivedState() - p = &ProjectCardListOptions{} - p.GetArchivedState() - p = nil - p.GetArchivedState() -} - -func TestProjectCardNote_GetFrom(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectCardNote{From: &zeroValue} - p.GetFrom() - p = &ProjectCardNote{} - p.GetFrom() - p = nil - p.GetFrom() -} - -func TestProjectCardOptions_GetArchived(tt *testing.T) { - tt.Parallel() - var zeroValue bool - p := &ProjectCardOptions{Archived: &zeroValue} - p.GetArchived() - p = &ProjectCardOptions{} - p.GetArchived() - p = nil - p.GetArchived() -} - -func TestProjectChange_GetBody(tt *testing.T) { - tt.Parallel() - p := &ProjectChange{} - p.GetBody() - p = nil - p.GetBody() -} - -func TestProjectChange_GetName(tt *testing.T) { - tt.Parallel() - p := &ProjectChange{} - p.GetName() - p = nil - p.GetName() -} - -func TestProjectCollaboratorOptions_GetPermission(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectCollaboratorOptions{Permission: &zeroValue} - p.GetPermission() - p = &ProjectCollaboratorOptions{} - p.GetPermission() - p = nil - p.GetPermission() -} - -func TestProjectColumn_GetCardsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumn{CardsURL: &zeroValue} - p.GetCardsURL() - p = &ProjectColumn{} - p.GetCardsURL() - p = nil - p.GetCardsURL() -} - -func TestProjectColumn_GetCreatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectColumn{CreatedAt: &zeroValue} - p.GetCreatedAt() - p = &ProjectColumn{} - p.GetCreatedAt() - p = nil - p.GetCreatedAt() -} - -func TestProjectColumn_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - p := &ProjectColumn{ID: &zeroValue} - p.GetID() - p = &ProjectColumn{} - p.GetID() - p = nil - p.GetID() -} - -func TestProjectColumn_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumn{Name: &zeroValue} - p.GetName() - p = &ProjectColumn{} - p.GetName() - p = nil - p.GetName() -} - -func TestProjectColumn_GetNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumn{NodeID: &zeroValue} - p.GetNodeID() - p = &ProjectColumn{} - p.GetNodeID() - p = nil - p.GetNodeID() -} - -func TestProjectColumn_GetProjectURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumn{ProjectURL: &zeroValue} - p.GetProjectURL() - p = &ProjectColumn{} - p.GetProjectURL() - p = nil - p.GetProjectURL() -} - -func TestProjectColumn_GetUpdatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectColumn{UpdatedAt: &zeroValue} - p.GetUpdatedAt() - p = &ProjectColumn{} - p.GetUpdatedAt() - p = nil - p.GetUpdatedAt() -} - -func TestProjectColumn_GetURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumn{URL: &zeroValue} - p.GetURL() - p = &ProjectColumn{} - p.GetURL() - p = nil - p.GetURL() -} - -func TestProjectColumnChange_GetName(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnChange{} - p.GetName() - p = nil - p.GetName() -} - -func TestProjectColumnEvent_GetAction(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumnEvent{Action: &zeroValue} - p.GetAction() - p = &ProjectColumnEvent{} - p.GetAction() - p = nil - p.GetAction() -} - -func TestProjectColumnEvent_GetAfterID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - p := &ProjectColumnEvent{AfterID: &zeroValue} - p.GetAfterID() - p = &ProjectColumnEvent{} - p.GetAfterID() - p = nil - p.GetAfterID() -} - -func TestProjectColumnEvent_GetChanges(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetChanges() - p = nil - p.GetChanges() -} - -func TestProjectColumnEvent_GetInstallation(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetInstallation() - p = nil - p.GetInstallation() -} - -func TestProjectColumnEvent_GetOrg(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetOrg() - p = nil - p.GetOrg() -} - -func TestProjectColumnEvent_GetProjectColumn(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetProjectColumn() - p = nil - p.GetProjectColumn() -} - -func TestProjectColumnEvent_GetRepo(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetRepo() - p = nil - p.GetRepo() -} - -func TestProjectColumnEvent_GetSender(tt *testing.T) { - tt.Parallel() - p := &ProjectColumnEvent{} - p.GetSender() - p = nil - p.GetSender() -} - -func TestProjectColumnName_GetFrom(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectColumnName{From: &zeroValue} - p.GetFrom() - p = &ProjectColumnName{} - p.GetFrom() - p = nil - p.GetFrom() -} - -func TestProjectEvent_GetAction(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectEvent{Action: &zeroValue} - p.GetAction() - p = &ProjectEvent{} - p.GetAction() - p = nil - p.GetAction() -} - -func TestProjectEvent_GetChanges(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetChanges() - p = nil - p.GetChanges() -} - -func TestProjectEvent_GetInstallation(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetInstallation() - p = nil - p.GetInstallation() -} - -func TestProjectEvent_GetOrg(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetOrg() - p = nil - p.GetOrg() -} - -func TestProjectEvent_GetProject(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetProject() - p = nil - p.GetProject() -} - -func TestProjectEvent_GetRepo(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetRepo() - p = nil - p.GetRepo() -} - -func TestProjectEvent_GetSender(tt *testing.T) { - tt.Parallel() - p := &ProjectEvent{} - p.GetSender() - p = nil - p.GetSender() -} - -func TestProjectName_GetFrom(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectName{From: &zeroValue} - p.GetFrom() - p = &ProjectName{} - p.GetFrom() - p = nil - p.GetFrom() -} - -func TestProjectOptions_GetBody(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectOptions{Body: &zeroValue} - p.GetBody() - p = &ProjectOptions{} - p.GetBody() - p = nil - p.GetBody() -} - -func TestProjectOptions_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectOptions{Name: &zeroValue} - p.GetName() - p = &ProjectOptions{} - p.GetName() - p = nil - p.GetName() -} - -func TestProjectOptions_GetOrganizationPermission(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectOptions{OrganizationPermission: &zeroValue} - p.GetOrganizationPermission() - p = &ProjectOptions{} - p.GetOrganizationPermission() - p = nil - p.GetOrganizationPermission() -} - -func TestProjectOptions_GetPrivate(tt *testing.T) { - tt.Parallel() - var zeroValue bool - p := &ProjectOptions{Private: &zeroValue} - p.GetPrivate() - p = &ProjectOptions{} - p.GetPrivate() - p = nil - p.GetPrivate() -} - -func TestProjectOptions_GetState(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectOptions{State: &zeroValue} - p.GetState() - p = &ProjectOptions{} - p.GetState() - p = nil - p.GetState() -} - -func TestProjectPermissionLevel_GetPermission(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectPermissionLevel{Permission: &zeroValue} - p.GetPermission() - p = &ProjectPermissionLevel{} - p.GetPermission() - p = nil - p.GetPermission() -} - -func TestProjectPermissionLevel_GetUser(tt *testing.T) { - tt.Parallel() - p := &ProjectPermissionLevel{} - p.GetUser() - p = nil - p.GetUser() -} - -func TestProjectsV2_GetClosedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectsV2{ClosedAt: &zeroValue} - p.GetClosedAt() - p = &ProjectsV2{} - p.GetClosedAt() - p = nil - p.GetClosedAt() -} - -func TestProjectsV2_GetCreatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectsV2{CreatedAt: &zeroValue} - p.GetCreatedAt() - p = &ProjectsV2{} - p.GetCreatedAt() - p = nil - p.GetCreatedAt() -} - -func TestProjectsV2_GetCreator(tt *testing.T) { - tt.Parallel() - p := &ProjectsV2{} - p.GetCreator() - p = nil - p.GetCreator() -} - -func TestProjectsV2_GetDeletedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectsV2{DeletedAt: &zeroValue} - p.GetDeletedAt() - p = &ProjectsV2{} - p.GetDeletedAt() - p = nil - p.GetDeletedAt() -} - -func TestProjectsV2_GetDeletedBy(tt *testing.T) { - tt.Parallel() - p := &ProjectsV2{} - p.GetDeletedBy() - p = nil - p.GetDeletedBy() -} - -func TestProjectsV2_GetDescription(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectsV2{Description: &zeroValue} - p.GetDescription() - p = &ProjectsV2{} - p.GetDescription() - p = nil - p.GetDescription() -} - -func TestProjectsV2_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - p := &ProjectsV2{ID: &zeroValue} - p.GetID() - p = &ProjectsV2{} - p.GetID() - p = nil - p.GetID() -} - -func TestProjectsV2_GetNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectsV2{NodeID: &zeroValue} - p.GetNodeID() - p = &ProjectsV2{} - p.GetNodeID() - p = nil - p.GetNodeID() -} - -func TestProjectsV2_GetNumber(tt *testing.T) { - tt.Parallel() - var zeroValue int - p := &ProjectsV2{Number: &zeroValue} - p.GetNumber() - p = &ProjectsV2{} - p.GetNumber() - p = nil - p.GetNumber() -} - -func TestProjectsV2_GetOwner(tt *testing.T) { - tt.Parallel() - p := &ProjectsV2{} - p.GetOwner() - p = nil - p.GetOwner() -} - -func TestProjectsV2_GetPublic(tt *testing.T) { - tt.Parallel() - var zeroValue bool - p := &ProjectsV2{Public: &zeroValue} - p.GetPublic() - p = &ProjectsV2{} - p.GetPublic() - p = nil - p.GetPublic() -} - -func TestProjectsV2_GetShortDescription(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectsV2{ShortDescription: &zeroValue} - p.GetShortDescription() - p = &ProjectsV2{} - p.GetShortDescription() - p = nil - p.GetShortDescription() -} - -func TestProjectsV2_GetTitle(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectsV2{Title: &zeroValue} - p.GetTitle() - p = &ProjectsV2{} - p.GetTitle() - p = nil - p.GetTitle() -} - -func TestProjectsV2_GetUpdatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectsV2{UpdatedAt: &zeroValue} - p.GetUpdatedAt() - p = &ProjectsV2{} - p.GetUpdatedAt() - p = nil - p.GetUpdatedAt() -} - -func TestProjectV2Event_GetAction(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2Event{Action: &zeroValue} - p.GetAction() - p = &ProjectV2Event{} - p.GetAction() - p = nil - p.GetAction() -} - -func TestProjectV2Event_GetInstallation(tt *testing.T) { - tt.Parallel() - p := &ProjectV2Event{} - p.GetInstallation() - p = nil - p.GetInstallation() -} - -func TestProjectV2Event_GetOrg(tt *testing.T) { - tt.Parallel() - p := &ProjectV2Event{} - p.GetOrg() - p = nil - p.GetOrg() -} - -func TestProjectV2Event_GetProjectsV2(tt *testing.T) { - tt.Parallel() - p := &ProjectV2Event{} - p.GetProjectsV2() - p = nil - p.GetProjectsV2() -} - -func TestProjectV2Event_GetSender(tt *testing.T) { - tt.Parallel() - p := &ProjectV2Event{} - p.GetSender() - p = nil - p.GetSender() -} - -func TestProjectV2Item_GetArchivedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectV2Item{ArchivedAt: &zeroValue} - p.GetArchivedAt() - p = &ProjectV2Item{} - p.GetArchivedAt() - p = nil - p.GetArchivedAt() -} - -func TestProjectV2Item_GetContentNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2Item{ContentNodeID: &zeroValue} - p.GetContentNodeID() - p = &ProjectV2Item{} - p.GetContentNodeID() - p = nil - p.GetContentNodeID() -} - -func TestProjectV2Item_GetContentType(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2Item{ContentType: &zeroValue} - p.GetContentType() - p = &ProjectV2Item{} - p.GetContentType() - p = nil - p.GetContentType() -} - -func TestProjectV2Item_GetCreatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectV2Item{CreatedAt: &zeroValue} - p.GetCreatedAt() - p = &ProjectV2Item{} - p.GetCreatedAt() - p = nil - p.GetCreatedAt() -} - -func TestProjectV2Item_GetCreator(tt *testing.T) { - tt.Parallel() - p := &ProjectV2Item{} - p.GetCreator() - p = nil - p.GetCreator() -} - -func TestProjectV2Item_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - p := &ProjectV2Item{ID: &zeroValue} - p.GetID() - p = &ProjectV2Item{} - p.GetID() - p = nil - p.GetID() -} - -func TestProjectV2Item_GetNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2Item{NodeID: &zeroValue} - p.GetNodeID() - p = &ProjectV2Item{} - p.GetNodeID() - p = nil - p.GetNodeID() -} - -func TestProjectV2Item_GetProjectNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2Item{ProjectNodeID: &zeroValue} - p.GetProjectNodeID() - p = &ProjectV2Item{} - p.GetProjectNodeID() - p = nil - p.GetProjectNodeID() -} - -func TestProjectV2Item_GetUpdatedAt(tt *testing.T) { - tt.Parallel() - var zeroValue Timestamp - p := &ProjectV2Item{UpdatedAt: &zeroValue} - p.GetUpdatedAt() - p = &ProjectV2Item{} - p.GetUpdatedAt() - p = nil - p.GetUpdatedAt() -} - -func TestProjectV2ItemChange_GetArchivedAt(tt *testing.T) { - tt.Parallel() - p := &ProjectV2ItemChange{} - p.GetArchivedAt() - p = nil - p.GetArchivedAt() -} - -func TestProjectV2ItemEvent_GetAction(tt *testing.T) { - tt.Parallel() - var zeroValue string - p := &ProjectV2ItemEvent{Action: &zeroValue} - p.GetAction() - p = &ProjectV2ItemEvent{} - p.GetAction() - p = nil - p.GetAction() -} - -func TestProjectV2ItemEvent_GetChanges(tt *testing.T) { +func TestProjectV2ItemEvent_GetChanges(tt *testing.T) { tt.Parallel() p := &ProjectV2ItemEvent{} p.GetChanges() @@ -32272,14 +31623,6 @@ func TestTimeline_GetPerformedViaGithubApp(tt *testing.T) { t.GetPerformedViaGithubApp() } -func TestTimeline_GetProjectCard(tt *testing.T) { - tt.Parallel() - t := &Timeline{} - t.GetProjectCard() - t = nil - t.GetProjectCard() -} - func TestTimeline_GetRename(tt *testing.T) { tt.Parallel() t := &Timeline{} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index ed1c8f11e70..e9d8f29d061 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1305,31 +1305,6 @@ func TestPreReceiveHook_String(t *testing.T) { } } -func TestProject_String(t *testing.T) { - t.Parallel() - v := Project{ - ID: Ptr(int64(0)), - URL: Ptr(""), - HTMLURL: Ptr(""), - ColumnsURL: Ptr(""), - OwnerURL: Ptr(""), - Name: Ptr(""), - Body: Ptr(""), - Number: Ptr(0), - State: Ptr(""), - CreatedAt: &Timestamp{}, - UpdatedAt: &Timestamp{}, - NodeID: Ptr(""), - OrganizationPermission: Ptr(""), - Private: Ptr(false), - Creator: &User{}, - } - want := `github.Project{ID:0, URL:"", HTMLURL:"", ColumnsURL:"", OwnerURL:"", Name:"", Body:"", Number:0, State:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, NodeID:"", OrganizationPermission:"", Private:false, Creator:github.User{}}` - if got := v.String(); got != want { - t.Errorf("Project.String = %v, want %v", got, want) - } -} - func TestPullRequest_String(t *testing.T) { t.Parallel() v := PullRequest{ diff --git a/github/github.go b/github/github.go index 2590d061ee1..7cdd73eb25e 100644 --- a/github/github.go +++ b/github/github.go @@ -203,7 +203,6 @@ type Client struct { Meta *MetaService Migrations *MigrationService Organizations *OrganizationsService - Projects *ProjectsService PullRequests *PullRequestsService RateLimit *RateLimitService Reactions *ReactionsService @@ -432,7 +431,6 @@ func (c *Client) initialize() { c.Meta = (*MetaService)(&c.common) c.Migrations = (*MigrationService)(&c.common) c.Organizations = (*OrganizationsService)(&c.common) - c.Projects = (*ProjectsService)(&c.common) c.PullRequests = (*PullRequestsService)(&c.common) c.RateLimit = (*RateLimitService)(&c.common) c.Reactions = (*ReactionsService)(&c.common) diff --git a/github/issues_events.go b/github/issues_events.go index bba3b180311..8e234d7e020 100644 --- a/github/issues_events.go +++ b/github/issues_events.go @@ -85,7 +85,6 @@ type IssueEvent struct { Label *Label `json:"label,omitempty"` Rename *Rename `json:"rename,omitempty"` LockReason *string `json:"lock_reason,omitempty"` - ProjectCard *ProjectCard `json:"project_card,omitempty"` DismissedReview *DismissedReview `json:"dismissed_review,omitempty"` RequestedReviewer *User `json:"requested_reviewer,omitempty"` RequestedTeam *Team `json:"requested_team,omitempty"` diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 6e4a9685af2..043caedadc7 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -245,8 +245,7 @@ func TestIssueEvent_Marshal(t *testing.T) { From: Ptr("from"), To: Ptr("to"), }, - LockReason: Ptr("lr"), - ProjectCard: &ProjectCard{ID: Ptr(int64(1))}, + LockReason: Ptr("lr"), DismissedReview: &DismissedReview{ State: Ptr("state"), ReviewID: Ptr(int64(1)), diff --git a/github/issues_timeline.go b/github/issues_timeline.go index 0aa589afe40..ffd9b6fecfc 100644 --- a/github/issues_timeline.go +++ b/github/issues_timeline.go @@ -134,8 +134,7 @@ type Timeline struct { Source *Source `json:"source,omitempty"` // An object containing rename details including 'from' and 'to' attributes. // Only provided for 'renamed' events. - Rename *Rename `json:"rename,omitempty"` - ProjectCard *ProjectCard `json:"project_card,omitempty"` + Rename *Rename `json:"rename,omitempty"` // The state of a submitted review. Can be one of: 'commented', // 'changes_requested' or 'approved'. // Only provided for 'reviewed' events. diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index b5b33c4c5e8..1e88f500d99 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -170,8 +170,7 @@ func TestTimeline_Marshal(t *testing.T) { From: Ptr("from"), To: Ptr("to"), }, - ProjectCard: &ProjectCard{ID: Ptr(int64(1))}, - State: Ptr("state"), + State: Ptr("state"), } want := `{ diff --git a/github/messages.go b/github/messages.go index 3df4f3a3544..59b214b355a 100644 --- a/github/messages.go +++ b/github/messages.go @@ -86,9 +86,6 @@ var ( "page_build": &PageBuildEvent{}, "personal_access_token_request": &PersonalAccessTokenRequestEvent{}, "ping": &PingEvent{}, - "project": &ProjectEvent{}, - "project_card": &ProjectCardEvent{}, - "project_column": &ProjectColumnEvent{}, "projects_v2": &ProjectV2Event{}, "projects_v2_item": &ProjectV2ItemEvent{}, "public": &PublicEvent{}, diff --git a/github/messages_test.go b/github/messages_test.go index e5a5327cfac..36149ba2e36 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -424,18 +424,6 @@ func TestParseWebHook(t *testing.T) { payload: &PingEvent{}, messageType: "ping", }, - { - payload: &ProjectEvent{}, - messageType: "project", - }, - { - payload: &ProjectCardEvent{}, - messageType: "project_card", - }, - { - payload: &ProjectColumnEvent{}, - messageType: "project_column", - }, { payload: &ProjectV2Event{}, messageType: "projects_v2", diff --git a/github/orgs_projects.go b/github/orgs_projects.go deleted file mode 100644 index 454d8cf1c34..00000000000 --- a/github/orgs_projects.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// ListProjects lists the projects for an organization. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#list-organization-projects -// -//meta:operation GET /orgs/{org}/projects -func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) { - u := fmt.Sprintf("orgs/%v/projects", org) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - var projects []*Project - resp, err := s.client.Do(ctx, req, &projects) - if err != nil { - return nil, resp, err - } - - return projects, resp, nil -} - -// CreateProject creates a GitHub Project for the specified organization. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#create-an-organization-project -// -//meta:operation POST /orgs/{org}/projects -func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) { - u := fmt.Sprintf("orgs/%v/projects", org) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - project := &Project{} - resp, err := s.client.Do(ctx, req, project) - if err != nil { - return nil, resp, err - } - - return project, resp, nil -} diff --git a/github/orgs_projects_test.go b/github/orgs_projects_test.go deleted file mode 100644 index f26cb90ac35..00000000000 --- a/github/orgs_projects_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2017 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestOrganizationsService_ListProjects(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"state": "open", "page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ProjectListOptions{State: "open", ListOptions: ListOptions{Page: 2}} - ctx := context.Background() - projects, _, err := client.Organizations.ListProjects(ctx, "o", opt) - if err != nil { - t.Errorf("Organizations.ListProjects returned error: %v", err) - } - - want := []*Project{{ID: Ptr(int64(1))}} - if !cmp.Equal(projects, want) { - t.Errorf("Organizations.ListProjects returned %+v, want %+v", projects, want) - } - - const methodName = "ListProjects" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Organizations.ListProjects(ctx, "\n", opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Organizations.ListProjects(ctx, "o", opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestOrganizationsService_CreateProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectOptions{Name: Ptr("Project Name"), Body: Ptr("Project body.")} - - mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - project, _, err := client.Organizations.CreateProject(ctx, "o", input) - if err != nil { - t.Errorf("Organizations.CreateProject returned error: %v", err) - } - - want := &Project{ID: Ptr(int64(1))} - if !cmp.Equal(project, want) { - t.Errorf("Organizations.CreateProject returned %+v, want %+v", project, want) - } - - const methodName = "CreateProject" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Organizations.CreateProject(ctx, "\n", input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Organizations.CreateProject(ctx, "o", input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} diff --git a/github/projects.go b/github/projects.go deleted file mode 100644 index c5c42f8939b..00000000000 --- a/github/projects.go +++ /dev/null @@ -1,634 +0,0 @@ -// Copyright 2016 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// ProjectsService provides access to the projects functions in the -// GitHub API. -// -// GitHub API docs: https://docs.github.com/rest/projects -type ProjectsService service - -// Project represents a GitHub Project. -type Project struct { - ID *int64 `json:"id,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - ColumnsURL *string `json:"columns_url,omitempty"` - OwnerURL *string `json:"owner_url,omitempty"` - Name *string `json:"name,omitempty"` - Body *string `json:"body,omitempty"` - Number *int `json:"number,omitempty"` - State *string `json:"state,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - NodeID *string `json:"node_id,omitempty"` - OrganizationPermission *string `json:"organization_permission,omitempty"` - Private *bool `json:"private,omitempty"` - - // The User object that generated the project. - Creator *User `json:"creator,omitempty"` -} - -func (p Project) String() string { - return Stringify(p) -} - -// GetProject gets a GitHub Project for a repo. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#get-a-project -// -//meta:operation GET /projects/{project_id} -func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *Response, error) { - u := fmt.Sprintf("projects/%v", id) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - project := &Project{} - resp, err := s.client.Do(ctx, req, project) - if err != nil { - return nil, resp, err - } - - return project, resp, nil -} - -// ProjectOptions specifies the parameters to the -// RepositoriesService.CreateProject and -// ProjectsService.UpdateProject methods. -type ProjectOptions struct { - // The name of the project. (Required for creation; optional for update.) - Name *string `json:"name,omitempty"` - // The body of the project. (Optional.) - Body *string `json:"body,omitempty"` - - // The following field(s) are only applicable for update. - // They should be left with zero values for creation. - - // State of the project. Either "open" or "closed". (Optional.) - State *string `json:"state,omitempty"` - // The permission level that all members of the project's organization - // will have on this project. - // Setting the organization permission is only available - // for organization projects. (Optional.) - OrganizationPermission *string `json:"organization_permission,omitempty"` - // Sets visibility of the project within the organization. - // Setting visibility is only available - // for organization projects.(Optional.) - Private *bool `json:"private,omitempty"` -} - -// UpdateProject updates a repository project. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#update-a-project -// -//meta:operation PATCH /projects/{project_id} -func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *ProjectOptions) (*Project, *Response, error) { - u := fmt.Sprintf("projects/%v", id) - req, err := s.client.NewRequest("PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - project := &Project{} - resp, err := s.client.Do(ctx, req, project) - if err != nil { - return nil, resp, err - } - - return project, resp, nil -} - -// DeleteProject deletes a GitHub Project from a repository. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#delete-a-project -// -//meta:operation DELETE /projects/{project_id} -func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Response, error) { - u := fmt.Sprintf("projects/%v", id) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ProjectColumn represents a column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/repos/projects/ -type ProjectColumn struct { - ID *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - URL *string `json:"url,omitempty"` - ProjectURL *string `json:"project_url,omitempty"` - CardsURL *string `json:"cards_url,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - NodeID *string `json:"node_id,omitempty"` -} - -// ListProjectColumns lists the columns of a GitHub Project for a repo. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#list-project-columns -// -//meta:operation GET /projects/{project_id}/columns -func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int64, opts *ListOptions) ([]*ProjectColumn, *Response, error) { - u := fmt.Sprintf("projects/%v/columns", projectID) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - columns := []*ProjectColumn{} - resp, err := s.client.Do(ctx, req, &columns) - if err != nil { - return nil, resp, err - } - - return columns, resp, nil -} - -// GetProjectColumn gets a column of a GitHub Project for a repo. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#get-a-project-column -// -//meta:operation GET /projects/columns/{column_id} -func (s *ProjectsService) GetProjectColumn(ctx context.Context, id int64) (*ProjectColumn, *Response, error) { - u := fmt.Sprintf("projects/columns/%v", id) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - column := &ProjectColumn{} - resp, err := s.client.Do(ctx, req, column) - if err != nil { - return nil, resp, err - } - - return column, resp, nil -} - -// ProjectColumnOptions specifies the parameters to the -// ProjectsService.CreateProjectColumn and -// ProjectsService.UpdateProjectColumn methods. -type ProjectColumnOptions struct { - // The name of the project column. (Required for creation and update.) - Name string `json:"name"` -} - -// CreateProjectColumn creates a column for the specified (by number) project. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#create-a-project-column -// -//meta:operation POST /projects/{project_id}/columns -func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) { - u := fmt.Sprintf("projects/%v/columns", projectID) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - column := &ProjectColumn{} - resp, err := s.client.Do(ctx, req, column) - if err != nil { - return nil, resp, err - } - - return column, resp, nil -} - -// UpdateProjectColumn updates a column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#update-an-existing-project-column -// -//meta:operation PATCH /projects/columns/{column_id} -func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) { - u := fmt.Sprintf("projects/columns/%v", columnID) - req, err := s.client.NewRequest("PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - column := &ProjectColumn{} - resp, err := s.client.Do(ctx, req, column) - if err != nil { - return nil, resp, err - } - - return column, resp, nil -} - -// DeleteProjectColumn deletes a column from a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#delete-a-project-column -// -//meta:operation DELETE /projects/columns/{column_id} -func (s *ProjectsService) DeleteProjectColumn(ctx context.Context, columnID int64) (*Response, error) { - u := fmt.Sprintf("projects/columns/%v", columnID) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ProjectColumnMoveOptions specifies the parameters to the -// ProjectsService.MoveProjectColumn method. -type ProjectColumnMoveOptions struct { - // Position can be one of "first", "last", or "after:", where - // is the ID of a column in the same project. (Required.) - Position string `json:"position"` -} - -// MoveProjectColumn moves a column within a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/columns#move-a-project-column -// -//meta:operation POST /projects/columns/{column_id}/moves -func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnMoveOptions) (*Response, error) { - u := fmt.Sprintf("projects/columns/%v/moves", columnID) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ProjectCard represents a card in a column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards/#get-a-project-card -type ProjectCard struct { - URL *string `json:"url,omitempty"` - ColumnURL *string `json:"column_url,omitempty"` - ContentURL *string `json:"content_url,omitempty"` - ID *int64 `json:"id,omitempty"` - Note *string `json:"note,omitempty"` - Creator *User `json:"creator,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Archived *bool `json:"archived,omitempty"` - - // The following fields are only populated by Webhook events. - ColumnID *int64 `json:"column_id,omitempty"` - - // The following fields are only populated by Events API. - ProjectID *int64 `json:"project_id,omitempty"` - ProjectURL *string `json:"project_url,omitempty"` - ColumnName *string `json:"column_name,omitempty"` - PreviousColumnName *string `json:"previous_column_name,omitempty"` // Populated in "moved_columns_in_project" event deliveries. -} - -// ProjectCardListOptions specifies the optional parameters to the -// ProjectsService.ListProjectCards method. -type ProjectCardListOptions struct { - // ArchivedState is used to list all, archived, or not_archived project cards. - // Defaults to not_archived when you omit this parameter. - ArchivedState *string `url:"archived_state,omitempty"` - - ListOptions -} - -// ListProjectCards lists the cards in a column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#list-project-cards -// -//meta:operation GET /projects/columns/{column_id}/cards -func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opts *ProjectCardListOptions) ([]*ProjectCard, *Response, error) { - u := fmt.Sprintf("projects/columns/%v/cards", columnID) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - cards := []*ProjectCard{} - resp, err := s.client.Do(ctx, req, &cards) - if err != nil { - return nil, resp, err - } - - return cards, resp, nil -} - -// GetProjectCard gets a card in a column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#get-a-project-card -// -//meta:operation GET /projects/columns/cards/{card_id} -func (s *ProjectsService) GetProjectCard(ctx context.Context, cardID int64) (*ProjectCard, *Response, error) { - u := fmt.Sprintf("projects/columns/cards/%v", cardID) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - card := &ProjectCard{} - resp, err := s.client.Do(ctx, req, card) - if err != nil { - return nil, resp, err - } - - return card, resp, nil -} - -// ProjectCardOptions specifies the parameters to the -// ProjectsService.CreateProjectCard and -// ProjectsService.UpdateProjectCard methods. -type ProjectCardOptions struct { - // The note of the card. Note and ContentID are mutually exclusive. - Note string `json:"note,omitempty"` - // The ID (not Number) of the Issue to associate with this card. - // Note and ContentID are mutually exclusive. - ContentID int64 `json:"content_id,omitempty"` - // The type of content to associate with this card. Possible values are: "Issue" and "PullRequest". - ContentType string `json:"content_type,omitempty"` - // Use true to archive a project card. - // Specify false if you need to restore a previously archived project card. - Archived *bool `json:"archived,omitempty"` -} - -// CreateProjectCard creates a card in the specified column of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#create-a-project-card -// -//meta:operation POST /projects/columns/{column_id}/cards -func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) { - u := fmt.Sprintf("projects/columns/%v/cards", columnID) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - card := &ProjectCard{} - resp, err := s.client.Do(ctx, req, card) - if err != nil { - return nil, resp, err - } - - return card, resp, nil -} - -// UpdateProjectCard updates a card of a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#update-an-existing-project-card -// -//meta:operation PATCH /projects/columns/cards/{card_id} -func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) { - u := fmt.Sprintf("projects/columns/cards/%v", cardID) - req, err := s.client.NewRequest("PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - card := &ProjectCard{} - resp, err := s.client.Do(ctx, req, card) - if err != nil { - return nil, resp, err - } - - return card, resp, nil -} - -// DeleteProjectCard deletes a card from a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#delete-a-project-card -// -//meta:operation DELETE /projects/columns/cards/{card_id} -func (s *ProjectsService) DeleteProjectCard(ctx context.Context, cardID int64) (*Response, error) { - u := fmt.Sprintf("projects/columns/cards/%v", cardID) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ProjectCardMoveOptions specifies the parameters to the -// ProjectsService.MoveProjectCard method. -type ProjectCardMoveOptions struct { - // Position can be one of "top", "bottom", or "after:", where - // is the ID of a card in the same project. - Position string `json:"position"` - // ColumnID is the ID of a column in the same project. Note that ColumnID - // is required when using Position "after:" when that card is in - // another column; otherwise it is optional. - ColumnID int64 `json:"column_id,omitempty"` -} - -// MoveProjectCard moves a card within a GitHub Project. -// -// GitHub API docs: https://docs.github.com/rest/projects/cards#move-a-project-card -// -//meta:operation POST /projects/columns/cards/{card_id}/moves -func (s *ProjectsService) MoveProjectCard(ctx context.Context, cardID int64, opts *ProjectCardMoveOptions) (*Response, error) { - u := fmt.Sprintf("projects/columns/cards/%v/moves", cardID) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ProjectCollaboratorOptions specifies the optional parameters to the -// ProjectsService.AddProjectCollaborator method. -type ProjectCollaboratorOptions struct { - // Permission specifies the permission to grant to the collaborator. - // Possible values are: - // "read" - can read, but not write to or administer this project. - // "write" - can read and write, but not administer this project. - // "admin" - can read, write and administer this project. - // - // Default value is "write" - Permission *string `json:"permission,omitempty"` -} - -// AddProjectCollaborator adds a collaborator to an organization project and sets -// their permission level. You must be an organization owner or a project admin to add a collaborator. -// -// GitHub API docs: https://docs.github.com/rest/projects/collaborators#add-project-collaborator -// -//meta:operation PUT /projects/{project_id}/collaborators/{username} -func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64, username string, opts *ProjectCollaboratorOptions) (*Response, error) { - u := fmt.Sprintf("projects/%v/collaborators/%v", id, username) - req, err := s.client.NewRequest("PUT", u, opts) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// RemoveProjectCollaborator removes a collaborator from an organization project. -// You must be an organization owner or a project admin to remove a collaborator. -// -// GitHub API docs: https://docs.github.com/rest/projects/collaborators#remove-user-as-a-collaborator -// -//meta:operation DELETE /projects/{project_id}/collaborators/{username} -func (s *ProjectsService) RemoveProjectCollaborator(ctx context.Context, id int64, username string) (*Response, error) { - u := fmt.Sprintf("projects/%v/collaborators/%v", id, username) - req, err := s.client.NewRequest("DELETE", u, nil) - if err != nil { - return nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - return s.client.Do(ctx, req, nil) -} - -// ListCollaboratorOptions specifies the optional parameters to the -// ProjectsService.ListProjectCollaborators method. -type ListCollaboratorOptions struct { - // Affiliation specifies how collaborators should be filtered by their affiliation. - // Possible values are: - // "outside" - All outside collaborators of an organization-owned repository - // "direct" - All collaborators with permissions to an organization-owned repository, - // regardless of organization membership status - // "all" - All collaborators the authenticated user can see - // - // Default value is "all". - Affiliation *string `url:"affiliation,omitempty"` - - ListOptions -} - -// ListProjectCollaborators lists the collaborators for an organization project. For a project, -// the list of collaborators includes outside collaborators, organization members that are direct -// collaborators, organization members with access through team memberships, organization members -// with access through default organization permissions, and organization owners. You must be an -// organization owner or a project admin to list collaborators. -// -// GitHub API docs: https://docs.github.com/rest/projects/collaborators#list-project-collaborators -// -//meta:operation GET /projects/{project_id}/collaborators -func (s *ProjectsService) ListProjectCollaborators(ctx context.Context, id int64, opts *ListCollaboratorOptions) ([]*User, *Response, error) { - u := fmt.Sprintf("projects/%v/collaborators", id) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - var users []*User - resp, err := s.client.Do(ctx, req, &users) - if err != nil { - return nil, resp, err - } - - return users, resp, nil -} - -// ProjectPermissionLevel represents the permission level an organization -// member has for a given project. -type ProjectPermissionLevel struct { - // Possible values: "admin", "write", "read", "none" - Permission *string `json:"permission,omitempty"` - - User *User `json:"user,omitempty"` -} - -// ReviewProjectCollaboratorPermission returns the collaborator's permission level for an organization -// project. Possible values for the permission key: "admin", "write", "read", "none". -// You must be an organization owner or a project admin to review a user's permission level. -// -// GitHub API docs: https://docs.github.com/rest/projects/collaborators#get-project-permission-for-a-user -// -//meta:operation GET /projects/{project_id}/collaborators/{username}/permission -func (s *ProjectsService) ReviewProjectCollaboratorPermission(ctx context.Context, id int64, username string) (*ProjectPermissionLevel, *Response, error) { - u := fmt.Sprintf("projects/%v/collaborators/%v/permission", id, username) - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - ppl := new(ProjectPermissionLevel) - resp, err := s.client.Do(ctx, req, ppl) - if err != nil { - return nil, resp, err - } - return ppl, resp, nil -} diff --git a/github/projects_test.go b/github/projects_test.go deleted file mode 100644 index f02e2a725a4..00000000000 --- a/github/projects_test.go +++ /dev/null @@ -1,1120 +0,0 @@ -// Copyright 2016 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestProject_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &Project{}, "{}") - - u := &Project{ - ID: Ptr(int64(1)), - URL: Ptr("u"), - HTMLURL: Ptr("h"), - ColumnsURL: Ptr("c"), - OwnerURL: Ptr("o"), - Name: Ptr("n"), - Body: Ptr("b"), - Number: Ptr(1), - State: Ptr("s"), - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - NodeID: Ptr("n"), - Creator: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - URL: Ptr("u"), - }, - } - want := `{ - "id": 1, - "url": "u", - "html_url": "h", - "columns_url": "c", - "owner_url": "o", - "name": "n", - "body": "b", - "number": 1, - "state": "s", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "n", - "creator": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "url": "u" - } - }` - testJSONMarshal(t, u, want) -} - -func TestProjectsService_UpdateProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectOptions{ - Name: Ptr("Project Name"), - Body: Ptr("Project body."), - State: Ptr("open"), - Private: Ptr(false), - - OrganizationPermission: Ptr("read"), - } - - mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - project, _, err := client.Projects.UpdateProject(ctx, 1, input) - if err != nil { - t.Errorf("Projects.UpdateProject returned error: %v", err) - } - - want := &Project{ID: Ptr(int64(1))} - if !cmp.Equal(project, want) { - t.Errorf("Projects.UpdateProject returned %+v, want %+v", project, want) - } - - const methodName = "UpdateProject" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.UpdateProject(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.UpdateProject(ctx, 1, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_GetProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - project, _, err := client.Projects.GetProject(ctx, 1) - if err != nil { - t.Errorf("Projects.GetProject returned error: %v", err) - } - - want := &Project{ID: Ptr(int64(1))} - if !cmp.Equal(project, want) { - t.Errorf("Projects.GetProject returned %+v, want %+v", project, want) - } - - const methodName = "GetProject" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.GetProject(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.GetProject(ctx, 1) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_DeleteProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - }) - - ctx := context.Background() - _, err := client.Projects.DeleteProject(ctx, 1) - if err != nil { - t.Errorf("Projects.DeleteProject returned error: %v", err) - } - - const methodName = "DeleteProject" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.DeleteProject(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.DeleteProject(ctx, 1) - }) -} - -func TestProjectsService_ListProjectColumns(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ListOptions{Page: 2} - ctx := context.Background() - columns, _, err := client.Projects.ListProjectColumns(ctx, 1, opt) - if err != nil { - t.Errorf("Projects.ListProjectColumns returned error: %v", err) - } - - want := []*ProjectColumn{{ID: Ptr(int64(1))}} - if !cmp.Equal(columns, want) { - t.Errorf("Projects.ListProjectColumns returned %+v, want %+v", columns, want) - } - - const methodName = "ListProjectColumns" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.ListProjectColumns(ctx, -1, opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.ListProjectColumns(ctx, 1, opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_GetProjectColumn(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - column, _, err := client.Projects.GetProjectColumn(ctx, 1) - if err != nil { - t.Errorf("Projects.GetProjectColumn returned error: %v", err) - } - - want := &ProjectColumn{ID: Ptr(int64(1))} - if !cmp.Equal(column, want) { - t.Errorf("Projects.GetProjectColumn returned %+v, want %+v", column, want) - } - - const methodName = "GetProjectColumn" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.GetProjectColumn(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.GetProjectColumn(ctx, 1) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_CreateProjectColumn(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectColumnOptions{Name: "Column Name"} - - mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectColumnOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - column, _, err := client.Projects.CreateProjectColumn(ctx, 1, input) - if err != nil { - t.Errorf("Projects.CreateProjectColumn returned error: %v", err) - } - - want := &ProjectColumn{ID: Ptr(int64(1))} - if !cmp.Equal(column, want) { - t.Errorf("Projects.CreateProjectColumn returned %+v, want %+v", column, want) - } - - const methodName = "CreateProjectColumn" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.CreateProjectColumn(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.CreateProjectColumn(ctx, 1, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_UpdateProjectColumn(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectColumnOptions{Name: "Column Name"} - - mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectColumnOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - column, _, err := client.Projects.UpdateProjectColumn(ctx, 1, input) - if err != nil { - t.Errorf("Projects.UpdateProjectColumn returned error: %v", err) - } - - want := &ProjectColumn{ID: Ptr(int64(1))} - if !cmp.Equal(column, want) { - t.Errorf("Projects.UpdateProjectColumn returned %+v, want %+v", column, want) - } - - const methodName = "UpdateProjectColumn" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.UpdateProjectColumn(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.UpdateProjectColumn(ctx, 1, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_DeleteProjectColumn(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - }) - - ctx := context.Background() - _, err := client.Projects.DeleteProjectColumn(ctx, 1) - if err != nil { - t.Errorf("Projects.DeleteProjectColumn returned error: %v", err) - } - - const methodName = "DeleteProjectColumn" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.DeleteProjectColumn(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.DeleteProjectColumn(ctx, 1) - }) -} - -func TestProjectsService_MoveProjectColumn(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectColumnMoveOptions{Position: "after:12345"} - - mux.HandleFunc("/projects/columns/1/moves", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectColumnMoveOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - }) - - ctx := context.Background() - _, err := client.Projects.MoveProjectColumn(ctx, 1, input) - if err != nil { - t.Errorf("Projects.MoveProjectColumn returned error: %v", err) - } - - const methodName = "MoveProjectColumn" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.MoveProjectColumn(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.MoveProjectColumn(ctx, 1, input) - }) -} - -func TestProjectsService_ListProjectCards(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{ - "archived_state": "all", - "page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ProjectCardListOptions{ - ArchivedState: Ptr("all"), - ListOptions: ListOptions{Page: 2}} - ctx := context.Background() - cards, _, err := client.Projects.ListProjectCards(ctx, 1, opt) - if err != nil { - t.Errorf("Projects.ListProjectCards returned error: %v", err) - } - - want := []*ProjectCard{{ID: Ptr(int64(1))}} - if !cmp.Equal(cards, want) { - t.Errorf("Projects.ListProjectCards returned %+v, want %+v", cards, want) - } - - const methodName = "ListProjectCards" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.ListProjectCards(ctx, -1, opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.ListProjectCards(ctx, 1, opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_GetProjectCard(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - card, _, err := client.Projects.GetProjectCard(ctx, 1) - if err != nil { - t.Errorf("Projects.GetProjectCard returned error: %v", err) - } - - want := &ProjectCard{ID: Ptr(int64(1))} - if !cmp.Equal(card, want) { - t.Errorf("Projects.GetProjectCard returned %+v, want %+v", card, want) - } - - const methodName = "GetProjectCard" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.GetProjectCard(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.GetProjectCard(ctx, 1) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_CreateProjectCard(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectCardOptions{ - ContentID: 12345, - ContentType: "Issue", - } - - mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectCardOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - card, _, err := client.Projects.CreateProjectCard(ctx, 1, input) - if err != nil { - t.Errorf("Projects.CreateProjectCard returned error: %v", err) - } - - want := &ProjectCard{ID: Ptr(int64(1))} - if !cmp.Equal(card, want) { - t.Errorf("Projects.CreateProjectCard returned %+v, want %+v", card, want) - } - - const methodName = "CreateProjectCard" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.CreateProjectCard(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.CreateProjectCard(ctx, 1, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_UpdateProjectCard(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectCardOptions{ - ContentID: 12345, - ContentType: "Issue", - } - - mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectCardOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1, "archived":false}`) - }) - - ctx := context.Background() - card, _, err := client.Projects.UpdateProjectCard(ctx, 1, input) - if err != nil { - t.Errorf("Projects.UpdateProjectCard returned error: %v", err) - } - - want := &ProjectCard{ID: Ptr(int64(1)), Archived: Ptr(false)} - if !cmp.Equal(card, want) { - t.Errorf("Projects.UpdateProjectCard returned %+v, want %+v", card, want) - } - - const methodName = "UpdateProjectCard" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.UpdateProjectCard(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.UpdateProjectCard(ctx, 1, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_DeleteProjectCard(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - }) - - ctx := context.Background() - _, err := client.Projects.DeleteProjectCard(ctx, 1) - if err != nil { - t.Errorf("Projects.DeleteProjectCard returned error: %v", err) - } - - const methodName = "DeleteProjectCard" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.DeleteProjectCard(ctx, -1) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.DeleteProjectCard(ctx, 1) - }) -} - -func TestProjectsService_MoveProjectCard(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectCardMoveOptions{Position: "after:12345"} - - mux.HandleFunc("/projects/columns/cards/1/moves", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectCardMoveOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - }) - - ctx := context.Background() - _, err := client.Projects.MoveProjectCard(ctx, 1, input) - if err != nil { - t.Errorf("Projects.MoveProjectCard returned error: %v", err) - } - - const methodName = "MoveProjectCard" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.MoveProjectCard(ctx, -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.MoveProjectCard(ctx, 1, input) - }) -} - -func TestProjectsService_AddProjectCollaborator(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - opt := &ProjectCollaboratorOptions{ - Permission: Ptr("admin"), - } - - mux.HandleFunc("/projects/1/collaborators/u", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectCollaboratorOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, opt) { - t.Errorf("Request body = %+v, want %+v", v, opt) - } - - w.WriteHeader(http.StatusNoContent) - }) - - ctx := context.Background() - _, err := client.Projects.AddProjectCollaborator(ctx, 1, "u", opt) - if err != nil { - t.Errorf("Projects.AddProjectCollaborator returned error: %v", err) - } - - const methodName = "AddProjectCollaborator" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.AddProjectCollaborator(ctx, -1, "\n", opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.AddProjectCollaborator(ctx, 1, "u", opt) - }) -} - -func TestProjectsService_AddCollaborator_invalidUser(t *testing.T) { - t.Parallel() - client, _, _ := setup(t) - - ctx := context.Background() - _, err := client.Projects.AddProjectCollaborator(ctx, 1, "%", nil) - testURLParseError(t, err) -} - -func TestProjectsService_RemoveCollaborator(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1/collaborators/u", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - w.WriteHeader(http.StatusNoContent) - }) - - ctx := context.Background() - _, err := client.Projects.RemoveProjectCollaborator(ctx, 1, "u") - if err != nil { - t.Errorf("Projects.RemoveProjectCollaborator returned error: %v", err) - } - - const methodName = "RemoveProjectCollaborator" - testBadOptions(t, methodName, func() (err error) { - _, err = client.Projects.RemoveProjectCollaborator(ctx, -1, "\n") - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Projects.RemoveProjectCollaborator(ctx, 1, "u") - }) -} - -func TestProjectsService_RemoveCollaborator_invalidUser(t *testing.T) { - t.Parallel() - client, _, _ := setup(t) - - ctx := context.Background() - _, err := client.Projects.RemoveProjectCollaborator(ctx, 1, "%") - testURLParseError(t, err) -} - -func TestProjectsService_ListCollaborators(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1/collaborators", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) - }) - - opt := &ListCollaboratorOptions{ - ListOptions: ListOptions{Page: 2}, - } - ctx := context.Background() - users, _, err := client.Projects.ListProjectCollaborators(ctx, 1, opt) - if err != nil { - t.Errorf("Projects.ListProjectCollaborators returned error: %v", err) - } - - want := []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} - if !cmp.Equal(users, want) { - t.Errorf("Projects.ListProjectCollaborators returned %+v, want %+v", users, want) - } - - const methodName = "ListProjectCollaborators" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.ListProjectCollaborators(ctx, -1, opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.ListProjectCollaborators(ctx, 1, opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectsService_ListCollaborators_withAffiliation(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1/collaborators", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"affiliation": "all", "page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) - }) - - opt := &ListCollaboratorOptions{ - ListOptions: ListOptions{Page: 2}, - Affiliation: Ptr("all"), - } - ctx := context.Background() - users, _, err := client.Projects.ListProjectCollaborators(ctx, 1, opt) - if err != nil { - t.Errorf("Projects.ListProjectCollaborators returned error: %v", err) - } - - want := []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}} - if !cmp.Equal(users, want) { - t.Errorf("Projects.ListProjectCollaborators returned %+v, want %+v", users, want) - } -} - -func TestProjectsService_ReviewProjectCollaboratorPermission(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/projects/1/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - fmt.Fprintf(w, `{"permission":"admin","user":{"login":"u"}}`) - }) - - ctx := context.Background() - ppl, _, err := client.Projects.ReviewProjectCollaboratorPermission(ctx, 1, "u") - if err != nil { - t.Errorf("Projects.ReviewProjectCollaboratorPermission returned error: %v", err) - } - - want := &ProjectPermissionLevel{ - Permission: Ptr("admin"), - User: &User{ - Login: Ptr("u"), - }, - } - - if !cmp.Equal(ppl, want) { - t.Errorf("Projects.ReviewProjectCollaboratorPermission returned %+v, want %+v", ppl, want) - } - - const methodName = "ReviewProjectCollaboratorPermission" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Projects.ReviewProjectCollaboratorPermission(ctx, -1, "\n") - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Projects.ReviewProjectCollaboratorPermission(ctx, 1, "u") - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestProjectOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectOptions{}, "{}") - - u := &ProjectOptions{ - Name: Ptr("name"), - Body: Ptr("body"), - State: Ptr("state"), - OrganizationPermission: Ptr("op"), - Private: Ptr(false), - } - - want := `{ - "name": "name", - "body": "body", - "state": "state", - "organization_permission": "op", - "private": false - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectColumn_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectColumn{}, "{}") - - u := &ProjectColumn{ - ID: Ptr(int64(1)), - Name: Ptr("name"), - URL: Ptr("url"), - ProjectURL: Ptr("purl"), - CardsURL: Ptr("curl"), - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - NodeID: Ptr("onidp"), - } - - want := `{ - "id": 1, - "name": "name", - "url": "url", - "project_url": "purl", - "cards_url": "curl", - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "onidp" - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectColumnOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectColumnOptions{}, "{}") - - u := &ProjectColumnOptions{ - Name: "name", - } - - want := `{ - "name": "name" - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectColumnMoveOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectColumnMoveOptions{}, "{}") - - u := &ProjectColumnMoveOptions{ - Position: "pos", - } - - want := `{ - "position": "pos" - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectCard_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectCard{}, "{}") - - u := &ProjectCard{ - URL: Ptr("url"), - ColumnURL: Ptr("curl"), - ContentURL: Ptr("conurl"), - ID: Ptr(int64(1)), - Note: Ptr("note"), - Creator: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, - NodeID: Ptr("nid"), - Archived: Ptr(true), - ColumnID: Ptr(int64(1)), - ProjectID: Ptr(int64(1)), - ProjectURL: Ptr("purl"), - ColumnName: Ptr("cn"), - PreviousColumnName: Ptr("pcn"), - } - - want := `{ - "url": "url", - "column_url": "curl", - "content_url": "conurl", - "id": 1, - "note": "note", - "creator": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - }, - "created_at": ` + referenceTimeStr + `, - "updated_at": ` + referenceTimeStr + `, - "node_id": "nid", - "archived": true, - "column_id": 1, - "project_id": 1, - "project_url": "purl", - "column_name": "cn", - "previous_column_name": "pcn" - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectCardOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectCardOptions{}, "{}") - - u := &ProjectCardOptions{ - Note: "note", - ContentID: 1, - ContentType: "ct", - Archived: Ptr(false), - } - - want := `{ - "note": "note", - "content_id": 1, - "content_type": "ct", - "archived": false - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectCardMoveOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectCardMoveOptions{}, "{}") - - u := &ProjectCardMoveOptions{ - Position: "pos", - ColumnID: 1, - } - - want := `{ - "position": "pos", - "column_id": 1 - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectCollaboratorOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectCollaboratorOptions{}, "{}") - - u := &ProjectCollaboratorOptions{ - Permission: Ptr("per"), - } - - want := `{ - "permission": "per" - }` - - testJSONMarshal(t, u, want) -} - -func TestProjectPermissionLevel_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &ProjectPermissionLevel{}, "{}") - - u := &ProjectPermissionLevel{ - Permission: Ptr("per"), - User: &User{ - Login: Ptr("l"), - ID: Ptr(int64(1)), - URL: Ptr("u"), - AvatarURL: Ptr("a"), - GravatarID: Ptr("g"), - Name: Ptr("n"), - Company: Ptr("c"), - Blog: Ptr("b"), - Location: Ptr("l"), - Email: Ptr("e"), - Hireable: Ptr(true), - Bio: Ptr("b"), - TwitterUsername: Ptr("t"), - PublicRepos: Ptr(1), - Followers: Ptr(1), - Following: Ptr(1), - CreatedAt: &Timestamp{referenceTime}, - SuspendedAt: &Timestamp{referenceTime}, - }, - } - - want := `{ - "permission": "per", - "user": { - "login": "l", - "id": 1, - "avatar_url": "a", - "gravatar_id": "g", - "name": "n", - "company": "c", - "blog": "b", - "location": "l", - "email": "e", - "hireable": true, - "bio": "b", - "twitter_username": "t", - "public_repos": 1, - "followers": 1, - "following": 1, - "created_at": ` + referenceTimeStr + `, - "suspended_at": ` + referenceTimeStr + `, - "url": "u" - } - }` - - testJSONMarshal(t, u, want) -} diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index b168964674b..5cdc66dfae2 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -174,9 +174,6 @@ var hookDeliveryPayloadTypeToStruct = map[string]interface{}{ "package": &PackageEvent{}, "page_build": &PageBuildEvent{}, "ping": &PingEvent{}, - "project": &ProjectEvent{}, - "project_card": &ProjectCardEvent{}, - "project_column": &ProjectColumnEvent{}, "projects_v2": &ProjectV2Event{}, "projects_v2_item": &ProjectV2ItemEvent{}, "public": &PublicEvent{}, diff --git a/github/repos_projects.go b/github/repos_projects.go deleted file mode 100644 index 9269d4e95c0..00000000000 --- a/github/repos_projects.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// ProjectListOptions specifies the optional parameters to the -// OrganizationsService.ListProjects and RepositoriesService.ListProjects methods. -type ProjectListOptions struct { - // Indicates the state of the projects to return. Can be either open, closed, or all. Default: open - State string `url:"state,omitempty"` - - ListOptions -} - -// ListProjects lists the projects for a repo. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#list-repository-projects -// -//meta:operation GET /repos/{owner}/{repo}/projects -func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opts *ProjectListOptions) ([]*Project, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - var projects []*Project - resp, err := s.client.Do(ctx, req, &projects) - if err != nil { - return nil, resp, err - } - - return projects, resp, nil -} - -// CreateProject creates a GitHub Project for the specified repository. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#create-a-repository-project -// -//meta:operation POST /repos/{owner}/{repo}/projects -func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo string, opts *ProjectOptions) (*Project, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept headers when APIs fully launch. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - project := &Project{} - resp, err := s.client.Do(ctx, req, project) - if err != nil { - return nil, resp, err - } - - return project, resp, nil -} diff --git a/github/repos_projects_test.go b/github/repos_projects_test.go deleted file mode 100644 index e81b93390fd..00000000000 --- a/github/repos_projects_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2017 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestRepositoriesService_ListProjects(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ProjectListOptions{ListOptions: ListOptions{Page: 2}} - ctx := context.Background() - projects, _, err := client.Repositories.ListProjects(ctx, "o", "r", opt) - if err != nil { - t.Errorf("Repositories.ListProjects returned error: %v", err) - } - - want := []*Project{{ID: Ptr(int64(1))}} - if !cmp.Equal(projects, want) { - t.Errorf("Repositories.ListProjects returned %+v, want %+v", projects, want) - } - - const methodName = "ListProjects" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.ListProjects(ctx, "\n", "\n", opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.ListProjects(ctx, "o", "r", opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestRepositoriesService_CreateProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &ProjectOptions{Name: Ptr("Project Name"), Body: Ptr("Project body.")} - - mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &ProjectOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - project, _, err := client.Repositories.CreateProject(ctx, "o", "r", input) - if err != nil { - t.Errorf("Repositories.CreateProject returned error: %v", err) - } - - want := &Project{ID: Ptr(int64(1))} - if !cmp.Equal(project, want) { - t.Errorf("Repositories.CreateProject returned %+v, want %+v", project, want) - } - - const methodName = "CreateProject" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.CreateProject(ctx, "\n", "\n", input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.CreateProject(ctx, "o", "r", input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} diff --git a/github/teams.go b/github/teams.go index 686ab9a3f8e..579e5b828b5 100644 --- a/github/teams.go +++ b/github/teams.go @@ -615,7 +615,7 @@ func (s *TeamsService) ListUserTeams(ctx context.Context, opts *ListOptions) ([] // GitHub API docs: https://docs.github.com/rest/teams/teams#list-team-projects // //meta:operation GET /orgs/{org}/teams/{team_slug}/projects -func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID int64) ([]*Project, *Response, error) { +func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID int64) ([]*ProjectV2, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects", orgID, teamID) req, err := s.client.NewRequest("GET", u, nil) @@ -626,7 +626,7 @@ func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID i // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeProjectsPreview) - var projects []*Project + var projects []*ProjectV2 resp, err := s.client.Do(ctx, req, &projects) if err != nil { return nil, resp, err @@ -640,7 +640,7 @@ func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID i // GitHub API docs: https://docs.github.com/rest/teams/teams#list-team-projects // //meta:operation GET /orgs/{org}/teams/{team_slug}/projects -func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug string) ([]*Project, *Response, error) { +func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug string) ([]*ProjectV2, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects", org, slug) req, err := s.client.NewRequest("GET", u, nil) @@ -651,7 +651,7 @@ func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug str // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeProjectsPreview) - var projects []*Project + var projects []*ProjectV2 resp, err := s.client.Do(ctx, req, &projects) if err != nil { return nil, resp, err @@ -668,7 +668,7 @@ func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug str // GitHub API docs: https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project // //meta:operation GET /orgs/{org}/teams/{team_slug}/projects/{project_id} -func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID, projectID int64) (*Project, *Response, error) { +func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID, projectID int64) (*ProjectV2, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects/%v", orgID, teamID, projectID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -678,7 +678,7 @@ func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeProjectsPreview) - projects := &Project{} + projects := &ProjectV2{} resp, err := s.client.Do(ctx, req, &projects) if err != nil { return nil, resp, err @@ -693,7 +693,7 @@ func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID // GitHub API docs: https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project // //meta:operation GET /orgs/{org}/teams/{team_slug}/projects/{project_id} -func (s *TeamsService) ReviewTeamProjectsBySlug(ctx context.Context, org, slug string, projectID int64) (*Project, *Response, error) { +func (s *TeamsService) ReviewTeamProjectsBySlug(ctx context.Context, org, slug string, projectID int64) (*ProjectV2, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects/%v", org, slug, projectID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -703,7 +703,7 @@ func (s *TeamsService) ReviewTeamProjectsBySlug(ctx context.Context, org, slug s // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeProjectsPreview) - projects := &Project{} + projects := &ProjectV2{} resp, err := s.client.Do(ctx, req, &projects) if err != nil { return nil, resp, err diff --git a/github/teams_test.go b/github/teams_test.go index 34c5b2026b4..1e3d3da2980 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1023,7 +1023,7 @@ func TestTeamsService_ListProjectsByID(t *testing.T) { t.Errorf("Teams.ListTeamProjectsByID returned error: %v", err) } - want := []*Project{{ID: Ptr(int64(1))}} + want := []*ProjectV2{{ID: Ptr(int64(1))}} if !cmp.Equal(projects, want) { t.Errorf("Teams.ListTeamProjectsByID returned %+v, want %+v", projects, want) } @@ -1059,7 +1059,7 @@ func TestTeamsService_ListProjectsBySlug(t *testing.T) { t.Errorf("Teams.ListTeamProjectsBySlug returned error: %v", err) } - want := []*Project{{ID: Ptr(int64(1))}} + want := []*ProjectV2{{ID: Ptr(int64(1))}} if !cmp.Equal(projects, want) { t.Errorf("Teams.ListTeamProjectsBySlug returned %+v, want %+v", projects, want) } @@ -1095,7 +1095,7 @@ func TestTeamsService_ReviewProjectsByID(t *testing.T) { t.Errorf("Teams.ReviewTeamProjectsByID returned error: %v", err) } - want := &Project{ID: Ptr(int64(1))} + want := &ProjectV2{ID: Ptr(int64(1))} if !cmp.Equal(project, want) { t.Errorf("Teams.ReviewTeamProjectsByID returned %+v, want %+v", project, want) } @@ -1131,7 +1131,7 @@ func TestTeamsService_ReviewProjectsBySlug(t *testing.T) { t.Errorf("Teams.ReviewTeamProjectsBySlug returned error: %v", err) } - want := &Project{ID: Ptr(int64(1))} + want := &ProjectV2{ID: Ptr(int64(1))} if !cmp.Equal(project, want) { t.Errorf("Teams.ReviewTeamProjectsBySlug returned %+v, want %+v", project, want) } diff --git a/github/users_projects.go b/github/users_projects.go deleted file mode 100644 index 0ab57e5c23c..00000000000 --- a/github/users_projects.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2019 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// ListProjects lists the projects for the specified user. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#list-user-projects -// -//meta:operation GET /users/{username}/projects -func (s *UsersService) ListProjects(ctx context.Context, user string, opts *ProjectListOptions) ([]*Project, *Response, error) { - u := fmt.Sprintf("users/%v/projects", user) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - var projects []*Project - resp, err := s.client.Do(ctx, req, &projects) - if err != nil { - return nil, resp, err - } - - return projects, resp, nil -} - -// CreateUserProjectOptions specifies the parameters to the UsersService.CreateProject method. -type CreateUserProjectOptions struct { - // The name of the project. (Required.) - Name string `json:"name"` - // The description of the project. (Optional.) - Body *string `json:"body,omitempty"` -} - -// CreateProject creates a GitHub Project for the current user. -// -// GitHub API docs: https://docs.github.com/rest/projects/projects#create-a-user-project -// -//meta:operation POST /user/projects -func (s *UsersService) CreateProject(ctx context.Context, opts *CreateUserProjectOptions) (*Project, *Response, error) { - u := "user/projects" - req, err := s.client.NewRequest("POST", u, opts) - if err != nil { - return nil, nil, err - } - - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeProjectsPreview) - - project := &Project{} - resp, err := s.client.Do(ctx, req, project) - if err != nil { - return nil, resp, err - } - - return project, resp, nil -} diff --git a/github/users_projects_test.go b/github/users_projects_test.go deleted file mode 100644 index 215dc3ec98f..00000000000 --- a/github/users_projects_test.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2019 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestUsersService_ListProjects(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/users/u/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - testFormValues(t, r, values{"state": "open", "page": "2"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - opt := &ProjectListOptions{State: "open", ListOptions: ListOptions{Page: 2}} - ctx := context.Background() - projects, _, err := client.Users.ListProjects(ctx, "u", opt) - if err != nil { - t.Errorf("Users.ListProjects returned error: %v", err) - } - - want := []*Project{{ID: Ptr(int64(1))}} - if !cmp.Equal(projects, want) { - t.Errorf("Users.ListProjects returned %+v, want %+v", projects, want) - } - - const methodName = "ListProjects" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Users.ListProjects(ctx, "\n", opt) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Users.ListProjects(ctx, "u", opt) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestUsersService_CreateProject(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := &CreateUserProjectOptions{Name: "Project Name", Body: Ptr("Project body.")} - - mux.HandleFunc("/user/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeProjectsPreview) - - v := &CreateUserProjectOptions{} - assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - if !cmp.Equal(v, input) { - t.Errorf("Request body = %+v, want %+v", v, input) - } - - fmt.Fprint(w, `{"id":1}`) - }) - - ctx := context.Background() - project, _, err := client.Users.CreateProject(ctx, input) - if err != nil { - t.Errorf("Users.CreateProject returned error: %v", err) - } - - want := &Project{ID: Ptr(int64(1))} - if !cmp.Equal(project, want) { - t.Errorf("Users.CreateProject returned %+v, want %+v", project, want) - } - - const methodName = "CreateProject" - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Users.CreateProject(ctx, input) - if got != nil { - t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) - } - return resp, err - }) -} - -func TestCreateUserProjectOptions_Marshal(t *testing.T) { - t.Parallel() - testJSONMarshal(t, &CreateUserProjectOptions{}, `{}`) - - c := CreateUserProjectOptions{ - Name: "SomeProject", - Body: Ptr("SomeProjectBody"), - } - - want := `{ - "name": "SomeProject", - "body": "SomeProjectBody" - }` - - testJSONMarshal(t, c, want) -}