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..f45d36e4 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..c5acccbf 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..d124b2ee 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..593e2b1b 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..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, int? projectId = null) + public EventClient(ClientContext context, int? userId = null, ProjectId? projectId = null) : base(context) { _userId = userId; - _projectId = projectId; + _projectId = projectId.HasValue ? Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id : null; } 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..89a426bd 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..b9742dba 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..b681a38c 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..ca4e5b76 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 c06a397e..33d7abf4 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..d8b0cf04 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, IIdOrPathAddressable 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..68a0e517 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..101a6c93 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..dd9e7a57 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..c8b50c6a 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..8eea7e93 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..082f6432 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..66d4761f 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..c26595f3 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..2e07eb19 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..054631e9 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..10d3bd66 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..9fd164fa 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..a74293ed 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..3ab98bfa 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..7f18360e 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..22c517b8 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..0cc11340 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..58ef94a5 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..473b4a2d 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 fab19d07..d8796266 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..4a4dcb84 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, int id) + internal MilestoneClient(API api, MilestoneScope scope, IIdOrPathAddressable id) { _api = api; - _milestonePath = $"/{scope.ToString().ToLowerInvariant()}/{id.ToStringInvariant()}/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 6f9305ac..31ba7d7a 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..2712d88c 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..1ac9c255 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..e8a747da 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..a896ec12 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..e6cc5263 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..32572cbf 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..aa615a1e 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..e868fc1a 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..441f6c85 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..800daefd --- /dev/null +++ b/NGitLab/Models/GroupId.cs @@ -0,0 +1,37 @@ +using System; + +namespace NGitLab.Models +{ + 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) + { + _id = id; + } + + public GroupId(string path) + { + _path = path ?? throw new ArgumentNullException(nameof(path)); + } + + public GroupId(Group group) + { + _id = group?.Id ?? throw new ArgumentNullException(nameof(group)); + } + + 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); + + public override string ToString() => this.ValueAsString(); + } +} diff --git a/NGitLab/Models/IdOrPathExtensions.cs b/NGitLab/Models/IdOrPathExtensions.cs new file mode 100644 index 00000000..55fec516 --- /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..4d5cec8f --- /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 new file mode 100644 index 00000000..61b44443 --- /dev/null +++ b/NGitLab/Models/ProjectId.cs @@ -0,0 +1,37 @@ +using System; + +namespace NGitLab.Models +{ + 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) + { + _id = id; + } + + public ProjectId(string path) + { + _path = path ?? throw new ArgumentNullException(nameof(path)); + } + + public ProjectId(Project project) + { + _id = project?.Id ?? throw new ArgumentNullException(nameof(project)); + } + + 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); + + public override string ToString() => this.ValueAsString(); + } +} diff --git a/NGitLab/PublicAPI.Unshipped.txt b/NGitLab/PublicAPI.Unshipped.txt index 5ff74a54..367915e9 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 @@ -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 @@ -413,9 +459,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 @@ -424,6 +472,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 @@ -440,6 +489,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 @@ -550,6 +600,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 @@ -615,6 +666,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 @@ -695,6 +747,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 @@ -735,11 +788,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 @@ -759,6 +814,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 @@ -815,6 +871,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 @@ -844,6 +901,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 @@ -1696,6 +1754,11 @@ 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() -> void +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 @@ -1790,6 +1853,8 @@ NGitLab.Models.Identity.ExternUid -> string NGitLab.Models.Identity.Identity() -> void NGitLab.Models.Identity.Provider -> string NGitLab.Models.Identity.SamlProviderId -> int? +NGitLab.Models.IdOrPathExtensions +NGitLab.Models.IIdOrPathAddressable NGitLab.Models.Issue NGitLab.Models.Issue.Assignee -> NGitLab.Models.Assignee NGitLab.Models.Issue.Assignees -> NGitLab.Models.Assignee[] @@ -2677,6 +2742,11 @@ 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() -> void +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 @@ -3659,7 +3729,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.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 @@ -3672,6 +3744,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.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 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