From 23b25f592223463bcfddfdef32c2511ccf84ce16 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Fri, 29 Jun 2018 15:41:50 +1000 Subject: [PATCH] add GraphQL Node ID's to response models (#1806) * add node_id to Deployments payloads (Deployment and DeploymentStatus and Account/User/Organization) * add node_id to gist responses * add node_id to Git Blob * add node_id to Git Commit response * add node_id to GitReference response * add node_id to everything that inherits GitReference * add node_id to Issue * add node_id to IssueComment/IssueEvent * add node_id to Label * add node_id to Milestone * add node_id to Project/ProjectCard/ProjectColumn * add node_id to Reaction * add node_id to Release/ReleaseAsset * add node_id to Team * add node_id to Repository.RepositoryContributor/RepositoryInvitation/RepositoryTag * add node_id to Commit related responses * Add node_id to PullRequest related responses * Add node_id to any response models it was found to be missing, based on auditing integration test responses * remove unused test variable that was using a response ctor * fix tests that need to handle node_id now * Committer is a request object as well as response, so make nodeId optional * fix test --- Octokit.Tests/Models/MigrationTests.cs | 14 ------------- .../ObservablePullRequestsClientTests.cs | 4 ++-- Octokit/Models/Common/Committer.cs | 20 +++++++++++++++++++ Octokit/Models/Response/Account.cs | 8 +++++++- Octokit/Models/Response/Author.cs | 8 +++++++- Octokit/Models/Response/Blob.cs | 8 +++++++- Octokit/Models/Response/Commit.cs | 4 ++-- Octokit/Models/Response/CommitComment.cs | 8 +++++++- Octokit/Models/Response/CommitStatus.cs | 8 +++++++- Octokit/Models/Response/Deployment.cs | 8 +++++++- Octokit/Models/Response/DeploymentStatus.cs | 8 +++++++- Octokit/Models/Response/EventInfo.cs | 8 +++++++- Octokit/Models/Response/Gist.cs | 8 +++++++- Octokit/Models/Response/GistComment.cs | 8 +++++++- Octokit/Models/Response/GistFork.cs | 8 +++++++- Octokit/Models/Response/GitHubCommit.cs | 4 ++-- Octokit/Models/Response/GitReference.cs | 8 +++++++- Octokit/Models/Response/GitTag.cs | 5 +++-- Octokit/Models/Response/Issue.cs | 8 +++++++- Octokit/Models/Response/IssueComment.cs | 8 +++++++- Octokit/Models/Response/IssueEvent.cs | 8 +++++++- Octokit/Models/Response/Label.cs | 8 +++++++- Octokit/Models/Response/License.cs | 12 ++--------- Octokit/Models/Response/LicenseMetadata.cs | 13 ++++++------ Octokit/Models/Response/Merge.cs | 4 ++-- Octokit/Models/Response/Migration.cs | 7 +++++++ Octokit/Models/Response/Milestone.cs | 8 +++++++- Octokit/Models/Response/Organization.cs | 4 ++-- .../OrganizationMembershipInvitation.cs | 9 ++++++++- Octokit/Models/Response/Project.cs | 8 +++++++- Octokit/Models/Response/ProjectCard.cs | 8 +++++++- Octokit/Models/Response/ProjectColumn.cs | 8 +++++++- Octokit/Models/Response/PullRequest.cs | 8 +++++++- Octokit/Models/Response/PullRequestCommit.cs | 8 +++++++- Octokit/Models/Response/PullRequestReview.cs | 8 +++++++- .../Response/PullRequestReviewComment.cs | 8 +++++++- Octokit/Models/Response/Reaction.cs | 8 +++++++- Octokit/Models/Response/Reference.cs | 8 +++++++- Octokit/Models/Response/Release.cs | 8 +++++++- Octokit/Models/Response/ReleaseAsset.cs | 8 +++++++- Octokit/Models/Response/Repository.cs | 8 +++++++- .../Models/Response/RepositoryContributor.cs | 4 ++-- .../Models/Response/RepositoryInvitation.cs | 8 +++++++- Octokit/Models/Response/RepositoryTag.cs | 8 +++++++- Octokit/Models/Response/TagObject.cs | 4 ++-- Octokit/Models/Response/Team.cs | 8 +++++++- Octokit/Models/Response/TimelineEventInfo.cs | 9 ++++++++- Octokit/Models/Response/User.cs | 4 ++-- 48 files changed, 295 insertions(+), 82 deletions(-) diff --git a/Octokit.Tests/Models/MigrationTests.cs b/Octokit.Tests/Models/MigrationTests.cs index 31b89da75e..128606dc13 100644 --- a/Octokit.Tests/Models/MigrationTests.cs +++ b/Octokit.Tests/Models/MigrationTests.cs @@ -110,20 +110,6 @@ public class MigrationTests ] }"; - private static readonly Migration migration = new Migration( - id: 79, - guid: "0b989ba4-242f-11e5-81e1-c7b6966d2516", - state: Migration.MigrationState.Exported, - lockRepositories: true, - excludeAttachments: false, - url: "https://api.github.com/orgs/octo-org/migrations/79", - createdAt: "2015-07-06T15:33:38-07:00", - updatedAt: "2015-07-06T15:33:38-07:00", - repositories: new List - { - new Repository(1296269) - }); - [Fact] public void CanBeDeserialized() { diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index 8ca0e56061..b76e89bdf2 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -629,7 +629,7 @@ public class TheCommitsMethod [Fact] public async Task FetchesAllCommitsForPullRequest() { - var commit = new PullRequestCommit(null, null, null, null, null, Enumerable.Empty(), null, null); + var commit = new PullRequestCommit("123ABC", null, null, null, null, null, Enumerable.Empty(), null, null); var expectedUrl = "repos/fake/repo/pulls/42/commits"; var gitHubClient = Substitute.For(); var connection = Substitute.For(); @@ -653,7 +653,7 @@ public async Task FetchesAllCommitsForPullRequest() [Fact] public async Task FetchesAllCommitsForPullRequestWithRepositoryId() { - var commit = new PullRequestCommit(null, null, null, null, null, Enumerable.Empty(), null, null); + var commit = new PullRequestCommit("123ABC", null, null, null, null, null, Enumerable.Empty(), null, null); var expectedUrl = "repositories/1/pulls/42/commits"; var gitHubClient = Substitute.For(); var connection = Substitute.For(); diff --git a/Octokit/Models/Common/Committer.cs b/Octokit/Models/Common/Committer.cs index c9949d5487..bc8539d0c3 100644 --- a/Octokit/Models/Common/Committer.cs +++ b/Octokit/Models/Common/Committer.cs @@ -29,6 +29,26 @@ public Committer(string name, string email, DateTimeOffset date) Date = date; } + /// + /// Initializes a new instance of the class. + /// + /// The GraphQL Node Id + /// The full name of the author or committer. + /// The email. + /// The date. + public Committer(string nodeId, string name, string email, DateTimeOffset date) + { + NodeId = nodeId; + Name = name; + Email = email; + Date = date; + } + + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// Gets the name of the author or committer. /// diff --git a/Octokit/Models/Response/Account.cs b/Octokit/Models/Response/Account.cs index 9538411933..9e242b9e9e 100644 --- a/Octokit/Models/Response/Account.cs +++ b/Octokit/Models/Response/Account.cs @@ -9,7 +9,7 @@ public abstract class Account { protected Account() { } - protected Account(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, AccountType type, string url) + protected Account(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, string nodeId, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, AccountType type, string url) { AvatarUrl = avatarUrl; Bio = bio; @@ -28,6 +28,7 @@ protected Account(string avatarUrl, string bio, string blog, int collaborators, Location = location; Login = login; Name = name; + NodeId = nodeId; OwnedPrivateRepos = ownedPrivateRepos; Plan = plan; PrivateGists = privateGists; @@ -103,6 +104,11 @@ protected Account(string avatarUrl, string bio, string blog, int collaborators, /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The account's geographic location. /// diff --git a/Octokit/Models/Response/Author.cs b/Octokit/Models/Response/Author.cs index a416b7bb44..c37ee6a6e8 100644 --- a/Octokit/Models/Response/Author.cs +++ b/Octokit/Models/Response/Author.cs @@ -9,10 +9,11 @@ public class Author { public Author() { } - public Author(string login, int id, string avatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin) + public Author(string login, int id, string nodeId, string avatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin) { Login = login; Id = id; + NodeId = nodeId; AvatarUrl = avatarUrl; Url = url; HtmlUrl = htmlUrl; @@ -33,6 +34,11 @@ public Author(string login, int id, string avatarUrl, string url, string htmlUrl public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + public string AvatarUrl { get; protected set; } public string Url { get; protected set; } diff --git a/Octokit/Models/Response/Blob.cs b/Octokit/Models/Response/Blob.cs index 61af602889..b4df6a4f36 100644 --- a/Octokit/Models/Response/Blob.cs +++ b/Octokit/Models/Response/Blob.cs @@ -9,14 +9,20 @@ public class Blob { public Blob() { } - public Blob(string content, EncodingType encoding, string sha, int size) + public Blob(string nodeId, string content, EncodingType encoding, string sha, int size) { + NodeId = nodeId; Content = content; Encoding = encoding; Sha = sha; Size = size; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The content of the blob. /// diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs index 1623692a48..e72abbf649 100644 --- a/Octokit/Models/Response/Commit.cs +++ b/Octokit/Models/Response/Commit.cs @@ -10,8 +10,8 @@ public class Commit : GitReference { public Commit() { } - public Commit(string url, string label, string @ref, string sha, User user, Repository repository, string message, Committer author, Committer committer, GitReference tree, IEnumerable parents, int commentCount, Verification verification) - : base(url, label, @ref, sha, user, repository) + public Commit(string nodeId, string url, string label, string @ref, string sha, User user, Repository repository, string message, Committer author, Committer committer, GitReference tree, IEnumerable parents, int commentCount, Verification verification) + : base(nodeId, url, label, @ref, sha, user, repository) { Ensure.ArgumentNotNull(parents, nameof(parents)); diff --git a/Octokit/Models/Response/CommitComment.cs b/Octokit/Models/Response/CommitComment.cs index 4038f6e4e8..531423a103 100644 --- a/Octokit/Models/Response/CommitComment.cs +++ b/Octokit/Models/Response/CommitComment.cs @@ -9,9 +9,10 @@ public class CommitComment { public CommitComment() { } - public CommitComment(int id, string url, string htmlUrl, string body, string path, int position, int? line, string commitId, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt, ReactionSummary reactions) + public CommitComment(int id, string nodeId, string url, string htmlUrl, string body, string path, int position, int? line, string commitId, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt, ReactionSummary reactions) { Id = id; + NodeId = nodeId; Url = url; HtmlUrl = htmlUrl; Body = body; @@ -30,6 +31,11 @@ public CommitComment(int id, string url, string htmlUrl, string body, string pat /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The URL for this repository comment. /// diff --git a/Octokit/Models/Response/CommitStatus.cs b/Octokit/Models/Response/CommitStatus.cs index dfc955c50d..d5660f21da 100644 --- a/Octokit/Models/Response/CommitStatus.cs +++ b/Octokit/Models/Response/CommitStatus.cs @@ -10,7 +10,7 @@ public class CommitStatus { public CommitStatus() { } - public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitState state, string targetUrl, string description, string context, long id, string url, User creator) + public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitState state, string targetUrl, string description, string context, long id, string nodeId, string url, User creator) { CreatedAt = createdAt; UpdatedAt = updatedAt; @@ -19,6 +19,7 @@ public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitSt Description = description; Context = context; Id = id; + NodeId = nodeId; Url = url; Creator = creator; } @@ -59,6 +60,11 @@ public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitSt /// public long Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The URL of the status. /// diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index a9ab8fe2cd..4d4e5be667 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -13,9 +13,10 @@ public class Deployment { public Deployment() { } - public Deployment(int id, string sha, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment) + public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment) { Id = id; + NodeId = nodeId; Sha = sha; Url = url; Creator = creator; @@ -33,6 +34,11 @@ public Deployment(int id, string sha, string url, User creator, IReadOnlyDiction /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// /// diff --git a/Octokit/Models/Response/DeploymentStatus.cs b/Octokit/Models/Response/DeploymentStatus.cs index 363144da5f..a7bef3ca05 100644 --- a/Octokit/Models/Response/DeploymentStatus.cs +++ b/Octokit/Models/Response/DeploymentStatus.cs @@ -11,9 +11,10 @@ public class DeploymentStatus { public DeploymentStatus() { } - public DeploymentStatus(int id, string url, DeploymentState state, User creator, IReadOnlyDictionary payload, string targetUrl, string logUrl, string environmentUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description) + public DeploymentStatus(int id, string nodeId, string url, DeploymentState state, User creator, IReadOnlyDictionary payload, string targetUrl, string logUrl, string environmentUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description) { Id = id; + NodeId = nodeId; Url = url; State = state; Creator = creator; @@ -31,6 +32,11 @@ public DeploymentStatus(int id, string url, DeploymentState state, User creator, /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The API URL for this deployment status. /// diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index 5491acb8bd..7daf2e15bb 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -11,9 +11,10 @@ public class EventInfo { public EventInfo() { } - public EventInfo(int id, string url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt) + public EventInfo(int id, string nodeId, string url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt) { Id = id; + NodeId = nodeId; Url = url; Actor = actor; Assignee = assignee; @@ -28,6 +29,11 @@ public EventInfo(int id, string url, User actor, User assignee, Label label, Eve /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The URL for this event. /// diff --git a/Octokit/Models/Response/Gist.cs b/Octokit/Models/Response/Gist.cs index 1c50a50c00..2ec6ffdc52 100644 --- a/Octokit/Models/Response/Gist.cs +++ b/Octokit/Models/Response/Gist.cs @@ -10,10 +10,11 @@ public class Gist { public Gist() { } - public Gist(string url, string id, string description, bool @public, User owner, IReadOnlyDictionary files, int comments, string commentsUrl, string htmlUrl, string gitPullUrl, string gitPushUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, IReadOnlyList forks, IReadOnlyList history) + public Gist(string url, string id, string nodeId, string description, bool @public, User owner, IReadOnlyDictionary files, int comments, string commentsUrl, string htmlUrl, string gitPullUrl, string gitPushUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, IReadOnlyList forks, IReadOnlyList history) { Url = url; Id = id; + NodeId = nodeId; Description = description; Public = @public; Owner = owner; @@ -42,6 +43,11 @@ public Gist(string url, string id, string description, bool @public, User owner, /// public string Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// A description of the . /// diff --git a/Octokit/Models/Response/GistComment.cs b/Octokit/Models/Response/GistComment.cs index e88d46ccba..9a9b773c18 100644 --- a/Octokit/Models/Response/GistComment.cs +++ b/Octokit/Models/Response/GistComment.cs @@ -9,9 +9,10 @@ public class GistComment { public GistComment() { } - public GistComment(int id, string url, string body, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt) + public GistComment(int id, string nodeId, string url, string body, User user, DateTimeOffset createdAt, DateTimeOffset? updatedAt) { Id = id; + NodeId = nodeId; Url = url; Body = body; User = user; @@ -24,6 +25,11 @@ public GistComment(int id, string url, string body, User user, DateTimeOffset cr /// public int Id { get; protected set; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The URL for this gist comment. /// diff --git a/Octokit/Models/Response/GistFork.cs b/Octokit/Models/Response/GistFork.cs index 9729fc4307..888b81cb8c 100644 --- a/Octokit/Models/Response/GistFork.cs +++ b/Octokit/Models/Response/GistFork.cs @@ -9,13 +9,19 @@ public class GistFork { public GistFork() { } - public GistFork(User user, string url, DateTimeOffset createdAt) + public GistFork(string nodeId, User user, string url, DateTimeOffset createdAt) { + NodeId = nodeId; User = user; Url = url; CreatedAt = createdAt; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The that created this /// diff --git a/Octokit/Models/Response/GitHubCommit.cs b/Octokit/Models/Response/GitHubCommit.cs index facc929b71..34f4a35606 100644 --- a/Octokit/Models/Response/GitHubCommit.cs +++ b/Octokit/Models/Response/GitHubCommit.cs @@ -11,8 +11,8 @@ public class GitHubCommit : GitReference { public GitHubCommit() { } - public GitHubCommit(string url, string label, string @ref, string sha, User user, Repository repository, Author author, string commentsUrl, Commit commit, Author committer, string htmlUrl, GitHubCommitStats stats, IReadOnlyList parents, IReadOnlyList files) - : base(url, label, @ref, sha, user, repository) + public GitHubCommit(string nodeId, string url, string label, string @ref, string sha, User user, Repository repository, Author author, string commentsUrl, Commit commit, Author committer, string htmlUrl, GitHubCommitStats stats, IReadOnlyList parents, IReadOnlyList files) + : base(nodeId, url, label, @ref, sha, user, repository) { Author = author; CommentsUrl = commentsUrl; diff --git a/Octokit/Models/Response/GitReference.cs b/Octokit/Models/Response/GitReference.cs index ec4466839f..8d9906917a 100644 --- a/Octokit/Models/Response/GitReference.cs +++ b/Octokit/Models/Response/GitReference.cs @@ -9,8 +9,9 @@ public class GitReference { public GitReference() { } - public GitReference(string url, string label, string @ref, string sha, User user, Repository repository) + public GitReference(string nodeId, string url, string label, string @ref, string sha, User user, Repository repository) { + NodeId = nodeId; Url = url; Label = label; Ref = @ref; @@ -19,6 +20,11 @@ public GitReference(string url, string label, string @ref, string sha, User user Repository = repository; } + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + /// /// The URL associated with this reference. /// diff --git a/Octokit/Models/Response/GitTag.cs b/Octokit/Models/Response/GitTag.cs index 5c7e73d5d7..6db53711d7 100644 --- a/Octokit/Models/Response/GitTag.cs +++ b/Octokit/Models/Response/GitTag.cs @@ -7,8 +7,8 @@ public class GitTag : GitReference { public GitTag() { } - public GitTag(string url, string label, string @ref, string sha, User user, Repository repository, string tag, string message, Committer tagger, TagObject @object, Verification verification) - : base(url, label, @ref, sha, user, repository) + public GitTag(string nodeId, string url, string label, string @ref, string sha, User user, Repository repository, string tag, string message, Committer tagger, TagObject @object, Verification verification) + : base(nodeId, url, label, @ref, sha, user, repository) { Tag = tag; Message = message; @@ -17,6 +17,7 @@ public GitTag(string url, string label, string @ref, string sha, User user, Repo Verification = verification; } + public string Tag { get; protected set; } public string Message { get; protected set; } diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index 2f7b930234..4a0add46fa 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -11,9 +11,10 @@ public class Issue { public Issue() { } - public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList