From b42eedbdb981ca71d06bf58da1025cc5260a7f92 Mon Sep 17 00:00:00 2001 From: PMExtra Date: Thu, 26 Oct 2023 11:17:53 +0800 Subject: [PATCH 1/4] Support long and string id for projects and groups, then obsolete int --- NGitLab.Mock/Clients/ClientBase.cs | 2 +- NGitLab.Mock/Clients/ClusterClient.cs | 4 +- NGitLab.Mock/Clients/CommitClient.cs | 4 +- NGitLab.Mock/Clients/CommitStatusClient.cs | 4 +- NGitLab.Mock/Clients/EnvironmentClient.cs | 4 +- NGitLab.Mock/Clients/EventClient.cs | 4 +- NGitLab.Mock/Clients/GitLabClient.cs | 95 +++++++--- NGitLab.Mock/Clients/GroupBadgeClient.cs | 4 +- NGitLab.Mock/Clients/GroupClient.cs | 2 +- NGitLab.Mock/Clients/GroupSearchClient.cs | 7 +- NGitLab.Mock/Clients/GroupVariableClient.cs | 4 +- NGitLab.Mock/Clients/JobClient.cs | 4 +- NGitLab.Mock/Clients/MergeRequestClient.cs | 4 +- NGitLab.Mock/Clients/MilestoneClient.cs | 9 +- NGitLab.Mock/Clients/PipelineClient.cs | 4 +- NGitLab.Mock/Clients/ProjectBadgeClient.cs | 4 +- .../Clients/ProjectIssueNoteClient.cs | 4 +- .../ProjectLevelApprovalRulesClient.cs | 4 +- NGitLab.Mock/Clients/ProjectSearchClient.cs | 7 +- NGitLab.Mock/Clients/ProjectVariableClient.cs | 4 +- NGitLab.Mock/Clients/ProtectedBranchClient.cs | 4 +- NGitLab.Mock/Clients/ReleaseClient.cs | 4 +- NGitLab.Mock/Clients/RepositoryClient.cs | 4 +- NGitLab.Mock/Clients/TriggerClient.cs | 4 +- NGitLab.Mock/Clients/WikiClient.cs | 4 +- NGitLab.Mock/GroupExtensions.cs | 28 ++- NGitLab.Mock/ProjectExtensions.cs | 33 ++-- NGitLab.Mock/PublicAPI.Unshipped.txt | 6 +- NGitLab/GitLabClient.cs | 170 ++++++++++-------- NGitLab/IGitLabClient.cs | 78 +++++++- NGitLab/Impl/ClusterClient.cs | 12 +- NGitLab/Impl/CommitClient.cs | 12 +- NGitLab/Impl/CommitStatusClient.cs | 16 +- NGitLab/Impl/EnvironmentClient.cs | 8 +- NGitLab/Impl/GroupBadgeClient.cs | 7 +- NGitLab/Impl/GroupVariableClient.cs | 7 +- NGitLab/Impl/JobClient.cs | 8 +- NGitLab/Impl/MergeRequestClient.cs | 8 +- NGitLab/Impl/MilestoneClient.cs | 8 +- NGitLab/Impl/PipelineClient.cs | 10 +- NGitLab/Impl/ProjectBadgeClient.cs | 5 +- NGitLab/Impl/ProjectIssueNoteClient.cs | 13 +- .../Impl/ProjectLevelApprovalRulesClient.cs | 11 +- NGitLab/Impl/ProjectVariableClient.cs | 7 +- NGitLab/Impl/ProtectedBranchClient.cs | 4 +- NGitLab/Impl/ReleaseClient.cs | 6 +- NGitLab/Impl/RepositoryClient.cs | 10 +- NGitLab/Impl/TriggerClient.cs | 11 +- NGitLab/Impl/WikiClient.cs | 9 +- NGitLab/Models/GroupId.cs | 26 +++ NGitLab/Models/IdOrNamespacedPath.cs | 25 +++ NGitLab/Models/ProjectId.cs | 26 +++ NGitLab/PublicAPI.Unshipped.txt | 78 ++++++++ 53 files changed, 601 insertions(+), 239 deletions(-) create mode 100644 NGitLab/Models/GroupId.cs create mode 100644 NGitLab/Models/IdOrNamespacedPath.cs create mode 100644 NGitLab/Models/ProjectId.cs diff --git a/NGitLab.Mock/Clients/ClientBase.cs b/NGitLab.Mock/Clients/ClientBase.cs index da9e6b2e..ab9868c7 100644 --- a/NGitLab.Mock/Clients/ClientBase.cs +++ b/NGitLab.Mock/Clients/ClientBase.cs @@ -29,7 +29,7 @@ protected Group GetGroup(object id, GroupPermission permissions) var group = id switch { - int idInt => Server.AllGroups.FindGroupById(idInt), + int idInt => Server.AllGroups.FindById(idInt), string idStr => Server.AllGroups.FindGroup(idStr), _ => throw new ArgumentException($"Id of type '{id.GetType()}' is not supported"), }; diff --git a/NGitLab.Mock/Clients/ClusterClient.cs b/NGitLab.Mock/Clients/ClusterClient.cs index 183e477c..d1cb2c02 100644 --- a/NGitLab.Mock/Clients/ClusterClient.cs +++ b/NGitLab.Mock/Clients/ClusterClient.cs @@ -8,10 +8,10 @@ internal sealed class ClusterClient : ClientBase, IClusterClient { private readonly int _projectId; - public ClusterClient(ClientContext context, int projectId) + public ClusterClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public IEnumerable All => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/CommitClient.cs b/NGitLab.Mock/Clients/CommitClient.cs index 62d473a0..aa3fe7ab 100644 --- a/NGitLab.Mock/Clients/CommitClient.cs +++ b/NGitLab.Mock/Clients/CommitClient.cs @@ -9,10 +9,10 @@ internal sealed class CommitClient : ClientBase, ICommitClient { private readonly int _projectId; - public CommitClient(ClientContext context, int projectId) + public CommitClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Commit Create(CommitCreate commit) diff --git a/NGitLab.Mock/Clients/CommitStatusClient.cs b/NGitLab.Mock/Clients/CommitStatusClient.cs index 0f70a8f6..2d691303 100644 --- a/NGitLab.Mock/Clients/CommitStatusClient.cs +++ b/NGitLab.Mock/Clients/CommitStatusClient.cs @@ -9,10 +9,10 @@ internal sealed class CommitStatusClient : ClientBase, ICommitStatusClient { private readonly int _projectId; - public CommitStatusClient(ClientContext context, int projectId) + public CommitStatusClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public CommitStatusCreate AddOrUpdate(CommitStatusCreate status) diff --git a/NGitLab.Mock/Clients/EnvironmentClient.cs b/NGitLab.Mock/Clients/EnvironmentClient.cs index 86a5f7fa..9b88572a 100644 --- a/NGitLab.Mock/Clients/EnvironmentClient.cs +++ b/NGitLab.Mock/Clients/EnvironmentClient.cs @@ -10,10 +10,10 @@ internal sealed class EnvironmentClient : ClientBase, IEnvironmentClient { private readonly int _projectId; - public EnvironmentClient(ClientContext context, int projectId) + public EnvironmentClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public IEnumerable All => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/EventClient.cs b/NGitLab.Mock/Clients/EventClient.cs index 5c755ddc..33f039a9 100644 --- a/NGitLab.Mock/Clients/EventClient.cs +++ b/NGitLab.Mock/Clients/EventClient.cs @@ -14,11 +14,11 @@ public EventClient(ClientContext context) { } - public EventClient(ClientContext context, int? userId = null, int? projectId = null) + public EventClient(ClientContext context, int? userId = null, ProjectId projectId = null) : base(context) { _userId = userId; - _projectId = projectId; + _projectId = projectId is null ? null : Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } IEnumerable IEventClient.Get(EventQuery query) diff --git a/NGitLab.Mock/Clients/GitLabClient.cs b/NGitLab.Mock/Clients/GitLabClient.cs index b5363a23..2ae10d62 100644 --- a/NGitLab.Mock/Clients/GitLabClient.cs +++ b/NGitLab.Mock/Clients/GitLabClient.cs @@ -1,4 +1,5 @@ using NGitLab.Impl; +using NGitLab.Models; namespace NGitLab.Mock.Clients { @@ -19,7 +20,9 @@ public GitLabClient(ClientContext context) public IMembersClient Members => new MembersClient(Context); - public ICommitClient GetCommits(int projectId) => new CommitClient(Context, projectId); + public ICommitClient GetCommits(int projectId) => GetCommits((long)projectId); + + public ICommitClient GetCommits(ProjectId projectId) => new CommitClient(Context, projectId); public IIssueClient Issues => new IssueClient(Context); @@ -55,50 +58,94 @@ public IGraphQLClient GraphQL public IEventClient GetEvents() => new EventClient(Context); - public IEventClient GetUserEvents(int userId) => new EventClient(Context, userId: userId); + public IEventClient GetUserEvents(int userId) => new EventClient(Context, userId); + + public IEventClient GetProjectEvents(int projectId) => GetProjectEvents((long)projectId); + + public IEventClient GetProjectEvents(ProjectId projectId) => new EventClient(Context, null, projectId); + + public ICommitStatusClient GetCommitStatus(int projectId) => GetCommitStatus((long)projectId); + + public ICommitStatusClient GetCommitStatus(ProjectId projectId) => new CommitStatusClient(Context, projectId); + + public IEnvironmentClient GetEnvironmentClient(int projectId) => GetEnvironmentClient((long)projectId); + + public IEnvironmentClient GetEnvironmentClient(ProjectId projectId) => new EnvironmentClient(Context, projectId); + + public IClusterClient GetClusterClient(int projectId) => GetClusterClient((long)projectId); + + public IClusterClient GetClusterClient(ProjectId projectId) => new ClusterClient(Context, projectId); + + public IGroupBadgeClient GetGroupBadgeClient(int groupId) => GetGroupBadgeClient((long)groupId); + + public IGroupBadgeClient GetGroupBadgeClient(GroupId groupId) => new GroupBadgeClient(Context, groupId); + + public IGroupVariableClient GetGroupVariableClient(int groupId) => GetGroupVariableClient((long)groupId); + + public IGroupVariableClient GetGroupVariableClient(GroupId groupId) => new GroupVariableClient(Context, groupId); + + public IJobClient GetJobs(int projectId) => GetJobs((long)projectId); + + public IJobClient GetJobs(ProjectId projectId) => new JobClient(Context, projectId); + + public IMergeRequestClient GetMergeRequest(int projectId) => GetMergeRequest((long)projectId); + + public IMergeRequestClient GetMergeRequest(ProjectId projectId) => new MergeRequestClient(Context, projectId); + + public IMilestoneClient GetMilestone(int projectId) => GetMilestone((long)projectId); + + public IMilestoneClient GetMilestone(ProjectId projectId) => new MilestoneClient(Context, projectId, MilestoneScope.Projects); + + public IMilestoneClient GetGroupMilestone(int groupId) => GetGroupMilestone((long)groupId); + + public IMilestoneClient GetGroupMilestone(GroupId groupId) => new MilestoneClient(Context, groupId, MilestoneScope.Groups); + + public IReleaseClient GetReleases(int projectId) => GetReleases((long)projectId); + + public IReleaseClient GetReleases(ProjectId projectId) => new ReleaseClient(Context, projectId); - public IEventClient GetProjectEvents(int projectId) => new EventClient(Context, projectId: projectId); + public IPipelineClient GetPipelines(int projectId) => GetPipelines((long)projectId); - public ICommitStatusClient GetCommitStatus(int projectId) => new CommitStatusClient(Context, projectId); + public IPipelineClient GetPipelines(ProjectId projectId) => new PipelineClient(Context, jobClient: GetJobs(projectId), projectId: projectId); - public IEnvironmentClient GetEnvironmentClient(int projectId) => new EnvironmentClient(Context, projectId); + public IProjectBadgeClient GetProjectBadgeClient(int projectId) => GetProjectBadgeClient((long)projectId); - public IClusterClient GetClusterClient(int projectId) => new ClusterClient(Context, projectId); + public IProjectBadgeClient GetProjectBadgeClient(ProjectId projectId) => new ProjectBadgeClient(Context, projectId); - public IGroupBadgeClient GetGroupBadgeClient(int groupId) => new GroupBadgeClient(Context, groupId); + public IProjectIssueNoteClient GetProjectIssueNoteClient(int projectId) => GetProjectIssueNoteClient((long)projectId); - public IGroupVariableClient GetGroupVariableClient(int groupId) => new GroupVariableClient(Context, groupId); + public IProjectIssueNoteClient GetProjectIssueNoteClient(ProjectId projectId) => new ProjectIssueNoteClient(Context, projectId); - public IJobClient GetJobs(int projectId) => new JobClient(Context, projectId); + public IProjectVariableClient GetProjectVariableClient(int projectId) => GetProjectVariableClient((long)projectId); - public IMergeRequestClient GetMergeRequest(int projectId) => new MergeRequestClient(Context, projectId); + public IProjectVariableClient GetProjectVariableClient(ProjectId projectId) => new ProjectVariableClient(Context, projectId); - public IMilestoneClient GetMilestone(int projectId) => new MilestoneClient(Context, projectId, MilestoneScope.Projects); + public IRepositoryClient GetRepository(int projectId) => GetRepository((long)projectId); - public IMilestoneClient GetGroupMilestone(int groupId) => new MilestoneClient(Context, groupId, MilestoneScope.Groups); + public IRepositoryClient GetRepository(ProjectId projectId) => new RepositoryClient(Context, projectId); - public IReleaseClient GetReleases(int projectId) => new ReleaseClient(Context, projectId); + public ITriggerClient GetTriggers(int projectId) => GetTriggers((long)projectId); - public IPipelineClient GetPipelines(int projectId) => new PipelineClient(Context, jobClient: GetJobs(projectId), projectId: projectId); + public ITriggerClient GetTriggers(ProjectId projectId) => new TriggerClient(Context, projectId); - public IProjectBadgeClient GetProjectBadgeClient(int projectId) => new ProjectBadgeClient(Context, projectId); + public IWikiClient GetWikiClient(int projectId) => GetWikiClient((long)projectId); - public IProjectIssueNoteClient GetProjectIssueNoteClient(int projectId) => new ProjectIssueNoteClient(Context, projectId); + public IWikiClient GetWikiClient(ProjectId projectId) => new WikiClient(Context, projectId); - public IProjectVariableClient GetProjectVariableClient(int projectId) => new ProjectVariableClient(Context, projectId); + public IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(int projectId) => GetProjectLevelApprovalRulesClient((long)projectId); - public IRepositoryClient GetRepository(int projectId) => new RepositoryClient(Context, projectId); + public IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(ProjectId projectId) => new ProjectLevelApprovalRulesClient(Context, projectId); - public ITriggerClient GetTriggers(int projectId) => new TriggerClient(Context, projectId); + public IProtectedBranchClient GetProtectedBranchClient(int projectId) => GetProtectedBranchClient((long)projectId); - public IWikiClient GetWikiClient(int projectId) => new WikiClient(Context, projectId); + public IProtectedBranchClient GetProtectedBranchClient(ProjectId projectId) => new ProtectedBranchClient(Context, projectId); - public IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(int projectId) => new ProjectLevelApprovalRulesClient(Context, projectId); + public ISearchClient GetGroupSearchClient(int groupId) => GetGroupSearchClient((long)groupId); - public IProtectedBranchClient GetProtectedBranchClient(int projectId) => new ProtectedBranchClient(Context, projectId); + public ISearchClient GetGroupSearchClient(GroupId groupId) => new GroupSearchClient(Context, groupId); - public ISearchClient GetGroupSearchClient(int groupId) => new GroupSearchClient(Context, groupId); + public ISearchClient GetProjectSearchClient(int projectId) => GetProjectSearchClient((long)projectId); - public ISearchClient GetProjectSearchClient(int projectId) => new ProjectSearchClient(Context, projectId); + public ISearchClient GetProjectSearchClient(ProjectId projectId) => new ProjectSearchClient(Context, projectId); } } diff --git a/NGitLab.Mock/Clients/GroupBadgeClient.cs b/NGitLab.Mock/Clients/GroupBadgeClient.cs index ee1d461c..a6e46bd8 100644 --- a/NGitLab.Mock/Clients/GroupBadgeClient.cs +++ b/NGitLab.Mock/Clients/GroupBadgeClient.cs @@ -8,10 +8,10 @@ internal sealed class GroupBadgeClient : ClientBase, IGroupBadgeClient { private readonly int _groupId; - public GroupBadgeClient(ClientContext context, int groupId) + public GroupBadgeClient(ClientContext context, GroupId groupId) : base(context) { - _groupId = groupId; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; } public Models.Badge this[int id] diff --git a/NGitLab.Mock/Clients/GroupClient.cs b/NGitLab.Mock/Clients/GroupClient.cs index 78ebff51..40eec7d8 100644 --- a/NGitLab.Mock/Clients/GroupClient.cs +++ b/NGitLab.Mock/Clients/GroupClient.cs @@ -235,7 +235,7 @@ public Models.Group Update(int id, GroupUpdate groupUpdate) { using (Context.BeginOperationScope()) { - var group = Server.AllGroups.FindGroupById(id); + var group = Server.AllGroups.FindById(id); if (group == null || !group.CanUserViewGroup(Context.User)) throw new GitLabNotFoundException(); diff --git a/NGitLab.Mock/Clients/GroupSearchClient.cs b/NGitLab.Mock/Clients/GroupSearchClient.cs index a092214d..acd61a68 100644 --- a/NGitLab.Mock/Clients/GroupSearchClient.cs +++ b/NGitLab.Mock/Clients/GroupSearchClient.cs @@ -3,15 +3,16 @@ namespace NGitLab.Mock.Clients { - internal sealed class GroupSearchClient : ISearchClient + internal sealed class GroupSearchClient : ClientBase, ISearchClient { private readonly ClientContext _context; private readonly int _groupId; - public GroupSearchClient(ClientContext context, int groupId) + public GroupSearchClient(ClientContext context, GroupId groupId) + : base(context) { _context = context; - _groupId = groupId; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; } public GitLabCollectionResponse GetBlobsAsync(SearchQuery query) diff --git a/NGitLab.Mock/Clients/GroupVariableClient.cs b/NGitLab.Mock/Clients/GroupVariableClient.cs index 6a0b51b1..6bc83058 100644 --- a/NGitLab.Mock/Clients/GroupVariableClient.cs +++ b/NGitLab.Mock/Clients/GroupVariableClient.cs @@ -8,10 +8,10 @@ internal sealed class GroupVariableClient : ClientBase, IGroupVariableClient { private readonly int _groupId; - public GroupVariableClient(ClientContext context, int groupId) + public GroupVariableClient(ClientContext context, GroupId groupId) : base(context) { - _groupId = groupId; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; } public Variable this[string key] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/JobClient.cs b/NGitLab.Mock/Clients/JobClient.cs index aa97a9c9..38fedbd9 100644 --- a/NGitLab.Mock/Clients/JobClient.cs +++ b/NGitLab.Mock/Clients/JobClient.cs @@ -13,10 +13,10 @@ internal sealed class JobClient : ClientBase, IJobClient { private readonly int _projectId; - public JobClient(ClientContext context, int projectId) + public JobClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Models.Job Get(int jobId) diff --git a/NGitLab.Mock/Clients/MergeRequestClient.cs b/NGitLab.Mock/Clients/MergeRequestClient.cs index 201bd7ad..f8a963a9 100644 --- a/NGitLab.Mock/Clients/MergeRequestClient.cs +++ b/NGitLab.Mock/Clients/MergeRequestClient.cs @@ -19,10 +19,10 @@ public MergeRequestClient(ClientContext context) { } - public MergeRequestClient(ClientContext context, int projectId) + public MergeRequestClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } private void AssertProjectId() diff --git a/NGitLab.Mock/Clients/MilestoneClient.cs b/NGitLab.Mock/Clients/MilestoneClient.cs index 0e688f6d..ec00912a 100644 --- a/NGitLab.Mock/Clients/MilestoneClient.cs +++ b/NGitLab.Mock/Clients/MilestoneClient.cs @@ -12,10 +12,15 @@ internal sealed class MilestoneClient : ClientBase, IMilestoneClient { private readonly int _resourceId; - public MilestoneClient(ClientContext context, int id, MilestoneScope scope) + public MilestoneClient(ClientContext context, IdOrNamespacedPath id, MilestoneScope scope) : base(context) { - _resourceId = id; + _resourceId = scope switch + { + MilestoneScope.Groups => Server.AllGroups.FindGroup(id.ValueAsUriParameter).Id, + MilestoneScope.Projects => Server.AllProjects.FindProject(id.ValueAsUriParameter).Id, + _ => throw new NotSupportedException($"{scope} milestone is not supported yet."), + }; Scope = scope; } diff --git a/NGitLab.Mock/Clients/PipelineClient.cs b/NGitLab.Mock/Clients/PipelineClient.cs index 97c028c6..51addb8d 100644 --- a/NGitLab.Mock/Clients/PipelineClient.cs +++ b/NGitLab.Mock/Clients/PipelineClient.cs @@ -14,11 +14,11 @@ internal sealed class PipelineClient : ClientBase, IPipelineClient private readonly int _projectId; private readonly IJobClient _jobClient; - public PipelineClient(ClientContext context, IJobClient jobClient, int projectId) + public PipelineClient(ClientContext context, IJobClient jobClient, ProjectId projectId) : base(context) { _jobClient = jobClient; - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Models.Pipeline this[int id] diff --git a/NGitLab.Mock/Clients/ProjectBadgeClient.cs b/NGitLab.Mock/Clients/ProjectBadgeClient.cs index 4eb23a6a..0af90e86 100644 --- a/NGitLab.Mock/Clients/ProjectBadgeClient.cs +++ b/NGitLab.Mock/Clients/ProjectBadgeClient.cs @@ -9,10 +9,10 @@ internal sealed class ProjectBadgeClient : ClientBase, IProjectBadgeClient { private readonly int _projectId; - public ProjectBadgeClient(ClientContext context, int projectId) + public ProjectBadgeClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Models.Badge this[int id] diff --git a/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs b/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs index 7cd6da56..f02feed2 100644 --- a/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs +++ b/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs @@ -8,10 +8,10 @@ internal sealed class ProjectIssueNoteClient : ClientBase, IProjectIssueNoteClie { private readonly int _projectId; - public ProjectIssueNoteClient(ClientContext context, int projectId) + public ProjectIssueNoteClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Models.ProjectIssueNote Create(ProjectIssueNoteCreate create) diff --git a/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs b/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs index 172a027a..f71b4db4 100644 --- a/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs +++ b/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs @@ -8,10 +8,10 @@ internal sealed class ProjectLevelApprovalRulesClient : ClientBase, IProjectLeve { private readonly int _projectId; - public ProjectLevelApprovalRulesClient(ClientContext context, int projectId) + public ProjectLevelApprovalRulesClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public List GetProjectLevelApprovalRules() diff --git a/NGitLab.Mock/Clients/ProjectSearchClient.cs b/NGitLab.Mock/Clients/ProjectSearchClient.cs index 06af83f7..f3f5040f 100644 --- a/NGitLab.Mock/Clients/ProjectSearchClient.cs +++ b/NGitLab.Mock/Clients/ProjectSearchClient.cs @@ -3,15 +3,16 @@ namespace NGitLab.Mock.Clients { - internal sealed class ProjectSearchClient : ISearchClient + internal sealed class ProjectSearchClient : ClientBase, ISearchClient { private readonly ClientContext _context; private readonly int _projectId; - public ProjectSearchClient(ClientContext context, int projectId) + public ProjectSearchClient(ClientContext context, ProjectId projectId) + : base(context) { _context = context; - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public GitLabCollectionResponse GetBlobsAsync(SearchQuery query) diff --git a/NGitLab.Mock/Clients/ProjectVariableClient.cs b/NGitLab.Mock/Clients/ProjectVariableClient.cs index a911d077..079ca6a3 100644 --- a/NGitLab.Mock/Clients/ProjectVariableClient.cs +++ b/NGitLab.Mock/Clients/ProjectVariableClient.cs @@ -8,10 +8,10 @@ internal sealed class ProjectVariableClient : ClientBase, IProjectVariableClient { private readonly int _projectId; - public ProjectVariableClient(ClientContext context, int projectId) + public ProjectVariableClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Variable this[string key] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/ProtectedBranchClient.cs b/NGitLab.Mock/Clients/ProtectedBranchClient.cs index 491a9b54..0b30df59 100644 --- a/NGitLab.Mock/Clients/ProtectedBranchClient.cs +++ b/NGitLab.Mock/Clients/ProtectedBranchClient.cs @@ -8,10 +8,10 @@ internal sealed class ProtectedBranchClient : ClientBase, IProtectedBranchClient { private readonly int _projectId; - public ProtectedBranchClient(ClientContext context, int projectId) + public ProtectedBranchClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Models.ProtectedBranch GetProtectedBranch(string branchName) diff --git a/NGitLab.Mock/Clients/ReleaseClient.cs b/NGitLab.Mock/Clients/ReleaseClient.cs index 6bf6c2f5..9551ce06 100644 --- a/NGitLab.Mock/Clients/ReleaseClient.cs +++ b/NGitLab.Mock/Clients/ReleaseClient.cs @@ -13,10 +13,10 @@ internal sealed class ReleaseClient : ClientBase, IReleaseClient { private readonly int _projectId; - public ReleaseClient(ClientContext context, int projectId) + public ReleaseClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public IEnumerable All diff --git a/NGitLab.Mock/Clients/RepositoryClient.cs b/NGitLab.Mock/Clients/RepositoryClient.cs index 2d28c937..4bfe4236 100644 --- a/NGitLab.Mock/Clients/RepositoryClient.cs +++ b/NGitLab.Mock/Clients/RepositoryClient.cs @@ -11,10 +11,10 @@ internal sealed class RepositoryClient : ClientBase, IRepositoryClient { private readonly int _projectId; - public RepositoryClient(ClientContext context, int projectId) + public RepositoryClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public ITagClient Tags => new TagClient(Context, _projectId); diff --git a/NGitLab.Mock/Clients/TriggerClient.cs b/NGitLab.Mock/Clients/TriggerClient.cs index 560b686d..d9d08b6d 100644 --- a/NGitLab.Mock/Clients/TriggerClient.cs +++ b/NGitLab.Mock/Clients/TriggerClient.cs @@ -8,10 +8,10 @@ internal sealed class TriggerClient : ClientBase, ITriggerClient { private readonly int _projectId; - public TriggerClient(ClientContext context, int projectId) + public TriggerClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public Trigger this[int id] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/WikiClient.cs b/NGitLab.Mock/Clients/WikiClient.cs index 35231d0f..84d4e57d 100644 --- a/NGitLab.Mock/Clients/WikiClient.cs +++ b/NGitLab.Mock/Clients/WikiClient.cs @@ -8,10 +8,10 @@ internal sealed class WikiClient : ClientBase, IWikiClient { private readonly int _projectId; - public WikiClient(ClientContext context, int projectId) + public WikiClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = projectId; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; } public WikiPage this[string slug] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/GroupExtensions.cs b/NGitLab.Mock/GroupExtensions.cs index a7ac63fb..7045406a 100644 --- a/NGitLab.Mock/GroupExtensions.cs +++ b/NGitLab.Mock/GroupExtensions.cs @@ -1,34 +1,26 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Linq; namespace NGitLab.Mock { public static class GroupExtensions { - public static Group FindGroupById(this IEnumerable groups, int id) + public static Group FindById(this IEnumerable groups, long id) { - foreach (var group in groups) - { - if (group.Id == id) - return group; - } + return groups.FirstOrDefault(group => group.Id == id); + } - return null; + public static Group FindByNamespacedPath(this IEnumerable groups, string pathWithNamespace) + { + return groups.FirstOrDefault(group => string.Equals(group.PathWithNameSpace, pathWithNamespace, StringComparison.Ordinal)); } public static Group FindGroup(this IEnumerable groups, string idOrPathWithNamespace) { - foreach (var group in groups) - { - if (string.Equals(group.PathWithNameSpace, idOrPathWithNamespace, StringComparison.Ordinal)) - return group; - - if (string.Equals(group.Id.ToString(CultureInfo.InvariantCulture), idOrPathWithNamespace, StringComparison.Ordinal)) - return group; - } - - return null; + return long.TryParse(idOrPathWithNamespace, out var id) + ? FindById(groups, id) + : FindByNamespacedPath(groups, idOrPathWithNamespace); } } } diff --git a/NGitLab.Mock/ProjectExtensions.cs b/NGitLab.Mock/ProjectExtensions.cs index 61930219..e1e92233 100644 --- a/NGitLab.Mock/ProjectExtensions.cs +++ b/NGitLab.Mock/ProjectExtensions.cs @@ -1,37 +1,26 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Linq; namespace NGitLab.Mock { public static class ProjectExtensions { - public static Project FindProject(this IEnumerable projects, string idOrPathWithNamespace) + public static Project FindById(this IEnumerable projects, long id) { - foreach (var project in projects) - { - if (string.Equals(project.Id.ToString(CultureInfo.InvariantCulture), idOrPathWithNamespace, StringComparison.Ordinal)) - return project; - } - - foreach (var project in projects) - { - if (string.Equals(project.PathWithNamespace, idOrPathWithNamespace, StringComparison.OrdinalIgnoreCase)) - return project; - } - - return null; + return projects.FirstOrDefault(project => project.Id == id); } - public static Project FindById(this IEnumerable projects, int id) + public static Project FindByNamespacedPath(this IEnumerable projects, string pathWithNamespace) { - foreach (var project in projects) - { - if (project.Id == id) - return project; - } + return projects.FirstOrDefault(project => string.Equals(project.PathWithNamespace, pathWithNamespace, StringComparison.OrdinalIgnoreCase)); + } - return null; + public static Project FindProject(this IEnumerable projects, string idOrPathWithNamespace) + { + return long.TryParse(idOrPathWithNamespace, out var id) + ? FindById(projects, id) + : FindByNamespacedPath(projects, idOrPathWithNamespace); } } } diff --git a/NGitLab.Mock/PublicAPI.Unshipped.txt b/NGitLab.Mock/PublicAPI.Unshipped.txt index 2aa6ffc9..159a3e56 100644 --- a/NGitLab.Mock/PublicAPI.Unshipped.txt +++ b/NGitLab.Mock/PublicAPI.Unshipped.txt @@ -1263,9 +1263,11 @@ static NGitLab.Mock.Config.GitLabHelpers.WithProject(this NGitLab.Mock.Config.Gi static NGitLab.Mock.Config.GitLabHelpers.WithTag(this NGitLab.Mock.Config.GitLabCommit commit, string name) -> NGitLab.Mock.Config.GitLabCommit static NGitLab.Mock.Config.GitLabHelpers.WithUser(this NGitLab.Mock.Config.GitLabConfig config, string username, System.Action configure) -> NGitLab.Mock.Config.GitLabConfig static NGitLab.Mock.GitLabClientMockExtensions.WithGraphQLClient(this NGitLab.IGitLabClient client, NGitLab.IGraphQLClient graphQLClient) -> NGitLab.IGitLabClient +static NGitLab.Mock.GroupExtensions.FindById(this System.Collections.Generic.IEnumerable groups, long id) -> NGitLab.Mock.Group +static NGitLab.Mock.GroupExtensions.FindByNamespacedPath(this System.Collections.Generic.IEnumerable groups, string pathWithNamespace) -> NGitLab.Mock.Group static NGitLab.Mock.GroupExtensions.FindGroup(this System.Collections.Generic.IEnumerable groups, string idOrPathWithNamespace) -> NGitLab.Mock.Group -static NGitLab.Mock.GroupExtensions.FindGroupById(this System.Collections.Generic.IEnumerable groups, int id) -> NGitLab.Mock.Group -static NGitLab.Mock.ProjectExtensions.FindById(this System.Collections.Generic.IEnumerable projects, int id) -> NGitLab.Mock.Project +static NGitLab.Mock.ProjectExtensions.FindById(this System.Collections.Generic.IEnumerable projects, long id) -> NGitLab.Mock.Project +static NGitLab.Mock.ProjectExtensions.FindByNamespacedPath(this System.Collections.Generic.IEnumerable projects, string pathWithNamespace) -> NGitLab.Mock.Project static NGitLab.Mock.ProjectExtensions.FindProject(this System.Collections.Generic.IEnumerable projects, string idOrPathWithNamespace) -> NGitLab.Mock.Project static NGitLab.Mock.StringExtensions.Contains(this string source, string toCheck, System.StringComparison comparison) -> bool static NGitLab.Mock.TemporaryDirectory.Create() -> NGitLab.Mock.TemporaryDirectory diff --git a/NGitLab/GitLabClient.cs b/NGitLab/GitLabClient.cs index 9bb61b5e..8105ccfa 100644 --- a/NGitLab/GitLabClient.cs +++ b/NGitLab/GitLabClient.cs @@ -1,6 +1,7 @@ using System; using NGitLab.Extensions; using NGitLab.Impl; +using NGitLab.Models; namespace NGitLab { @@ -95,133 +96,154 @@ private GitLabClient(GitLabCredentials credentials, RequestOptions options) [Obsolete("Use GitLabClient constructor instead")] public static GitLabClient Connect(string hostUrl, string apiToken) - { - return new GitLabClient(hostUrl, apiToken); - } + => new(hostUrl, apiToken); [Obsolete("Use GitLabClient constructor instead")] public static GitLabClient Connect(string hostUrl, string username, string password) - { - return new GitLabClient(hostUrl, username, password); - } + => new(hostUrl, username, password); public IEventClient GetEvents() - { - return new EventClient(_api, "events"); - } + => new EventClient(_api, "events"); public IEventClient GetUserEvents(int userId) - { - return new EventClient(_api, $"users/{userId.ToStringInvariant()}/events"); - } + => new EventClient(_api, $"users/{userId.ToStringInvariant()}/events"); public IEventClient GetProjectEvents(int projectId) - { - return new EventClient(_api, $"projects/{projectId.ToStringInvariant()}/events"); - } + => GetProjectEvents((long)projectId); + + public IEventClient GetProjectEvents(ProjectId projectId) + => new EventClient(_api, $"projects/{projectId.ValueAsUriParameter}/events"); public IRepositoryClient GetRepository(int projectId) - { - return new RepositoryClient(_api, projectId); - } + => GetRepository((long)projectId); + + public IRepositoryClient GetRepository(ProjectId projectId) + => new RepositoryClient(_api, projectId); public ICommitClient GetCommits(int projectId) - { - return new CommitClient(_api, projectId); - } + => GetCommits((long)projectId); + + public ICommitClient GetCommits(ProjectId projectId) + => new CommitClient(_api, projectId); public ICommitStatusClient GetCommitStatus(int projectId) - { - return new CommitStatusClient(_api, projectId); - } + => GetCommitStatus((long)projectId); + + public ICommitStatusClient GetCommitStatus(ProjectId projectId) + => new CommitStatusClient(_api, projectId); public IPipelineClient GetPipelines(int projectId) - { - return new PipelineClient(_api, projectId); - } + => GetPipelines((long)projectId); + + public IPipelineClient GetPipelines(ProjectId projectId) + => new PipelineClient(_api, projectId); public ITriggerClient GetTriggers(int projectId) - { - return new TriggerClient(_api, projectId); - } + => GetTriggers((long)projectId); + + public ITriggerClient GetTriggers(ProjectId projectId) + => new TriggerClient(_api, projectId); public IJobClient GetJobs(int projectId) - { - return new JobClient(_api, projectId); - } + => GetJobs((long)projectId); + + public IJobClient GetJobs(ProjectId projectId) + => new JobClient(_api, projectId); public IMergeRequestClient GetMergeRequest(int projectId) - { - return new MergeRequestClient(_api, projectId); - } + => GetMergeRequest((long)projectId); + + public IMergeRequestClient GetMergeRequest(ProjectId projectId) + => new MergeRequestClient(_api, projectId); public IMilestoneClient GetMilestone(int projectId) - { - return new MilestoneClient(_api, MilestoneScope.Projects, projectId); - } + => GetMilestone((long)projectId); + + public IMilestoneClient GetMilestone(ProjectId projectId) + => new MilestoneClient(_api, MilestoneScope.Projects, projectId); public IMilestoneClient GetGroupMilestone(int groupId) - { - return new MilestoneClient(_api, MilestoneScope.Groups, groupId); - } + => GetGroupMilestone((long)groupId); + + public IMilestoneClient GetGroupMilestone(GroupId groupId) + => new MilestoneClient(_api, MilestoneScope.Groups, groupId); public IReleaseClient GetReleases(int projectId) - { - return new ReleaseClient(_api, projectId); - } + => GetReleases((long)projectId); + + public IReleaseClient GetReleases(ProjectId projectId) + => new ReleaseClient(_api, projectId); public IProjectIssueNoteClient GetProjectIssueNoteClient(int projectId) - { - return new ProjectIssueNoteClient(_api, projectId); - } + => GetProjectIssueNoteClient((long)projectId); + + public IProjectIssueNoteClient GetProjectIssueNoteClient(ProjectId projectId) + => new ProjectIssueNoteClient(_api, projectId); public IEnvironmentClient GetEnvironmentClient(int projectId) - { - return new EnvironmentClient(_api, projectId); - } + => GetEnvironmentClient((long)projectId); + + public IEnvironmentClient GetEnvironmentClient(ProjectId projectId) + => new EnvironmentClient(_api, projectId); public IClusterClient GetClusterClient(int projectId) - { - return new ClusterClient(_api, projectId); - } + => GetClusterClient((long)projectId); + + public IClusterClient GetClusterClient(ProjectId projectId) + => new ClusterClient(_api, projectId); public IWikiClient GetWikiClient(int projectId) - { - return new WikiClient(_api, projectId); - } + => GetWikiClient((long)projectId); + + public IWikiClient GetWikiClient(ProjectId projectId) + => new WikiClient(_api, projectId); public IProjectBadgeClient GetProjectBadgeClient(int projectId) - { - return new ProjectBadgeClient(_api, projectId); - } + => GetProjectBadgeClient((long)projectId); + + public IProjectBadgeClient GetProjectBadgeClient(ProjectId projectId) + => new ProjectBadgeClient(_api, projectId); public IGroupBadgeClient GetGroupBadgeClient(int groupId) - { - return new GroupBadgeClient(_api, groupId); - } + => GetGroupBadgeClient((long)groupId); + + public IGroupBadgeClient GetGroupBadgeClient(GroupId groupId) + => new GroupBadgeClient(_api, groupId); public IProjectVariableClient GetProjectVariableClient(int projectId) - { - return new ProjectVariableClient(_api, projectId); - } + => GetProjectVariableClient((long)projectId); + + public IProjectVariableClient GetProjectVariableClient(ProjectId projectId) + => new ProjectVariableClient(_api, projectId); public IGroupVariableClient GetGroupVariableClient(int groupId) - { - return new GroupVariableClient(_api, groupId); - } + => GetGroupVariableClient((long)groupId); + + public IGroupVariableClient GetGroupVariableClient(GroupId groupId) + => new GroupVariableClient(_api, groupId); public IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(int projectId) - { - return new ProjectLevelApprovalRulesClient(_api, projectId); - } + => GetProjectLevelApprovalRulesClient((long)projectId); + + public IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(ProjectId projectId) + => new ProjectLevelApprovalRulesClient(_api, projectId); public IProtectedBranchClient GetProtectedBranchClient(int projectId) + => GetProtectedBranchClient((long)projectId); + + public IProtectedBranchClient GetProtectedBranchClient(ProjectId projectId) => new ProtectedBranchClient(_api, projectId); public ISearchClient GetGroupSearchClient(int groupId) - => new SearchClient(_api, $"/groups/{groupId.ToStringInvariant()}/search"); + => GetGroupSearchClient((long)groupId); + + public ISearchClient GetGroupSearchClient(GroupId groupId) + => new SearchClient(_api, $"/groups/{groupId.ValueAsUriParameter}/search"); public ISearchClient GetProjectSearchClient(int projectId) - => new SearchClient(_api, $"/projects/{projectId.ToStringInvariant()}/search"); + => GetProjectSearchClient((long)projectId); + + public ISearchClient GetProjectSearchClient(ProjectId projectId) + => new SearchClient(_api, $"/projects/{projectId.ValueAsUriParameter}/search"); } } diff --git a/NGitLab/IGitLabClient.cs b/NGitLab/IGitLabClient.cs index fd60a0da..abdfd87c 100644 --- a/NGitLab/IGitLabClient.cs +++ b/NGitLab/IGitLabClient.cs @@ -1,4 +1,7 @@ -namespace NGitLab +using System; +using NGitLab.Models; + +namespace NGitLab { public interface IGitLabClient { @@ -33,29 +36,64 @@ public interface IGitLabClient /// /// Returns the events that occurred in the specified project. /// - /// + [Obsolete("Use long or namespaced path string as projectId instead.")] IEventClient GetProjectEvents(int projectId); + /// + /// Returns the events that occurred in the specified project. + /// + IEventClient GetProjectEvents(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IRepositoryClient GetRepository(int projectId); + IRepositoryClient GetRepository(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] ICommitClient GetCommits(int projectId); + ICommitClient GetCommits(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] ICommitStatusClient GetCommitStatus(int projectId); + ICommitStatusClient GetCommitStatus(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IPipelineClient GetPipelines(int projectId); + IPipelineClient GetPipelines(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] ITriggerClient GetTriggers(int projectId); + ITriggerClient GetTriggers(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IJobClient GetJobs(int projectId); + IJobClient GetJobs(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IMergeRequestClient GetMergeRequest(int projectId); + IMergeRequestClient GetMergeRequest(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IMilestoneClient GetMilestone(int projectId); + IMilestoneClient GetMilestone(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as groupId instead.")] IMilestoneClient GetGroupMilestone(int groupId); + IMilestoneClient GetGroupMilestone(GroupId groupId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IReleaseClient GetReleases(int projectId); + IReleaseClient GetReleases(ProjectId projectId); + IMembersClient Members { get; } IVersionClient Version { get; } @@ -74,28 +112,64 @@ public interface IGitLabClient ISearchClient AdvancedSearch { get; } + [Obsolete("Use long or namespaced path string as projectId instead.")] IProjectIssueNoteClient GetProjectIssueNoteClient(int projectId); + IProjectIssueNoteClient GetProjectIssueNoteClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IEnvironmentClient GetEnvironmentClient(int projectId); + IEnvironmentClient GetEnvironmentClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IClusterClient GetClusterClient(int projectId); + IClusterClient GetClusterClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IWikiClient GetWikiClient(int projectId); + IWikiClient GetWikiClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IProjectBadgeClient GetProjectBadgeClient(int projectId); + IProjectBadgeClient GetProjectBadgeClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as groupId instead.")] IGroupBadgeClient GetGroupBadgeClient(int groupId); + IGroupBadgeClient GetGroupBadgeClient(GroupId groupId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IProjectVariableClient GetProjectVariableClient(int projectId); + IProjectVariableClient GetProjectVariableClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as groupId instead.")] IGroupVariableClient GetGroupVariableClient(int groupId); + IGroupVariableClient GetGroupVariableClient(GroupId groupId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(int projectId); + IProjectLevelApprovalRulesClient GetProjectLevelApprovalRulesClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] IProtectedBranchClient GetProtectedBranchClient(int projectId); + IProtectedBranchClient GetProtectedBranchClient(ProjectId projectId); + + [Obsolete("Use long or namespaced path string as groupId instead.")] public ISearchClient GetGroupSearchClient(int groupId); + public ISearchClient GetGroupSearchClient(GroupId groupId); + + [Obsolete("Use long or namespaced path string as projectId instead.")] public ISearchClient GetProjectSearchClient(int projectId); + + public ISearchClient GetProjectSearchClient(ProjectId projectId); } } diff --git a/NGitLab/Impl/ClusterClient.cs b/NGitLab/Impl/ClusterClient.cs index 641a2b33..a25bf858 100644 --- a/NGitLab/Impl/ClusterClient.cs +++ b/NGitLab/Impl/ClusterClient.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using NGitLab.Extensions; +using System; +using System.Collections.Generic; using NGitLab.Models; namespace NGitLab.Impl @@ -9,10 +9,16 @@ public class ClusterClient : IClusterClient private readonly API _api; private readonly string _environmentsPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public ClusterClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public ClusterClient(API api, ProjectId projectId) { _api = api; - _environmentsPath = $"{Project.Url}/{projectId.ToStringInvariant()}/clusters"; + _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/clusters"; } public IEnumerable All => _api.Get().GetAll(_environmentsPath); diff --git a/NGitLab/Impl/CommitClient.cs b/NGitLab/Impl/CommitClient.cs index f6ece503..045422ea 100644 --- a/NGitLab/Impl/CommitClient.cs +++ b/NGitLab/Impl/CommitClient.cs @@ -1,6 +1,5 @@ using System; using System.Net; -using NGitLab.Extensions; using NGitLab.Models; namespace NGitLab.Impl @@ -10,12 +9,17 @@ public class CommitClient : ICommitClient private readonly API _api; private readonly string _repoPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public CommitClient(API api, int projectId) + : this(api, (long)projectId) { - _api = api; + } - var projectPath = Project.Url + "/" + projectId.ToStringInvariant(); - _repoPath = projectPath + "/repository"; + public CommitClient(API api, ProjectId projectId) + { + _api = api; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _repoPath = $"{projectPath}/repository"; } public Commit GetCommit(string @ref) diff --git a/NGitLab/Impl/CommitStatusClient.cs b/NGitLab/Impl/CommitStatusClient.cs index 5b33b111..bb5eed28 100644 --- a/NGitLab/Impl/CommitStatusClient.cs +++ b/NGitLab/Impl/CommitStatusClient.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using NGitLab.Extensions; +using System; +using System.Collections.Generic; using NGitLab.Models; namespace NGitLab.Impl @@ -10,13 +10,19 @@ public class CommitStatusClient : ICommitStatusClient private readonly string _statusCreatePath; private readonly string _statusPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public CommitStatusClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public CommitStatusClient(API api, ProjectId projectId) { _api = api; - var projectPath = Project.Url + "/" + projectId.ToStringInvariant(); - _statusCreatePath = projectPath + "/statuses"; - _statusPath = projectPath + "/repository/commits"; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _statusCreatePath = $"{projectPath}/statuses"; + _statusPath = $"{projectPath}/repository/commits"; } public IEnumerable AllBySha(string commitSha) => _api.Get().GetAll($"{_statusPath}/{commitSha}/statuses"); diff --git a/NGitLab/Impl/EnvironmentClient.cs b/NGitLab/Impl/EnvironmentClient.cs index 02ebe797..957813fb 100644 --- a/NGitLab/Impl/EnvironmentClient.cs +++ b/NGitLab/Impl/EnvironmentClient.cs @@ -12,10 +12,16 @@ public class EnvironmentClient : IEnvironmentClient private readonly API _api; private readonly string _environmentsPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public EnvironmentClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public EnvironmentClient(API api, ProjectId projectId) { _api = api; - _environmentsPath = $"{Project.Url}/{projectId.ToStringInvariant()}/environments"; + _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/environments"; } public IEnumerable All => _api.Get().GetAll(_environmentsPath); diff --git a/NGitLab/Impl/GroupBadgeClient.cs b/NGitLab/Impl/GroupBadgeClient.cs index 0fad6140..6d186550 100644 --- a/NGitLab/Impl/GroupBadgeClient.cs +++ b/NGitLab/Impl/GroupBadgeClient.cs @@ -1,12 +1,11 @@ -using NGitLab.Extensions; -using NGitLab.Models; +using NGitLab.Models; namespace NGitLab.Impl { internal sealed class GroupBadgeClient : BadgeClient, IGroupBadgeClient { - public GroupBadgeClient(API api, int projectId) - : base(api, Group.Url + "/" + projectId.ToStringInvariant()) + public GroupBadgeClient(API api, GroupId groupId) + : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter}") { } } diff --git a/NGitLab/Impl/GroupVariableClient.cs b/NGitLab/Impl/GroupVariableClient.cs index 4e1ac2cb..7837c7ce 100644 --- a/NGitLab/Impl/GroupVariableClient.cs +++ b/NGitLab/Impl/GroupVariableClient.cs @@ -1,12 +1,11 @@ -using NGitLab.Extensions; -using NGitLab.Models; +using NGitLab.Models; namespace NGitLab.Impl { internal sealed class GroupVariableClient : VariableClient, IGroupVariableClient { - public GroupVariableClient(API api, int groupId) - : base(api, Group.Url + $"/{groupId.ToStringInvariant()}") + public GroupVariableClient(API api, GroupId groupId) + : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter}") { } } diff --git a/NGitLab/Impl/JobClient.cs b/NGitLab/Impl/JobClient.cs index 334eb784..c41bfbeb 100644 --- a/NGitLab/Impl/JobClient.cs +++ b/NGitLab/Impl/JobClient.cs @@ -13,10 +13,16 @@ public class JobClient : IJobClient private readonly API _api; private readonly string _jobsPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public JobClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public JobClient(API api, ProjectId projectId) { _api = api; - _jobsPath = $"{Project.Url}/{projectId.ToStringInvariant()}/jobs"; + _jobsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/jobs"; } public IEnumerable GetJobs(JobScopeMask scope) diff --git a/NGitLab/Impl/MergeRequestClient.cs b/NGitLab/Impl/MergeRequestClient.cs index 01f9ee25..59b7bcdf 100644 --- a/NGitLab/Impl/MergeRequestClient.cs +++ b/NGitLab/Impl/MergeRequestClient.cs @@ -16,10 +16,16 @@ public class MergeRequestClient : IMergeRequestClient private readonly string _projectPath; private readonly API _api; + [Obsolete("Use long or namespaced path string as projectId instead.")] public MergeRequestClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public MergeRequestClient(API api, ProjectId projectId) { _api = api; - _projectPath = Project.Url + "/" + projectId.ToStringInvariant(); + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; } public MergeRequestClient(API api) diff --git a/NGitLab/Impl/MilestoneClient.cs b/NGitLab/Impl/MilestoneClient.cs index 5e0c00e6..fb4daf38 100644 --- a/NGitLab/Impl/MilestoneClient.cs +++ b/NGitLab/Impl/MilestoneClient.cs @@ -12,10 +12,16 @@ public class MilestoneClient : IMilestoneClient private readonly API _api; private readonly string _milestonePath; + [Obsolete("Use long or namespaced path string as id instead.")] internal MilestoneClient(API api, MilestoneScope scope, int id) + : this(api, scope, (long)id) + { + } + + internal MilestoneClient(API api, MilestoneScope scope, IdOrNamespacedPath projectId) { _api = api; - _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ToStringInvariant()}/milestones"; + _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{projectId.ValueAsUriParameter}/milestones"; Scope = scope; } diff --git a/NGitLab/Impl/PipelineClient.cs b/NGitLab/Impl/PipelineClient.cs index 6f9305ac..d5a02628 100644 --- a/NGitLab/Impl/PipelineClient.cs +++ b/NGitLab/Impl/PipelineClient.cs @@ -15,11 +15,17 @@ public class PipelineClient : IPipelineClient private readonly string _projectPath; private readonly string _pipelinesPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public PipelineClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public PipelineClient(API api, ProjectId projectId) { _api = api; - _projectPath = $"{Project.Url}/{projectId.ToStringInvariant()}"; - _pipelinesPath = $"{Project.Url}/{projectId.ToStringInvariant()}/pipelines"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _pipelinesPath = $"{_projectPath}/pipelines"; } public IEnumerable All => _api.Get().GetAll(_pipelinesPath); diff --git a/NGitLab/Impl/ProjectBadgeClient.cs b/NGitLab/Impl/ProjectBadgeClient.cs index 2104b309..06dfa0fa 100644 --- a/NGitLab/Impl/ProjectBadgeClient.cs +++ b/NGitLab/Impl/ProjectBadgeClient.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using System.Linq; -using NGitLab.Extensions; using NGitLab.Models; namespace NGitLab.Impl { internal sealed class ProjectBadgeClient : BadgeClient, IProjectBadgeClient { - public ProjectBadgeClient(API api, int projectId) - : base(api, Project.Url + $"/{projectId.ToStringInvariant()}") + public ProjectBadgeClient(API api, ProjectId projectId) + : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter}") { } diff --git a/NGitLab/Impl/ProjectIssueNoteClient.cs b/NGitLab/Impl/ProjectIssueNoteClient.cs index be938958..f533dcd4 100644 --- a/NGitLab/Impl/ProjectIssueNoteClient.cs +++ b/NGitLab/Impl/ProjectIssueNoteClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using NGitLab.Models; namespace NGitLab.Impl @@ -9,12 +10,18 @@ public class ProjectIssueNoteClient : IProjectIssueNoteClient private const string SingleNoteIssueUrl = "/projects/{0}/issues/{1}/notes/{2}"; private readonly API _api; - private readonly int _projectId; + private readonly string _projectId; + [Obsolete("Use long or namespaced path string as projectId instead.")] public ProjectIssueNoteClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public ProjectIssueNoteClient(API api, ProjectId projectId) { _api = api; - _projectId = projectId; + _projectId = projectId.ValueAsUriParameter; } public IEnumerable ForIssue(int issueId) diff --git a/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs b/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs index cc2379b3..f4e01404 100644 --- a/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs +++ b/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using NGitLab.Extensions; using NGitLab.Models; @@ -9,10 +10,16 @@ public class ProjectLevelApprovalRulesClient : IProjectLevelApprovalRulesClient private readonly API _api; private readonly string _approvalRulesUrl; + [Obsolete("Use long or namespaced path string as projectId instead.")] public ProjectLevelApprovalRulesClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public ProjectLevelApprovalRulesClient(API api, ProjectId projectId) { _api = api; - _approvalRulesUrl = $"{Project.Url}/{projectId.ToStringInvariant()}/approval_rules"; + _approvalRulesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter}/approval_rules"; } public List GetProjectLevelApprovalRules() diff --git a/NGitLab/Impl/ProjectVariableClient.cs b/NGitLab/Impl/ProjectVariableClient.cs index 882b705f..cb9c9c28 100644 --- a/NGitLab/Impl/ProjectVariableClient.cs +++ b/NGitLab/Impl/ProjectVariableClient.cs @@ -1,12 +1,11 @@ -using NGitLab.Extensions; -using NGitLab.Models; +using NGitLab.Models; namespace NGitLab.Impl { internal sealed class ProjectVariableClient : VariableClient, IProjectVariableClient { - public ProjectVariableClient(API api, int projectId) - : base(api, Project.Url + $"/{projectId.ToStringInvariant()}") + public ProjectVariableClient(API api, ProjectId projectId) + : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter}") { } } diff --git a/NGitLab/Impl/ProtectedBranchClient.cs b/NGitLab/Impl/ProtectedBranchClient.cs index 2cf1ffb8..6951cdac 100644 --- a/NGitLab/Impl/ProtectedBranchClient.cs +++ b/NGitLab/Impl/ProtectedBranchClient.cs @@ -9,10 +9,10 @@ internal sealed class ProtectedBranchClient : IProtectedBranchClient private readonly API _api; private readonly string _protectedBranchesUrl; - public ProtectedBranchClient(API api, int projectId) + public ProtectedBranchClient(API api, ProjectId projectId) { _api = api; - _protectedBranchesUrl = $"{Project.Url}/{projectId.ToStringInvariant()}/protected_branches"; + _protectedBranchesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter}/protected_branches"; } public ProtectedBranch ProtectBranch(BranchProtect branchProtect) diff --git a/NGitLab/Impl/ReleaseClient.cs b/NGitLab/Impl/ReleaseClient.cs index 09c96bba..ecee8f39 100644 --- a/NGitLab/Impl/ReleaseClient.cs +++ b/NGitLab/Impl/ReleaseClient.cs @@ -14,11 +14,11 @@ internal sealed class ReleaseClient : IReleaseClient private readonly API _api; private readonly string _releasesPath; - public ReleaseClient(API api, int projectId) + public ReleaseClient(API api, ProjectId projectId) { _api = api; - var projectPath = Project.Url + "/" + projectId.ToStringInvariant(); - _releasesPath = projectPath + "/releases"; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _releasesPath = $"{projectPath}/releases"; } public IEnumerable All => _api.Get().GetAll(_releasesPath); diff --git a/NGitLab/Impl/RepositoryClient.cs b/NGitLab/Impl/RepositoryClient.cs index 126a65ca..1a841e39 100644 --- a/NGitLab/Impl/RepositoryClient.cs +++ b/NGitLab/Impl/RepositoryClient.cs @@ -14,11 +14,17 @@ public class RepositoryClient : IRepositoryClient private readonly string _repoPath; private readonly string _projectPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public RepositoryClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public RepositoryClient(API api, ProjectId projectId) { _api = api; - _projectPath = Project.Url + "/" + projectId.ToStringInvariant(); - _repoPath = _projectPath + "/repository"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _repoPath = $"{_projectPath}/repository"; } public ITagClient Tags => new TagClient(_api, _repoPath); diff --git a/NGitLab/Impl/TriggerClient.cs b/NGitLab/Impl/TriggerClient.cs index e808389b..b17323e0 100644 --- a/NGitLab/Impl/TriggerClient.cs +++ b/NGitLab/Impl/TriggerClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using NGitLab.Extensions; using NGitLab.Models; @@ -9,10 +10,16 @@ public class TriggerClient : ITriggerClient private readonly API _api; private readonly string _triggersPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public TriggerClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public TriggerClient(API api, ProjectId projectId) { _api = api; - _triggersPath = $"{Project.Url}/{projectId.ToStringInvariant()}/triggers"; + _triggersPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/triggers"; } public Trigger this[int id] => _api.Get().To(_triggersPath + "/" + id.ToStringInvariant()); diff --git a/NGitLab/Impl/WikiClient.cs b/NGitLab/Impl/WikiClient.cs index c603d87a..c85062d4 100644 --- a/NGitLab/Impl/WikiClient.cs +++ b/NGitLab/Impl/WikiClient.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Net; -using NGitLab.Extensions; using NGitLab.Models; namespace NGitLab.Impl @@ -11,10 +10,16 @@ public class WikiClient : IWikiClient private readonly API _api; private readonly string _projectPath; + [Obsolete("Use long or namespaced path string as projectId instead.")] public WikiClient(API api, int projectId) + : this(api, (long)projectId) + { + } + + public WikiClient(API api, ProjectId projectId) { _api = api; - _projectPath = Project.Url + "/" + projectId.ToStringInvariant(); + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; } public IEnumerable All => _api.Get().GetAll(_projectPath + "/wikis"); diff --git a/NGitLab/Models/GroupId.cs b/NGitLab/Models/GroupId.cs new file mode 100644 index 00000000..3a869067 --- /dev/null +++ b/NGitLab/Models/GroupId.cs @@ -0,0 +1,26 @@ +namespace NGitLab.Models +{ + public record GroupId : IdOrNamespacedPath + { + public GroupId(long id) + : base(id) + { + } + + public GroupId(string path) + : base(path) + { + } + + public GroupId(Group group) + : base(group.Id) + { + } + + public static implicit operator GroupId(long id) => new(id); + + public static implicit operator GroupId(string path) => new(path); + + public static implicit operator GroupId(Group group) => new(group); + } +} diff --git a/NGitLab/Models/IdOrNamespacedPath.cs b/NGitLab/Models/IdOrNamespacedPath.cs new file mode 100644 index 00000000..e115a816 --- /dev/null +++ b/NGitLab/Models/IdOrNamespacedPath.cs @@ -0,0 +1,25 @@ +using System; +using NGitLab.Extensions; + +namespace NGitLab.Models +{ + public record IdOrNamespacedPath + { + private readonly long _id; + private readonly string _path; + + public IdOrNamespacedPath(long id) => _id = id; + + public IdOrNamespacedPath(string path) => _path = path ?? throw new ArgumentNullException(nameof(path)); + + public static implicit operator IdOrNamespacedPath(long id) => new(id); + + public static implicit operator IdOrNamespacedPath(string path) => new(path); + + internal string ValueAsString => _path ?? _id.ToStringInvariant(); + + internal string ValueAsUriParameter => _path is null ? _id.ToStringInvariant() : Uri.EscapeDataString(_path); + + public override string ToString() => ValueAsString; + } +} diff --git a/NGitLab/Models/ProjectId.cs b/NGitLab/Models/ProjectId.cs new file mode 100644 index 00000000..65d60510 --- /dev/null +++ b/NGitLab/Models/ProjectId.cs @@ -0,0 +1,26 @@ +namespace NGitLab.Models +{ + public record ProjectId : IdOrNamespacedPath + { + public ProjectId(long id) + : base(id) + { + } + + public ProjectId(string path) + : base(path) + { + } + + public ProjectId(Project project) + : base(project.Id) + { + } + + public static implicit operator ProjectId(long id) => new(id); + + public static implicit operator ProjectId(string path) => new(path); + + public static implicit operator ProjectId(Project project) => new(project); + } +} diff --git a/NGitLab/PublicAPI.Unshipped.txt b/NGitLab/PublicAPI.Unshipped.txt index c209dfac..edeaf7f2 100644 --- a/NGitLab/PublicAPI.Unshipped.txt +++ b/NGitLab/PublicAPI.Unshipped.txt @@ -44,30 +44,53 @@ NGitLab.GitLabClient.AdvancedSearch.get -> NGitLab.ISearchClient NGitLab.GitLabClient.Deployments.get -> NGitLab.IDeploymentClient NGitLab.GitLabClient.Epics.get -> NGitLab.IEpicClient NGitLab.GitLabClient.GetClusterClient(int projectId) -> NGitLab.IClusterClient +NGitLab.GitLabClient.GetClusterClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IClusterClient NGitLab.GitLabClient.GetCommits(int projectId) -> NGitLab.ICommitClient +NGitLab.GitLabClient.GetCommits(NGitLab.Models.ProjectId projectId) -> NGitLab.ICommitClient NGitLab.GitLabClient.GetCommitStatus(int projectId) -> NGitLab.ICommitStatusClient +NGitLab.GitLabClient.GetCommitStatus(NGitLab.Models.ProjectId projectId) -> NGitLab.ICommitStatusClient NGitLab.GitLabClient.GetEnvironmentClient(int projectId) -> NGitLab.IEnvironmentClient +NGitLab.GitLabClient.GetEnvironmentClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IEnvironmentClient NGitLab.GitLabClient.GetEvents() -> NGitLab.IEventClient NGitLab.GitLabClient.GetGroupBadgeClient(int groupId) -> NGitLab.IGroupBadgeClient +NGitLab.GitLabClient.GetGroupBadgeClient(NGitLab.Models.GroupId groupId) -> NGitLab.IGroupBadgeClient NGitLab.GitLabClient.GetGroupMilestone(int groupId) -> NGitLab.IMilestoneClient +NGitLab.GitLabClient.GetGroupMilestone(NGitLab.Models.GroupId groupId) -> NGitLab.IMilestoneClient NGitLab.GitLabClient.GetGroupSearchClient(int groupId) -> NGitLab.ISearchClient +NGitLab.GitLabClient.GetGroupSearchClient(NGitLab.Models.GroupId groupId) -> NGitLab.ISearchClient NGitLab.GitLabClient.GetGroupVariableClient(int groupId) -> NGitLab.IGroupVariableClient +NGitLab.GitLabClient.GetGroupVariableClient(NGitLab.Models.GroupId groupId) -> NGitLab.IGroupVariableClient NGitLab.GitLabClient.GetJobs(int projectId) -> NGitLab.IJobClient +NGitLab.GitLabClient.GetJobs(NGitLab.Models.ProjectId projectId) -> NGitLab.IJobClient NGitLab.GitLabClient.GetMergeRequest(int projectId) -> NGitLab.IMergeRequestClient +NGitLab.GitLabClient.GetMergeRequest(NGitLab.Models.ProjectId projectId) -> NGitLab.IMergeRequestClient NGitLab.GitLabClient.GetMilestone(int projectId) -> NGitLab.IMilestoneClient +NGitLab.GitLabClient.GetMilestone(NGitLab.Models.ProjectId projectId) -> NGitLab.IMilestoneClient NGitLab.GitLabClient.GetPipelines(int projectId) -> NGitLab.IPipelineClient +NGitLab.GitLabClient.GetPipelines(NGitLab.Models.ProjectId projectId) -> NGitLab.IPipelineClient NGitLab.GitLabClient.GetProjectBadgeClient(int projectId) -> NGitLab.IProjectBadgeClient +NGitLab.GitLabClient.GetProjectBadgeClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectBadgeClient NGitLab.GitLabClient.GetProjectEvents(int projectId) -> NGitLab.IEventClient +NGitLab.GitLabClient.GetProjectEvents(NGitLab.Models.ProjectId projectId) -> NGitLab.IEventClient NGitLab.GitLabClient.GetProjectIssueNoteClient(int projectId) -> NGitLab.IProjectIssueNoteClient +NGitLab.GitLabClient.GetProjectIssueNoteClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectIssueNoteClient NGitLab.GitLabClient.GetProjectLevelApprovalRulesClient(int projectId) -> NGitLab.IProjectLevelApprovalRulesClient +NGitLab.GitLabClient.GetProjectLevelApprovalRulesClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectLevelApprovalRulesClient NGitLab.GitLabClient.GetProjectSearchClient(int projectId) -> NGitLab.ISearchClient +NGitLab.GitLabClient.GetProjectSearchClient(NGitLab.Models.ProjectId projectId) -> NGitLab.ISearchClient NGitLab.GitLabClient.GetProjectVariableClient(int projectId) -> NGitLab.IProjectVariableClient +NGitLab.GitLabClient.GetProjectVariableClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectVariableClient NGitLab.GitLabClient.GetProtectedBranchClient(int projectId) -> NGitLab.IProtectedBranchClient +NGitLab.GitLabClient.GetProtectedBranchClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProtectedBranchClient NGitLab.GitLabClient.GetReleases(int projectId) -> NGitLab.IReleaseClient +NGitLab.GitLabClient.GetReleases(NGitLab.Models.ProjectId projectId) -> NGitLab.IReleaseClient NGitLab.GitLabClient.GetRepository(int projectId) -> NGitLab.IRepositoryClient +NGitLab.GitLabClient.GetRepository(NGitLab.Models.ProjectId projectId) -> NGitLab.IRepositoryClient NGitLab.GitLabClient.GetTriggers(int projectId) -> NGitLab.ITriggerClient +NGitLab.GitLabClient.GetTriggers(NGitLab.Models.ProjectId projectId) -> NGitLab.ITriggerClient NGitLab.GitLabClient.GetUserEvents(int userId) -> NGitLab.IEventClient NGitLab.GitLabClient.GetWikiClient(int projectId) -> NGitLab.IWikiClient +NGitLab.GitLabClient.GetWikiClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IWikiClient NGitLab.GitLabClient.GitLabClient(string hostUrl, string apiToken) -> void NGitLab.GitLabClient.GitLabClient(string hostUrl, string apiToken, NGitLab.RequestOptions options) -> void NGitLab.GitLabClient.GitLabClient(string hostUrl, string userName, string password) -> void @@ -161,30 +184,53 @@ NGitLab.IGitLabClient.AdvancedSearch.get -> NGitLab.ISearchClient NGitLab.IGitLabClient.Deployments.get -> NGitLab.IDeploymentClient NGitLab.IGitLabClient.Epics.get -> NGitLab.IEpicClient NGitLab.IGitLabClient.GetClusterClient(int projectId) -> NGitLab.IClusterClient +NGitLab.IGitLabClient.GetClusterClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IClusterClient NGitLab.IGitLabClient.GetCommits(int projectId) -> NGitLab.ICommitClient +NGitLab.IGitLabClient.GetCommits(NGitLab.Models.ProjectId projectId) -> NGitLab.ICommitClient NGitLab.IGitLabClient.GetCommitStatus(int projectId) -> NGitLab.ICommitStatusClient +NGitLab.IGitLabClient.GetCommitStatus(NGitLab.Models.ProjectId projectId) -> NGitLab.ICommitStatusClient NGitLab.IGitLabClient.GetEnvironmentClient(int projectId) -> NGitLab.IEnvironmentClient +NGitLab.IGitLabClient.GetEnvironmentClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IEnvironmentClient NGitLab.IGitLabClient.GetEvents() -> NGitLab.IEventClient NGitLab.IGitLabClient.GetGroupBadgeClient(int groupId) -> NGitLab.IGroupBadgeClient +NGitLab.IGitLabClient.GetGroupBadgeClient(NGitLab.Models.GroupId groupId) -> NGitLab.IGroupBadgeClient NGitLab.IGitLabClient.GetGroupMilestone(int groupId) -> NGitLab.IMilestoneClient +NGitLab.IGitLabClient.GetGroupMilestone(NGitLab.Models.GroupId groupId) -> NGitLab.IMilestoneClient NGitLab.IGitLabClient.GetGroupSearchClient(int groupId) -> NGitLab.ISearchClient +NGitLab.IGitLabClient.GetGroupSearchClient(NGitLab.Models.GroupId groupId) -> NGitLab.ISearchClient NGitLab.IGitLabClient.GetGroupVariableClient(int groupId) -> NGitLab.IGroupVariableClient +NGitLab.IGitLabClient.GetGroupVariableClient(NGitLab.Models.GroupId groupId) -> NGitLab.IGroupVariableClient NGitLab.IGitLabClient.GetJobs(int projectId) -> NGitLab.IJobClient +NGitLab.IGitLabClient.GetJobs(NGitLab.Models.ProjectId projectId) -> NGitLab.IJobClient NGitLab.IGitLabClient.GetMergeRequest(int projectId) -> NGitLab.IMergeRequestClient +NGitLab.IGitLabClient.GetMergeRequest(NGitLab.Models.ProjectId projectId) -> NGitLab.IMergeRequestClient NGitLab.IGitLabClient.GetMilestone(int projectId) -> NGitLab.IMilestoneClient +NGitLab.IGitLabClient.GetMilestone(NGitLab.Models.ProjectId projectId) -> NGitLab.IMilestoneClient NGitLab.IGitLabClient.GetPipelines(int projectId) -> NGitLab.IPipelineClient +NGitLab.IGitLabClient.GetPipelines(NGitLab.Models.ProjectId projectId) -> NGitLab.IPipelineClient NGitLab.IGitLabClient.GetProjectBadgeClient(int projectId) -> NGitLab.IProjectBadgeClient +NGitLab.IGitLabClient.GetProjectBadgeClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectBadgeClient NGitLab.IGitLabClient.GetProjectEvents(int projectId) -> NGitLab.IEventClient +NGitLab.IGitLabClient.GetProjectEvents(NGitLab.Models.ProjectId projectId) -> NGitLab.IEventClient NGitLab.IGitLabClient.GetProjectIssueNoteClient(int projectId) -> NGitLab.IProjectIssueNoteClient +NGitLab.IGitLabClient.GetProjectIssueNoteClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectIssueNoteClient NGitLab.IGitLabClient.GetProjectLevelApprovalRulesClient(int projectId) -> NGitLab.IProjectLevelApprovalRulesClient +NGitLab.IGitLabClient.GetProjectLevelApprovalRulesClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectLevelApprovalRulesClient NGitLab.IGitLabClient.GetProjectSearchClient(int projectId) -> NGitLab.ISearchClient +NGitLab.IGitLabClient.GetProjectSearchClient(NGitLab.Models.ProjectId projectId) -> NGitLab.ISearchClient NGitLab.IGitLabClient.GetProjectVariableClient(int projectId) -> NGitLab.IProjectVariableClient +NGitLab.IGitLabClient.GetProjectVariableClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProjectVariableClient NGitLab.IGitLabClient.GetProtectedBranchClient(int projectId) -> NGitLab.IProtectedBranchClient +NGitLab.IGitLabClient.GetProtectedBranchClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IProtectedBranchClient NGitLab.IGitLabClient.GetReleases(int projectId) -> NGitLab.IReleaseClient +NGitLab.IGitLabClient.GetReleases(NGitLab.Models.ProjectId projectId) -> NGitLab.IReleaseClient NGitLab.IGitLabClient.GetRepository(int projectId) -> NGitLab.IRepositoryClient +NGitLab.IGitLabClient.GetRepository(NGitLab.Models.ProjectId projectId) -> NGitLab.IRepositoryClient NGitLab.IGitLabClient.GetTriggers(int projectId) -> NGitLab.ITriggerClient +NGitLab.IGitLabClient.GetTriggers(NGitLab.Models.ProjectId projectId) -> NGitLab.ITriggerClient NGitLab.IGitLabClient.GetUserEvents(int userId) -> NGitLab.IEventClient NGitLab.IGitLabClient.GetWikiClient(int projectId) -> NGitLab.IWikiClient +NGitLab.IGitLabClient.GetWikiClient(NGitLab.Models.ProjectId projectId) -> NGitLab.IWikiClient NGitLab.IGitLabClient.GraphQL.get -> NGitLab.IGraphQLClient NGitLab.IGitLabClient.Groups.get -> NGitLab.IGroupsClient NGitLab.IGitLabClient.Issues.get -> NGitLab.IIssueClient @@ -412,9 +458,11 @@ NGitLab.Impl.BranchClient.Unprotect(string name) -> NGitLab.Models.Branch NGitLab.Impl.ClusterClient NGitLab.Impl.ClusterClient.All.get -> System.Collections.Generic.IEnumerable NGitLab.Impl.ClusterClient.ClusterClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.ClusterClient.ClusterClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.CommitClient NGitLab.Impl.CommitClient.CherryPick(NGitLab.Models.CommitCherryPick cherryPick) -> NGitLab.Models.Commit NGitLab.Impl.CommitClient.CommitClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.CommitClient.CommitClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.CommitClient.Create(NGitLab.Models.CommitCreate commit) -> NGitLab.Models.Commit NGitLab.Impl.CommitClient.GetCommit(string ref) -> NGitLab.Models.Commit NGitLab.Impl.CommitClient.GetJobStatus(string branchName) -> NGitLab.JobStatus @@ -423,6 +471,7 @@ NGitLab.Impl.CommitStatusClient NGitLab.Impl.CommitStatusClient.AddOrUpdate(NGitLab.Models.CommitStatusCreate status) -> NGitLab.Models.CommitStatusCreate NGitLab.Impl.CommitStatusClient.AllBySha(string commitSha) -> System.Collections.Generic.IEnumerable NGitLab.Impl.CommitStatusClient.CommitStatusClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.CommitStatusClient.CommitStatusClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.DeploymentClient NGitLab.Impl.DeploymentClient.DeploymentClient(NGitLab.Impl.API api) -> void NGitLab.Impl.DeploymentClient.Get(int projectId, NGitLab.Models.DeploymentQuery query) -> System.Collections.Generic.IEnumerable @@ -439,6 +488,7 @@ NGitLab.Impl.EnvironmentClient.Create(string name, string externalUrl) -> NGitLa NGitLab.Impl.EnvironmentClient.Delete(int environmentId) -> void NGitLab.Impl.EnvironmentClient.Edit(int environmentId, string name, string externalUrl) -> NGitLab.Models.EnvironmentInfo NGitLab.Impl.EnvironmentClient.EnvironmentClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.EnvironmentClient.EnvironmentClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.EnvironmentClient.GetById(int environmentId) -> NGitLab.Models.EnvironmentInfo NGitLab.Impl.EnvironmentClient.GetByIdAsync(int environmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task NGitLab.Impl.EnvironmentClient.GetEnvironmentsAsync(NGitLab.Models.EnvironmentQuery query) -> NGitLab.GitLabCollectionResponse @@ -549,6 +599,7 @@ NGitLab.Impl.JobClient.GetJobsAsync(NGitLab.Models.JobQuery query) -> NGitLab.Gi NGitLab.Impl.JobClient.GetTrace(int jobId) -> string NGitLab.Impl.JobClient.GetTraceAsync(int jobId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task NGitLab.Impl.JobClient.JobClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.JobClient.JobClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.JobClient.RunAction(int jobId, NGitLab.Models.JobAction action) -> NGitLab.Models.Job NGitLab.Impl.JobClient.RunActionAsync(int jobId, NGitLab.Models.JobAction action, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task NGitLab.Impl.LabelClient @@ -614,6 +665,7 @@ NGitLab.Impl.MergeRequestClient.GetPipelines(int mergeRequestIid) -> System.Coll NGitLab.Impl.MergeRequestClient.GetVersionsAsync(int mergeRequestIid) -> NGitLab.GitLabCollectionResponse NGitLab.Impl.MergeRequestClient.MergeRequestClient(NGitLab.Impl.API api) -> void NGitLab.Impl.MergeRequestClient.MergeRequestClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.MergeRequestClient.MergeRequestClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.MergeRequestClient.Rebase(int mergeRequestIid) -> NGitLab.Models.RebaseResult NGitLab.Impl.MergeRequestClient.RebaseAsync(int mergeRequestIid, NGitLab.Models.MergeRequestRebase options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task NGitLab.Impl.MergeRequestClient.Reopen(int mergeRequestIid) -> NGitLab.Models.MergeRequest @@ -693,6 +745,7 @@ NGitLab.Impl.PipelineClient.GetTestReportsSummary(int pipelineId) -> NGitLab.Mod NGitLab.Impl.PipelineClient.GetVariables(int pipelineId) -> System.Collections.Generic.IEnumerable NGitLab.Impl.PipelineClient.GetVariablesAsync(int pipelineId) -> NGitLab.GitLabCollectionResponse NGitLab.Impl.PipelineClient.PipelineClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.PipelineClient.PipelineClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.PipelineClient.RetryAsync(int pipelineId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task NGitLab.Impl.PipelineClient.Search(NGitLab.Models.PipelineQuery query) -> System.Collections.Generic.IEnumerable NGitLab.Impl.PipelineClient.SearchAsync(NGitLab.Models.PipelineQuery query) -> NGitLab.GitLabCollectionResponse @@ -733,11 +786,13 @@ NGitLab.Impl.ProjectIssueNoteClient.Edit(NGitLab.Models.ProjectIssueNoteEdit edi NGitLab.Impl.ProjectIssueNoteClient.ForIssue(int issueId) -> System.Collections.Generic.IEnumerable NGitLab.Impl.ProjectIssueNoteClient.Get(int issueId, int noteId) -> NGitLab.Models.ProjectIssueNote NGitLab.Impl.ProjectIssueNoteClient.ProjectIssueNoteClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.ProjectIssueNoteClient.ProjectIssueNoteClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.ProjectLevelApprovalRulesClient NGitLab.Impl.ProjectLevelApprovalRulesClient.CreateProjectLevelRule(NGitLab.Models.ApprovalRuleCreate approvalRuleCreate) -> NGitLab.Models.ApprovalRule NGitLab.Impl.ProjectLevelApprovalRulesClient.DeleteProjectLevelRule(int approvalRuleIdToDelete) -> void NGitLab.Impl.ProjectLevelApprovalRulesClient.GetProjectLevelApprovalRules() -> System.Collections.Generic.List NGitLab.Impl.ProjectLevelApprovalRulesClient.ProjectLevelApprovalRulesClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.ProjectLevelApprovalRulesClient.ProjectLevelApprovalRulesClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.ProjectLevelApprovalRulesClient.UpdateProjectLevelApprovalRule(int approvalRuleIdToUpdate, NGitLab.Models.ApprovalRuleUpdate approvalRuleUpdate) -> NGitLab.Models.ApprovalRule NGitLab.Impl.RepositoryClient NGitLab.Impl.RepositoryClient.Branches.get -> NGitLab.IBranchClient @@ -757,6 +812,7 @@ NGitLab.Impl.RepositoryClient.GetTree(string path, string ref, bool recursive) - NGitLab.Impl.RepositoryClient.GetTreeAsync(NGitLab.Models.RepositoryGetTreeOptions options) -> NGitLab.GitLabCollectionResponse NGitLab.Impl.RepositoryClient.ProjectHooks.get -> NGitLab.IProjectHooksClient NGitLab.Impl.RepositoryClient.RepositoryClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.RepositoryClient.RepositoryClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.RepositoryClient.Tags.get -> NGitLab.ITagClient NGitLab.Impl.RepositoryClient.Tree.get -> System.Collections.Generic.IEnumerable NGitLab.Impl.RunnerClient @@ -813,6 +869,7 @@ NGitLab.Impl.TriggerClient.All.get -> System.Collections.Generic.IEnumerable NGitLab.Models.Trigger NGitLab.Impl.TriggerClient.this[int id].get -> NGitLab.Models.Trigger NGitLab.Impl.TriggerClient.TriggerClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.TriggerClient.TriggerClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.Impl.UserClient NGitLab.Impl.UserClient.Activate(int userId) -> void NGitLab.Impl.UserClient.All.get -> System.Collections.Generic.IEnumerable @@ -842,6 +899,7 @@ NGitLab.Impl.WikiClient.Delete(string slug) -> void NGitLab.Impl.WikiClient.this[string slug].get -> NGitLab.Models.WikiPage NGitLab.Impl.WikiClient.Update(string slug, NGitLab.Models.WikiPageUpdate wikiPage) -> NGitLab.Models.WikiPage NGitLab.Impl.WikiClient.WikiClient(NGitLab.Impl.API api, int projectId) -> void +NGitLab.Impl.WikiClient.WikiClient(NGitLab.Impl.API api, NGitLab.Models.ProjectId projectId) -> void NGitLab.INamespacesClient NGitLab.INamespacesClient.Accessible.get -> System.Collections.Generic.IEnumerable NGitLab.INamespacesClient.Search(string search) -> System.Collections.Generic.IEnumerable @@ -1694,6 +1752,10 @@ NGitLab.Models.GroupCreate.RequestAccessEnabled -> bool NGitLab.Models.GroupCreate.SharedRunnersMinutesLimit.get -> int? NGitLab.Models.GroupCreate.SharedRunnersMinutesLimit.set -> void NGitLab.Models.GroupCreate.Visibility -> NGitLab.Models.VisibilityLevel +NGitLab.Models.GroupId +NGitLab.Models.GroupId.GroupId(long id) -> void +NGitLab.Models.GroupId.GroupId(NGitLab.Models.Group group) -> void +NGitLab.Models.GroupId.GroupId(string path) -> void NGitLab.Models.GroupLabelCreate NGitLab.Models.GroupLabelCreate.Color.get -> string NGitLab.Models.GroupLabelCreate.Color.set -> void @@ -1788,6 +1850,9 @@ NGitLab.Models.Identity.ExternUid -> string NGitLab.Models.Identity.Identity() -> void NGitLab.Models.Identity.Provider -> string NGitLab.Models.Identity.SamlProviderId -> int? +NGitLab.Models.IdOrNamespacedPath +NGitLab.Models.IdOrNamespacedPath.IdOrNamespacedPath(long id) -> void +NGitLab.Models.IdOrNamespacedPath.IdOrNamespacedPath(string path) -> void NGitLab.Models.Issue NGitLab.Models.Issue.Assignee -> NGitLab.Models.Assignee NGitLab.Models.Issue.Assignees -> NGitLab.Models.Assignee[] @@ -2675,6 +2740,10 @@ NGitLab.Models.ProjectHookUpsert.PushEvents -> bool NGitLab.Models.ProjectHookUpsert.TagPushEvents -> bool NGitLab.Models.ProjectHookUpsert.Token -> string NGitLab.Models.ProjectHookUpsert.Url -> System.Uri +NGitLab.Models.ProjectId +NGitLab.Models.ProjectId.ProjectId(long id) -> void +NGitLab.Models.ProjectId.ProjectId(NGitLab.Models.Project project) -> void +NGitLab.Models.ProjectId.ProjectId(string path) -> void NGitLab.Models.ProjectIssueNote NGitLab.Models.ProjectIssueNote.Attachment -> string NGitLab.Models.ProjectIssueNote.Author -> NGitLab.Models.Author @@ -3657,6 +3726,7 @@ override NGitLab.Models.Blame.GetHashCode() -> int override NGitLab.Models.BlameCommit.Equals(object obj) -> bool override NGitLab.Models.BlameCommit.GetHashCode() -> int override NGitLab.Models.Event.ToString() -> string +override NGitLab.Models.IdOrNamespacedPath.ToString() -> string override NGitLab.Models.MergeRequest.ToString() -> string override NGitLab.Models.QueryAssigneeId.ToString() -> string override NGitLab.Sha1.Equals(object obj) -> bool @@ -3670,6 +3740,14 @@ static NGitLab.GitLabClient.Connect(string hostUrl, string apiToken) -> NGitLab. static NGitLab.GitLabClient.Connect(string hostUrl, string username, string password) -> NGitLab.GitLabClient static NGitLab.Models.FileData.Base64Decode(string base64EncodedData) -> string static NGitLab.Models.FileUpsert.Base64Encode(string plainText) -> string +static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(long id) -> NGitLab.Models.GroupId +static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(NGitLab.Models.Group group) -> NGitLab.Models.GroupId +static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(string path) -> NGitLab.Models.GroupId +static NGitLab.Models.IdOrNamespacedPath.implicit operator NGitLab.Models.IdOrNamespacedPath(long id) -> NGitLab.Models.IdOrNamespacedPath +static NGitLab.Models.IdOrNamespacedPath.implicit operator NGitLab.Models.IdOrNamespacedPath(string path) -> NGitLab.Models.IdOrNamespacedPath +static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(long id) -> NGitLab.Models.ProjectId +static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(NGitLab.Models.Project project) -> NGitLab.Models.ProjectId +static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(string path) -> NGitLab.Models.ProjectId static NGitLab.Models.QueryAssigneeId.Any.get -> NGitLab.Models.QueryAssigneeId static NGitLab.Models.QueryAssigneeId.implicit operator NGitLab.Models.QueryAssigneeId(int id) -> NGitLab.Models.QueryAssigneeId static NGitLab.Models.QueryAssigneeId.None.get -> NGitLab.Models.QueryAssigneeId From 11e2c1e9e5b5682b5b19704e7aec7b58a0b0cf13 Mon Sep 17 00:00:00 2001 From: PM Extra Date: Mon, 30 Oct 2023 22:39:06 +0800 Subject: [PATCH 2/4] Correct MilestoneClient --- NGitLab/Impl/MilestoneClient.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/NGitLab/Impl/MilestoneClient.cs b/NGitLab/Impl/MilestoneClient.cs index fb4daf38..d89fb51f 100644 --- a/NGitLab/Impl/MilestoneClient.cs +++ b/NGitLab/Impl/MilestoneClient.cs @@ -12,16 +12,10 @@ public class MilestoneClient : IMilestoneClient private readonly API _api; private readonly string _milestonePath; - [Obsolete("Use long or namespaced path string as id instead.")] - internal MilestoneClient(API api, MilestoneScope scope, int id) - : this(api, scope, (long)id) - { - } - - internal MilestoneClient(API api, MilestoneScope scope, IdOrNamespacedPath projectId) + internal MilestoneClient(API api, MilestoneScope scope, IdOrNamespacedPath id) { _api = api; - _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{projectId.ValueAsUriParameter}/milestones"; + _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ValueAsUriParameter}/milestones"; Scope = scope; } From bdcaa245802b93046fa1fb5ef9ed29c25a001c16 Mon Sep 17 00:00:00 2001 From: PMExtra Date: Wed, 1 Nov 2023 11:22:51 +0800 Subject: [PATCH 3/4] Replace record types with struct + interface --- NGitLab.Mock/Clients/ClusterClient.cs | 2 +- NGitLab.Mock/Clients/CommitClient.cs | 2 +- NGitLab.Mock/Clients/CommitStatusClient.cs | 2 +- NGitLab.Mock/Clients/EnvironmentClient.cs | 2 +- NGitLab.Mock/Clients/EventClient.cs | 4 +-- NGitLab.Mock/Clients/GroupBadgeClient.cs | 2 +- NGitLab.Mock/Clients/GroupSearchClient.cs | 2 +- NGitLab.Mock/Clients/GroupVariableClient.cs | 2 +- NGitLab.Mock/Clients/JobClient.cs | 2 +- NGitLab.Mock/Clients/MergeRequestClient.cs | 2 +- NGitLab.Mock/Clients/MilestoneClient.cs | 6 ++--- NGitLab.Mock/Clients/PipelineClient.cs | 2 +- NGitLab.Mock/Clients/ProjectBadgeClient.cs | 2 +- .../Clients/ProjectIssueNoteClient.cs | 2 +- .../ProjectLevelApprovalRulesClient.cs | 2 +- NGitLab.Mock/Clients/ProjectSearchClient.cs | 2 +- NGitLab.Mock/Clients/ProjectVariableClient.cs | 2 +- NGitLab.Mock/Clients/ProtectedBranchClient.cs | 2 +- NGitLab.Mock/Clients/ReleaseClient.cs | 2 +- NGitLab.Mock/Clients/RepositoryClient.cs | 2 +- NGitLab.Mock/Clients/TriggerClient.cs | 2 +- NGitLab.Mock/Clients/WikiClient.cs | 2 +- NGitLab/GitLabClient.cs | 6 ++--- NGitLab/Impl/ClusterClient.cs | 2 +- NGitLab/Impl/CommitClient.cs | 2 +- NGitLab/Impl/CommitStatusClient.cs | 2 +- NGitLab/Impl/EnvironmentClient.cs | 2 +- NGitLab/Impl/GroupBadgeClient.cs | 2 +- NGitLab/Impl/GroupVariableClient.cs | 2 +- NGitLab/Impl/JobClient.cs | 2 +- NGitLab/Impl/MergeRequestClient.cs | 2 +- NGitLab/Impl/MilestoneClient.cs | 6 ++--- NGitLab/Impl/PipelineClient.cs | 2 +- NGitLab/Impl/ProjectBadgeClient.cs | 2 +- NGitLab/Impl/ProjectIssueNoteClient.cs | 2 +- .../Impl/ProjectLevelApprovalRulesClient.cs | 2 +- NGitLab/Impl/ProjectVariableClient.cs | 2 +- NGitLab/Impl/ProtectedBranchClient.cs | 2 +- NGitLab/Impl/ReleaseClient.cs | 2 +- NGitLab/Impl/RepositoryClient.cs | 2 +- NGitLab/Impl/TriggerClient.cs | 2 +- NGitLab/Impl/WikiClient.cs | 2 +- NGitLab/Models/GroupId.cs | 19 +++++++++++--- NGitLab/Models/IdOrNamespacedPath.cs | 25 ------------------- NGitLab/Models/IdOrPathExtensions.cs | 14 +++++++++++ NGitLab/Models/IidOrPathAddressable.cs | 11 ++++++++ NGitLab/Models/ProjectId.cs | 19 +++++++++++--- NGitLab/PublicAPI.Unshipped.txt | 16 ++++++------ 48 files changed, 113 insertions(+), 89 deletions(-) delete mode 100644 NGitLab/Models/IdOrNamespacedPath.cs create mode 100644 NGitLab/Models/IdOrPathExtensions.cs create mode 100644 NGitLab/Models/IidOrPathAddressable.cs diff --git a/NGitLab.Mock/Clients/ClusterClient.cs b/NGitLab.Mock/Clients/ClusterClient.cs index d1cb2c02..f45d36e4 100644 --- a/NGitLab.Mock/Clients/ClusterClient.cs +++ b/NGitLab.Mock/Clients/ClusterClient.cs @@ -11,7 +11,7 @@ internal sealed class ClusterClient : ClientBase, IClusterClient public ClusterClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public IEnumerable All => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/CommitClient.cs b/NGitLab.Mock/Clients/CommitClient.cs index aa3fe7ab..c5acccbf 100644 --- a/NGitLab.Mock/Clients/CommitClient.cs +++ b/NGitLab.Mock/Clients/CommitClient.cs @@ -12,7 +12,7 @@ internal sealed class CommitClient : ClientBase, ICommitClient public CommitClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Commit Create(CommitCreate commit) diff --git a/NGitLab.Mock/Clients/CommitStatusClient.cs b/NGitLab.Mock/Clients/CommitStatusClient.cs index 2d691303..d124b2ee 100644 --- a/NGitLab.Mock/Clients/CommitStatusClient.cs +++ b/NGitLab.Mock/Clients/CommitStatusClient.cs @@ -12,7 +12,7 @@ internal sealed class CommitStatusClient : ClientBase, ICommitStatusClient public CommitStatusClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public CommitStatusCreate AddOrUpdate(CommitStatusCreate status) diff --git a/NGitLab.Mock/Clients/EnvironmentClient.cs b/NGitLab.Mock/Clients/EnvironmentClient.cs index 9b88572a..593e2b1b 100644 --- a/NGitLab.Mock/Clients/EnvironmentClient.cs +++ b/NGitLab.Mock/Clients/EnvironmentClient.cs @@ -13,7 +13,7 @@ internal sealed class EnvironmentClient : ClientBase, IEnvironmentClient public EnvironmentClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public IEnumerable All => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/EventClient.cs b/NGitLab.Mock/Clients/EventClient.cs index 33f039a9..4b48d1d4 100644 --- a/NGitLab.Mock/Clients/EventClient.cs +++ b/NGitLab.Mock/Clients/EventClient.cs @@ -14,11 +14,11 @@ public EventClient(ClientContext context) { } - public EventClient(ClientContext context, int? userId = null, ProjectId projectId = null) + public EventClient(ClientContext context, int? userId = null, ProjectId? projectId = null) : base(context) { _userId = userId; - _projectId = projectId is null ? null : Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = projectId.HasValue ? Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id : null; } IEnumerable IEventClient.Get(EventQuery query) diff --git a/NGitLab.Mock/Clients/GroupBadgeClient.cs b/NGitLab.Mock/Clients/GroupBadgeClient.cs index a6e46bd8..89a426bd 100644 --- a/NGitLab.Mock/Clients/GroupBadgeClient.cs +++ b/NGitLab.Mock/Clients/GroupBadgeClient.cs @@ -11,7 +11,7 @@ internal sealed class GroupBadgeClient : ClientBase, IGroupBadgeClient public GroupBadgeClient(ClientContext context, GroupId groupId) : base(context) { - _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter()).Id; } public Models.Badge this[int id] diff --git a/NGitLab.Mock/Clients/GroupSearchClient.cs b/NGitLab.Mock/Clients/GroupSearchClient.cs index acd61a68..b9742dba 100644 --- a/NGitLab.Mock/Clients/GroupSearchClient.cs +++ b/NGitLab.Mock/Clients/GroupSearchClient.cs @@ -12,7 +12,7 @@ public GroupSearchClient(ClientContext context, GroupId groupId) : base(context) { _context = context; - _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter()).Id; } public GitLabCollectionResponse GetBlobsAsync(SearchQuery query) diff --git a/NGitLab.Mock/Clients/GroupVariableClient.cs b/NGitLab.Mock/Clients/GroupVariableClient.cs index 6bc83058..b681a38c 100644 --- a/NGitLab.Mock/Clients/GroupVariableClient.cs +++ b/NGitLab.Mock/Clients/GroupVariableClient.cs @@ -11,7 +11,7 @@ internal sealed class GroupVariableClient : ClientBase, IGroupVariableClient public GroupVariableClient(ClientContext context, GroupId groupId) : base(context) { - _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter).Id; + _groupId = Server.AllGroups.FindGroup(groupId.ValueAsUriParameter()).Id; } public Variable this[string key] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/JobClient.cs b/NGitLab.Mock/Clients/JobClient.cs index 38fedbd9..ca4e5b76 100644 --- a/NGitLab.Mock/Clients/JobClient.cs +++ b/NGitLab.Mock/Clients/JobClient.cs @@ -16,7 +16,7 @@ internal sealed class JobClient : ClientBase, IJobClient public JobClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Models.Job Get(int jobId) diff --git a/NGitLab.Mock/Clients/MergeRequestClient.cs b/NGitLab.Mock/Clients/MergeRequestClient.cs index f8a963a9..9b43fb52 100644 --- a/NGitLab.Mock/Clients/MergeRequestClient.cs +++ b/NGitLab.Mock/Clients/MergeRequestClient.cs @@ -22,7 +22,7 @@ public MergeRequestClient(ClientContext context) public MergeRequestClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } private void AssertProjectId() diff --git a/NGitLab.Mock/Clients/MilestoneClient.cs b/NGitLab.Mock/Clients/MilestoneClient.cs index ec00912a..9e944ad1 100644 --- a/NGitLab.Mock/Clients/MilestoneClient.cs +++ b/NGitLab.Mock/Clients/MilestoneClient.cs @@ -12,13 +12,13 @@ internal sealed class MilestoneClient : ClientBase, IMilestoneClient { private readonly int _resourceId; - public MilestoneClient(ClientContext context, IdOrNamespacedPath id, MilestoneScope scope) + public MilestoneClient(ClientContext context, IidOrPathAddressable id, MilestoneScope scope) : base(context) { _resourceId = scope switch { - MilestoneScope.Groups => Server.AllGroups.FindGroup(id.ValueAsUriParameter).Id, - MilestoneScope.Projects => Server.AllProjects.FindProject(id.ValueAsUriParameter).Id, + MilestoneScope.Groups => Server.AllGroups.FindGroup(id.ValueAsUriParameter()).Id, + MilestoneScope.Projects => Server.AllProjects.FindProject(id.ValueAsUriParameter()).Id, _ => throw new NotSupportedException($"{scope} milestone is not supported yet."), }; Scope = scope; diff --git a/NGitLab.Mock/Clients/PipelineClient.cs b/NGitLab.Mock/Clients/PipelineClient.cs index 51addb8d..68a0e517 100644 --- a/NGitLab.Mock/Clients/PipelineClient.cs +++ b/NGitLab.Mock/Clients/PipelineClient.cs @@ -18,7 +18,7 @@ public PipelineClient(ClientContext context, IJobClient jobClient, ProjectId pro : base(context) { _jobClient = jobClient; - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Models.Pipeline this[int id] diff --git a/NGitLab.Mock/Clients/ProjectBadgeClient.cs b/NGitLab.Mock/Clients/ProjectBadgeClient.cs index 0af90e86..101a6c93 100644 --- a/NGitLab.Mock/Clients/ProjectBadgeClient.cs +++ b/NGitLab.Mock/Clients/ProjectBadgeClient.cs @@ -12,7 +12,7 @@ internal sealed class ProjectBadgeClient : ClientBase, IProjectBadgeClient public ProjectBadgeClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Models.Badge this[int id] diff --git a/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs b/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs index f02feed2..dd9e7a57 100644 --- a/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs +++ b/NGitLab.Mock/Clients/ProjectIssueNoteClient.cs @@ -11,7 +11,7 @@ internal sealed class ProjectIssueNoteClient : ClientBase, IProjectIssueNoteClie public ProjectIssueNoteClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Models.ProjectIssueNote Create(ProjectIssueNoteCreate create) diff --git a/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs b/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs index f71b4db4..c8b50c6a 100644 --- a/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs +++ b/NGitLab.Mock/Clients/ProjectLevelApprovalRulesClient.cs @@ -11,7 +11,7 @@ internal sealed class ProjectLevelApprovalRulesClient : ClientBase, IProjectLeve public ProjectLevelApprovalRulesClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public List GetProjectLevelApprovalRules() diff --git a/NGitLab.Mock/Clients/ProjectSearchClient.cs b/NGitLab.Mock/Clients/ProjectSearchClient.cs index f3f5040f..8eea7e93 100644 --- a/NGitLab.Mock/Clients/ProjectSearchClient.cs +++ b/NGitLab.Mock/Clients/ProjectSearchClient.cs @@ -12,7 +12,7 @@ public ProjectSearchClient(ClientContext context, ProjectId projectId) : base(context) { _context = context; - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public GitLabCollectionResponse GetBlobsAsync(SearchQuery query) diff --git a/NGitLab.Mock/Clients/ProjectVariableClient.cs b/NGitLab.Mock/Clients/ProjectVariableClient.cs index 079ca6a3..082f6432 100644 --- a/NGitLab.Mock/Clients/ProjectVariableClient.cs +++ b/NGitLab.Mock/Clients/ProjectVariableClient.cs @@ -11,7 +11,7 @@ internal sealed class ProjectVariableClient : ClientBase, IProjectVariableClient public ProjectVariableClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Variable this[string key] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/ProtectedBranchClient.cs b/NGitLab.Mock/Clients/ProtectedBranchClient.cs index 0b30df59..66d4761f 100644 --- a/NGitLab.Mock/Clients/ProtectedBranchClient.cs +++ b/NGitLab.Mock/Clients/ProtectedBranchClient.cs @@ -11,7 +11,7 @@ internal sealed class ProtectedBranchClient : ClientBase, IProtectedBranchClient public ProtectedBranchClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Models.ProtectedBranch GetProtectedBranch(string branchName) diff --git a/NGitLab.Mock/Clients/ReleaseClient.cs b/NGitLab.Mock/Clients/ReleaseClient.cs index 9551ce06..c26595f3 100644 --- a/NGitLab.Mock/Clients/ReleaseClient.cs +++ b/NGitLab.Mock/Clients/ReleaseClient.cs @@ -16,7 +16,7 @@ internal sealed class ReleaseClient : ClientBase, IReleaseClient public ReleaseClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public IEnumerable All diff --git a/NGitLab.Mock/Clients/RepositoryClient.cs b/NGitLab.Mock/Clients/RepositoryClient.cs index 4bfe4236..2e07eb19 100644 --- a/NGitLab.Mock/Clients/RepositoryClient.cs +++ b/NGitLab.Mock/Clients/RepositoryClient.cs @@ -14,7 +14,7 @@ internal sealed class RepositoryClient : ClientBase, IRepositoryClient public RepositoryClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public ITagClient Tags => new TagClient(Context, _projectId); diff --git a/NGitLab.Mock/Clients/TriggerClient.cs b/NGitLab.Mock/Clients/TriggerClient.cs index d9d08b6d..054631e9 100644 --- a/NGitLab.Mock/Clients/TriggerClient.cs +++ b/NGitLab.Mock/Clients/TriggerClient.cs @@ -11,7 +11,7 @@ internal sealed class TriggerClient : ClientBase, ITriggerClient public TriggerClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public Trigger this[int id] => throw new NotImplementedException(); diff --git a/NGitLab.Mock/Clients/WikiClient.cs b/NGitLab.Mock/Clients/WikiClient.cs index 84d4e57d..10d3bd66 100644 --- a/NGitLab.Mock/Clients/WikiClient.cs +++ b/NGitLab.Mock/Clients/WikiClient.cs @@ -11,7 +11,7 @@ internal sealed class WikiClient : ClientBase, IWikiClient public WikiClient(ClientContext context, ProjectId projectId) : base(context) { - _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter).Id; + _projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id; } public WikiPage this[string slug] => throw new NotImplementedException(); diff --git a/NGitLab/GitLabClient.cs b/NGitLab/GitLabClient.cs index 8105ccfa..9fd164fa 100644 --- a/NGitLab/GitLabClient.cs +++ b/NGitLab/GitLabClient.cs @@ -112,7 +112,7 @@ public IEventClient GetProjectEvents(int projectId) => GetProjectEvents((long)projectId); public IEventClient GetProjectEvents(ProjectId projectId) - => new EventClient(_api, $"projects/{projectId.ValueAsUriParameter}/events"); + => new EventClient(_api, $"projects/{projectId.ValueAsUriParameter()}/events"); public IRepositoryClient GetRepository(int projectId) => GetRepository((long)projectId); @@ -238,12 +238,12 @@ public ISearchClient GetGroupSearchClient(int groupId) => GetGroupSearchClient((long)groupId); public ISearchClient GetGroupSearchClient(GroupId groupId) - => new SearchClient(_api, $"/groups/{groupId.ValueAsUriParameter}/search"); + => new SearchClient(_api, $"/groups/{groupId.ValueAsUriParameter()}/search"); public ISearchClient GetProjectSearchClient(int projectId) => GetProjectSearchClient((long)projectId); public ISearchClient GetProjectSearchClient(ProjectId projectId) - => new SearchClient(_api, $"/projects/{projectId.ValueAsUriParameter}/search"); + => new SearchClient(_api, $"/projects/{projectId.ValueAsUriParameter()}/search"); } } diff --git a/NGitLab/Impl/ClusterClient.cs b/NGitLab/Impl/ClusterClient.cs index a25bf858..a74293ed 100644 --- a/NGitLab/Impl/ClusterClient.cs +++ b/NGitLab/Impl/ClusterClient.cs @@ -18,7 +18,7 @@ public ClusterClient(API api, int projectId) public ClusterClient(API api, ProjectId projectId) { _api = api; - _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/clusters"; + _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}/clusters"; } public IEnumerable All => _api.Get().GetAll(_environmentsPath); diff --git a/NGitLab/Impl/CommitClient.cs b/NGitLab/Impl/CommitClient.cs index 045422ea..3ab98bfa 100644 --- a/NGitLab/Impl/CommitClient.cs +++ b/NGitLab/Impl/CommitClient.cs @@ -18,7 +18,7 @@ public CommitClient(API api, int projectId) public CommitClient(API api, ProjectId projectId) { _api = api; - var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; _repoPath = $"{projectPath}/repository"; } diff --git a/NGitLab/Impl/CommitStatusClient.cs b/NGitLab/Impl/CommitStatusClient.cs index bb5eed28..7f18360e 100644 --- a/NGitLab/Impl/CommitStatusClient.cs +++ b/NGitLab/Impl/CommitStatusClient.cs @@ -20,7 +20,7 @@ public CommitStatusClient(API api, ProjectId projectId) { _api = api; - var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; _statusCreatePath = $"{projectPath}/statuses"; _statusPath = $"{projectPath}/repository/commits"; } diff --git a/NGitLab/Impl/EnvironmentClient.cs b/NGitLab/Impl/EnvironmentClient.cs index 957813fb..22c517b8 100644 --- a/NGitLab/Impl/EnvironmentClient.cs +++ b/NGitLab/Impl/EnvironmentClient.cs @@ -21,7 +21,7 @@ public EnvironmentClient(API api, int projectId) public EnvironmentClient(API api, ProjectId projectId) { _api = api; - _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/environments"; + _environmentsPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}/environments"; } public IEnumerable All => _api.Get().GetAll(_environmentsPath); diff --git a/NGitLab/Impl/GroupBadgeClient.cs b/NGitLab/Impl/GroupBadgeClient.cs index 6d186550..0cc11340 100644 --- a/NGitLab/Impl/GroupBadgeClient.cs +++ b/NGitLab/Impl/GroupBadgeClient.cs @@ -5,7 +5,7 @@ namespace NGitLab.Impl internal sealed class GroupBadgeClient : BadgeClient, IGroupBadgeClient { public GroupBadgeClient(API api, GroupId groupId) - : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter}") + : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter()}") { } } diff --git a/NGitLab/Impl/GroupVariableClient.cs b/NGitLab/Impl/GroupVariableClient.cs index 7837c7ce..58ef94a5 100644 --- a/NGitLab/Impl/GroupVariableClient.cs +++ b/NGitLab/Impl/GroupVariableClient.cs @@ -5,7 +5,7 @@ namespace NGitLab.Impl internal sealed class GroupVariableClient : VariableClient, IGroupVariableClient { public GroupVariableClient(API api, GroupId groupId) - : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter}") + : base(api, $"{Group.Url}/{groupId.ValueAsUriParameter()}") { } } diff --git a/NGitLab/Impl/JobClient.cs b/NGitLab/Impl/JobClient.cs index c41bfbeb..473b4a2d 100644 --- a/NGitLab/Impl/JobClient.cs +++ b/NGitLab/Impl/JobClient.cs @@ -22,7 +22,7 @@ public JobClient(API api, int projectId) public JobClient(API api, ProjectId projectId) { _api = api; - _jobsPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/jobs"; + _jobsPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}/jobs"; } public IEnumerable GetJobs(JobScopeMask scope) diff --git a/NGitLab/Impl/MergeRequestClient.cs b/NGitLab/Impl/MergeRequestClient.cs index 59b7bcdf..ff6d1113 100644 --- a/NGitLab/Impl/MergeRequestClient.cs +++ b/NGitLab/Impl/MergeRequestClient.cs @@ -25,7 +25,7 @@ public MergeRequestClient(API api, int projectId) public MergeRequestClient(API api, ProjectId projectId) { _api = api; - _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; } public MergeRequestClient(API api) diff --git a/NGitLab/Impl/MilestoneClient.cs b/NGitLab/Impl/MilestoneClient.cs index d89fb51f..5ae363cf 100644 --- a/NGitLab/Impl/MilestoneClient.cs +++ b/NGitLab/Impl/MilestoneClient.cs @@ -12,16 +12,16 @@ public class MilestoneClient : IMilestoneClient private readonly API _api; private readonly string _milestonePath; - internal MilestoneClient(API api, MilestoneScope scope, IdOrNamespacedPath id) + internal MilestoneClient(API api, MilestoneScope scope, IidOrPathAddressable id) { _api = api; - _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ValueAsUriParameter}/milestones"; + _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ValueAsUriParameter()}/milestones"; Scope = scope; } [Obsolete("Use GitLabClient.GetMilestone() or GitLabClient.GetGroupMilestone() instead.")] public MilestoneClient(API api, int projectId) - : this(api, MilestoneScope.Projects, projectId) + : this(api, MilestoneScope.Projects, (ProjectId)projectId) { } diff --git a/NGitLab/Impl/PipelineClient.cs b/NGitLab/Impl/PipelineClient.cs index d5a02628..31ba7d7a 100644 --- a/NGitLab/Impl/PipelineClient.cs +++ b/NGitLab/Impl/PipelineClient.cs @@ -24,7 +24,7 @@ public PipelineClient(API api, int projectId) public PipelineClient(API api, ProjectId projectId) { _api = api; - _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; _pipelinesPath = $"{_projectPath}/pipelines"; } diff --git a/NGitLab/Impl/ProjectBadgeClient.cs b/NGitLab/Impl/ProjectBadgeClient.cs index 06dfa0fa..2712d88c 100644 --- a/NGitLab/Impl/ProjectBadgeClient.cs +++ b/NGitLab/Impl/ProjectBadgeClient.cs @@ -7,7 +7,7 @@ namespace NGitLab.Impl internal sealed class ProjectBadgeClient : BadgeClient, IProjectBadgeClient { public ProjectBadgeClient(API api, ProjectId projectId) - : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter}") + : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter()}") { } diff --git a/NGitLab/Impl/ProjectIssueNoteClient.cs b/NGitLab/Impl/ProjectIssueNoteClient.cs index f533dcd4..1ac9c255 100644 --- a/NGitLab/Impl/ProjectIssueNoteClient.cs +++ b/NGitLab/Impl/ProjectIssueNoteClient.cs @@ -21,7 +21,7 @@ public ProjectIssueNoteClient(API api, int projectId) public ProjectIssueNoteClient(API api, ProjectId projectId) { _api = api; - _projectId = projectId.ValueAsUriParameter; + _projectId = projectId.ValueAsUriParameter(); } public IEnumerable ForIssue(int issueId) diff --git a/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs b/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs index f4e01404..e8a747da 100644 --- a/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs +++ b/NGitLab/Impl/ProjectLevelApprovalRulesClient.cs @@ -19,7 +19,7 @@ public ProjectLevelApprovalRulesClient(API api, int projectId) public ProjectLevelApprovalRulesClient(API api, ProjectId projectId) { _api = api; - _approvalRulesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter}/approval_rules"; + _approvalRulesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter()}/approval_rules"; } public List GetProjectLevelApprovalRules() diff --git a/NGitLab/Impl/ProjectVariableClient.cs b/NGitLab/Impl/ProjectVariableClient.cs index cb9c9c28..a896ec12 100644 --- a/NGitLab/Impl/ProjectVariableClient.cs +++ b/NGitLab/Impl/ProjectVariableClient.cs @@ -5,7 +5,7 @@ namespace NGitLab.Impl internal sealed class ProjectVariableClient : VariableClient, IProjectVariableClient { public ProjectVariableClient(API api, ProjectId projectId) - : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter}") + : base(api, $"{Project.Url}/{projectId.ValueAsUriParameter()}") { } } diff --git a/NGitLab/Impl/ProtectedBranchClient.cs b/NGitLab/Impl/ProtectedBranchClient.cs index 6951cdac..e6cc5263 100644 --- a/NGitLab/Impl/ProtectedBranchClient.cs +++ b/NGitLab/Impl/ProtectedBranchClient.cs @@ -12,7 +12,7 @@ internal sealed class ProtectedBranchClient : IProtectedBranchClient public ProtectedBranchClient(API api, ProjectId projectId) { _api = api; - _protectedBranchesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter}/protected_branches"; + _protectedBranchesUrl = $"{Project.Url}/{projectId.ValueAsUriParameter()}/protected_branches"; } public ProtectedBranch ProtectBranch(BranchProtect branchProtect) diff --git a/NGitLab/Impl/ReleaseClient.cs b/NGitLab/Impl/ReleaseClient.cs index ecee8f39..32572cbf 100644 --- a/NGitLab/Impl/ReleaseClient.cs +++ b/NGitLab/Impl/ReleaseClient.cs @@ -17,7 +17,7 @@ internal sealed class ReleaseClient : IReleaseClient public ReleaseClient(API api, ProjectId projectId) { _api = api; - var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + var projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; _releasesPath = $"{projectPath}/releases"; } diff --git a/NGitLab/Impl/RepositoryClient.cs b/NGitLab/Impl/RepositoryClient.cs index 1a841e39..aa615a1e 100644 --- a/NGitLab/Impl/RepositoryClient.cs +++ b/NGitLab/Impl/RepositoryClient.cs @@ -23,7 +23,7 @@ public RepositoryClient(API api, int projectId) public RepositoryClient(API api, ProjectId projectId) { _api = api; - _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; _repoPath = $"{_projectPath}/repository"; } diff --git a/NGitLab/Impl/TriggerClient.cs b/NGitLab/Impl/TriggerClient.cs index b17323e0..e868fc1a 100644 --- a/NGitLab/Impl/TriggerClient.cs +++ b/NGitLab/Impl/TriggerClient.cs @@ -19,7 +19,7 @@ public TriggerClient(API api, int projectId) public TriggerClient(API api, ProjectId projectId) { _api = api; - _triggersPath = $"{Project.Url}/{projectId.ValueAsUriParameter}/triggers"; + _triggersPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}/triggers"; } public Trigger this[int id] => _api.Get().To(_triggersPath + "/" + id.ToStringInvariant()); diff --git a/NGitLab/Impl/WikiClient.cs b/NGitLab/Impl/WikiClient.cs index c85062d4..441f6c85 100644 --- a/NGitLab/Impl/WikiClient.cs +++ b/NGitLab/Impl/WikiClient.cs @@ -19,7 +19,7 @@ public WikiClient(API api, int projectId) public WikiClient(API api, ProjectId projectId) { _api = api; - _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter}"; + _projectPath = $"{Project.Url}/{projectId.ValueAsUriParameter()}"; } public IEnumerable All => _api.Get().GetAll(_projectPath + "/wikis"); diff --git a/NGitLab/Models/GroupId.cs b/NGitLab/Models/GroupId.cs index 3a869067..3af278dc 100644 --- a/NGitLab/Models/GroupId.cs +++ b/NGitLab/Models/GroupId.cs @@ -1,20 +1,29 @@ +using System; + namespace NGitLab.Models { - public record GroupId : IdOrNamespacedPath + public readonly struct GroupId : IidOrPathAddressable { + private readonly long _id; + private readonly string _path; + + long IidOrPathAddressable.Id => _id; + + string IidOrPathAddressable.Path => _path; + public GroupId(long id) - : base(id) { + _id = id; } public GroupId(string path) - : base(path) { + _path = path ?? throw new ArgumentNullException(nameof(path)); } public GroupId(Group group) - : base(group.Id) { + _id = group?.Id ?? throw new ArgumentNullException(nameof(group)); } public static implicit operator GroupId(long id) => new(id); @@ -22,5 +31,7 @@ public GroupId(Group group) public static implicit operator GroupId(string path) => new(path); public static implicit operator GroupId(Group group) => new(group); + + public override string ToString() => this.ValueAsString(); } } diff --git a/NGitLab/Models/IdOrNamespacedPath.cs b/NGitLab/Models/IdOrNamespacedPath.cs deleted file mode 100644 index e115a816..00000000 --- a/NGitLab/Models/IdOrNamespacedPath.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using NGitLab.Extensions; - -namespace NGitLab.Models -{ - public record IdOrNamespacedPath - { - private readonly long _id; - private readonly string _path; - - public IdOrNamespacedPath(long id) => _id = id; - - public IdOrNamespacedPath(string path) => _path = path ?? throw new ArgumentNullException(nameof(path)); - - public static implicit operator IdOrNamespacedPath(long id) => new(id); - - public static implicit operator IdOrNamespacedPath(string path) => new(path); - - internal string ValueAsString => _path ?? _id.ToStringInvariant(); - - internal string ValueAsUriParameter => _path is null ? _id.ToStringInvariant() : Uri.EscapeDataString(_path); - - public override string ToString() => ValueAsString; - } -} diff --git a/NGitLab/Models/IdOrPathExtensions.cs b/NGitLab/Models/IdOrPathExtensions.cs new file mode 100644 index 00000000..9a1edef0 --- /dev/null +++ b/NGitLab/Models/IdOrPathExtensions.cs @@ -0,0 +1,14 @@ +using System; +using NGitLab.Extensions; + +namespace NGitLab.Models +{ + public static class IdOrPathExtensions + { + public static string ValueAsString(this IidOrPathAddressable idOrPath) + => idOrPath.Path ?? idOrPath.Id.ToStringInvariant(); + + public static string ValueAsUriParameter(this IidOrPathAddressable idOrPath) + => idOrPath.Path is null ? idOrPath.Id.ToStringInvariant() : Uri.EscapeDataString(idOrPath.Path); + } +} diff --git a/NGitLab/Models/IidOrPathAddressable.cs b/NGitLab/Models/IidOrPathAddressable.cs new file mode 100644 index 00000000..f72cdc39 --- /dev/null +++ b/NGitLab/Models/IidOrPathAddressable.cs @@ -0,0 +1,11 @@ +#nullable enable + +namespace NGitLab.Models +{ + public interface IidOrPathAddressable + { + internal long Id { get; } + + internal string? Path { get; } + } +} diff --git a/NGitLab/Models/ProjectId.cs b/NGitLab/Models/ProjectId.cs index 65d60510..5ed4027e 100644 --- a/NGitLab/Models/ProjectId.cs +++ b/NGitLab/Models/ProjectId.cs @@ -1,20 +1,29 @@ +using System; + namespace NGitLab.Models { - public record ProjectId : IdOrNamespacedPath + public readonly struct ProjectId : IidOrPathAddressable { + private readonly long _id; + private readonly string _path; + + long IidOrPathAddressable.Id => _id; + + string IidOrPathAddressable.Path => _path; + public ProjectId(long id) - : base(id) { + _id = id; } public ProjectId(string path) - : base(path) { + _path = path ?? throw new ArgumentNullException(nameof(path)); } public ProjectId(Project project) - : base(project.Id) { + _id = project?.Id ?? throw new ArgumentNullException(nameof(project)); } public static implicit operator ProjectId(long id) => new(id); @@ -22,5 +31,7 @@ public ProjectId(Project project) public static implicit operator ProjectId(string path) => new(path); public static implicit operator ProjectId(Project project) => new(project); + + public override string ToString() => this.ValueAsString(); } } diff --git a/NGitLab/PublicAPI.Unshipped.txt b/NGitLab/PublicAPI.Unshipped.txt index edeaf7f2..f3f910f7 100644 --- a/NGitLab/PublicAPI.Unshipped.txt +++ b/NGitLab/PublicAPI.Unshipped.txt @@ -1,4 +1,4 @@ -abstract NGitLab.GitLabCollectionResponse.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerator +abstract NGitLab.GitLabCollectionResponse.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerator abstract NGitLab.GitLabCollectionResponse.GetEnumerator() -> System.Collections.Generic.IEnumerator const NGitLab.Impl.GroupsClient.Url = "/groups" -> string const NGitLab.Impl.LabelClient.GroupLabelUrl = "/groups/{0}/labels" -> string @@ -1753,6 +1753,7 @@ NGitLab.Models.GroupCreate.SharedRunnersMinutesLimit.get -> int? NGitLab.Models.GroupCreate.SharedRunnersMinutesLimit.set -> void NGitLab.Models.GroupCreate.Visibility -> NGitLab.Models.VisibilityLevel NGitLab.Models.GroupId +NGitLab.Models.GroupId.GroupId() -> void NGitLab.Models.GroupId.GroupId(long id) -> void NGitLab.Models.GroupId.GroupId(NGitLab.Models.Group group) -> void NGitLab.Models.GroupId.GroupId(string path) -> void @@ -1850,9 +1851,8 @@ NGitLab.Models.Identity.ExternUid -> string NGitLab.Models.Identity.Identity() -> void NGitLab.Models.Identity.Provider -> string NGitLab.Models.Identity.SamlProviderId -> int? -NGitLab.Models.IdOrNamespacedPath -NGitLab.Models.IdOrNamespacedPath.IdOrNamespacedPath(long id) -> void -NGitLab.Models.IdOrNamespacedPath.IdOrNamespacedPath(string path) -> void +NGitLab.Models.IdOrPathExtensions +NGitLab.Models.IidOrPathAddressable NGitLab.Models.Issue NGitLab.Models.Issue.Assignee -> NGitLab.Models.Assignee NGitLab.Models.Issue.Assignees -> NGitLab.Models.Assignee[] @@ -2741,6 +2741,7 @@ NGitLab.Models.ProjectHookUpsert.TagPushEvents -> bool NGitLab.Models.ProjectHookUpsert.Token -> string NGitLab.Models.ProjectHookUpsert.Url -> System.Uri NGitLab.Models.ProjectId +NGitLab.Models.ProjectId.ProjectId() -> void NGitLab.Models.ProjectId.ProjectId(long id) -> void NGitLab.Models.ProjectId.ProjectId(NGitLab.Models.Project project) -> void NGitLab.Models.ProjectId.ProjectId(string path) -> void @@ -3726,8 +3727,9 @@ override NGitLab.Models.Blame.GetHashCode() -> int override NGitLab.Models.BlameCommit.Equals(object obj) -> bool override NGitLab.Models.BlameCommit.GetHashCode() -> int override NGitLab.Models.Event.ToString() -> string -override NGitLab.Models.IdOrNamespacedPath.ToString() -> string +override NGitLab.Models.GroupId.ToString() -> string override NGitLab.Models.MergeRequest.ToString() -> string +override NGitLab.Models.ProjectId.ToString() -> string override NGitLab.Models.QueryAssigneeId.ToString() -> string override NGitLab.Sha1.Equals(object obj) -> bool override NGitLab.Sha1.GetHashCode() -> int @@ -3743,8 +3745,8 @@ static NGitLab.Models.FileUpsert.Base64Encode(string plainText) -> string static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(long id) -> NGitLab.Models.GroupId static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(NGitLab.Models.Group group) -> NGitLab.Models.GroupId static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(string path) -> NGitLab.Models.GroupId -static NGitLab.Models.IdOrNamespacedPath.implicit operator NGitLab.Models.IdOrNamespacedPath(long id) -> NGitLab.Models.IdOrNamespacedPath -static NGitLab.Models.IdOrNamespacedPath.implicit operator NGitLab.Models.IdOrNamespacedPath(string path) -> NGitLab.Models.IdOrNamespacedPath +static NGitLab.Models.IdOrPathExtensions.ValueAsString(this NGitLab.Models.IidOrPathAddressable idOrPath) -> string +static NGitLab.Models.IdOrPathExtensions.ValueAsUriParameter(this NGitLab.Models.IidOrPathAddressable idOrPath) -> string static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(long id) -> NGitLab.Models.ProjectId static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(NGitLab.Models.Project project) -> NGitLab.Models.ProjectId static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(string path) -> NGitLab.Models.ProjectId From 7fce5388eaac79de327993bdb730b418f17d5a3d Mon Sep 17 00:00:00 2001 From: PM Extra Date: Fri, 3 Nov 2023 22:23:00 +0800 Subject: [PATCH 4/4] Fix typo `IIdOrPathAddressable` --- NGitLab.Mock/Clients/MilestoneClient.cs | 2 +- NGitLab/Impl/MilestoneClient.cs | 2 +- NGitLab/Models/GroupId.cs | 6 +++--- NGitLab/Models/IdOrPathExtensions.cs | 4 ++-- NGitLab/Models/IidOrPathAddressable.cs | 2 +- NGitLab/Models/ProjectId.cs | 6 +++--- NGitLab/PublicAPI.Unshipped.txt | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/NGitLab.Mock/Clients/MilestoneClient.cs b/NGitLab.Mock/Clients/MilestoneClient.cs index 9e944ad1..d8b0cf04 100644 --- a/NGitLab.Mock/Clients/MilestoneClient.cs +++ b/NGitLab.Mock/Clients/MilestoneClient.cs @@ -12,7 +12,7 @@ internal sealed class MilestoneClient : ClientBase, IMilestoneClient { private readonly int _resourceId; - public MilestoneClient(ClientContext context, IidOrPathAddressable id, MilestoneScope scope) + public MilestoneClient(ClientContext context, IIdOrPathAddressable id, MilestoneScope scope) : base(context) { _resourceId = scope switch diff --git a/NGitLab/Impl/MilestoneClient.cs b/NGitLab/Impl/MilestoneClient.cs index 5ae363cf..4a4dcb84 100644 --- a/NGitLab/Impl/MilestoneClient.cs +++ b/NGitLab/Impl/MilestoneClient.cs @@ -12,7 +12,7 @@ public class MilestoneClient : IMilestoneClient private readonly API _api; private readonly string _milestonePath; - internal MilestoneClient(API api, MilestoneScope scope, IidOrPathAddressable id) + internal MilestoneClient(API api, MilestoneScope scope, IIdOrPathAddressable id) { _api = api; _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ValueAsUriParameter()}/milestones"; diff --git a/NGitLab/Models/GroupId.cs b/NGitLab/Models/GroupId.cs index 3af278dc..800daefd 100644 --- a/NGitLab/Models/GroupId.cs +++ b/NGitLab/Models/GroupId.cs @@ -2,14 +2,14 @@ namespace NGitLab.Models { - public readonly struct GroupId : IidOrPathAddressable + public readonly struct GroupId : IIdOrPathAddressable { private readonly long _id; private readonly string _path; - long IidOrPathAddressable.Id => _id; + long IIdOrPathAddressable.Id => _id; - string IidOrPathAddressable.Path => _path; + string IIdOrPathAddressable.Path => _path; public GroupId(long id) { diff --git a/NGitLab/Models/IdOrPathExtensions.cs b/NGitLab/Models/IdOrPathExtensions.cs index 9a1edef0..55fec516 100644 --- a/NGitLab/Models/IdOrPathExtensions.cs +++ b/NGitLab/Models/IdOrPathExtensions.cs @@ -5,10 +5,10 @@ namespace NGitLab.Models { public static class IdOrPathExtensions { - public static string ValueAsString(this IidOrPathAddressable idOrPath) + public static string ValueAsString(this IIdOrPathAddressable idOrPath) => idOrPath.Path ?? idOrPath.Id.ToStringInvariant(); - public static string ValueAsUriParameter(this IidOrPathAddressable idOrPath) + public static string ValueAsUriParameter(this IIdOrPathAddressable idOrPath) => idOrPath.Path is null ? idOrPath.Id.ToStringInvariant() : Uri.EscapeDataString(idOrPath.Path); } } diff --git a/NGitLab/Models/IidOrPathAddressable.cs b/NGitLab/Models/IidOrPathAddressable.cs index f72cdc39..4d5cec8f 100644 --- a/NGitLab/Models/IidOrPathAddressable.cs +++ b/NGitLab/Models/IidOrPathAddressable.cs @@ -2,7 +2,7 @@ namespace NGitLab.Models { - public interface IidOrPathAddressable + public interface IIdOrPathAddressable { internal long Id { get; } diff --git a/NGitLab/Models/ProjectId.cs b/NGitLab/Models/ProjectId.cs index 5ed4027e..61b44443 100644 --- a/NGitLab/Models/ProjectId.cs +++ b/NGitLab/Models/ProjectId.cs @@ -2,14 +2,14 @@ namespace NGitLab.Models { - public readonly struct ProjectId : IidOrPathAddressable + public readonly struct ProjectId : IIdOrPathAddressable { private readonly long _id; private readonly string _path; - long IidOrPathAddressable.Id => _id; + long IIdOrPathAddressable.Id => _id; - string IidOrPathAddressable.Path => _path; + string IIdOrPathAddressable.Path => _path; public ProjectId(long id) { diff --git a/NGitLab/PublicAPI.Unshipped.txt b/NGitLab/PublicAPI.Unshipped.txt index 08d9a55d..367915e9 100644 --- a/NGitLab/PublicAPI.Unshipped.txt +++ b/NGitLab/PublicAPI.Unshipped.txt @@ -1854,7 +1854,7 @@ NGitLab.Models.Identity.Identity() -> void NGitLab.Models.Identity.Provider -> string NGitLab.Models.Identity.SamlProviderId -> int? NGitLab.Models.IdOrPathExtensions -NGitLab.Models.IidOrPathAddressable +NGitLab.Models.IIdOrPathAddressable NGitLab.Models.Issue NGitLab.Models.Issue.Assignee -> NGitLab.Models.Assignee NGitLab.Models.Issue.Assignees -> NGitLab.Models.Assignee[] @@ -3747,8 +3747,8 @@ static NGitLab.Models.FileUpsert.Base64Encode(string plainText) -> string static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(long id) -> NGitLab.Models.GroupId static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(NGitLab.Models.Group group) -> NGitLab.Models.GroupId static NGitLab.Models.GroupId.implicit operator NGitLab.Models.GroupId(string path) -> NGitLab.Models.GroupId -static NGitLab.Models.IdOrPathExtensions.ValueAsString(this NGitLab.Models.IidOrPathAddressable idOrPath) -> string -static NGitLab.Models.IdOrPathExtensions.ValueAsUriParameter(this NGitLab.Models.IidOrPathAddressable idOrPath) -> string +static NGitLab.Models.IdOrPathExtensions.ValueAsString(this NGitLab.Models.IIdOrPathAddressable idOrPath) -> string +static NGitLab.Models.IdOrPathExtensions.ValueAsUriParameter(this NGitLab.Models.IIdOrPathAddressable idOrPath) -> string static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(long id) -> NGitLab.Models.ProjectId static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(NGitLab.Models.Project project) -> NGitLab.Models.ProjectId static NGitLab.Models.ProjectId.implicit operator NGitLab.Models.ProjectId(string path) -> NGitLab.Models.ProjectId