internal Task DeleteNoteAsync(MergeRequestKey mrk, int noteId) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Notes.Get(noteId).DeleteTaskAsync())))); }
internal Task <IEnumerable <Project> > GetProjects() { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (IEnumerable <Project>) await client.RunAsync( async(gl) => await gl.Projects.LoadAllTaskAsync( new GitLabSharp.Accessors.ProjectsFilter(false, true, true)))))); }
internal Task <Discussion> GetDiscussionAsync(MergeRequestKey mrk, string discussionId) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (Discussion)(await client.RunAsync( async(gitlab) => await gitlab.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.Get(discussionId).LoadTaskAsync()))))); }
internal Task <MergeRequestRebaseResponse> RebaseMergeRequest(MergeRequestKey mrk, bool?skipCI) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (MergeRequestRebaseResponse)(await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId) .RebaseMergeRequestTaskAsync(skipCI)))))); }
internal Task CreateNoteAsync(MergeRequestKey mrk, CreateNewNoteParameters parameters) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Notes.CreateNewTaskAsync(parameters))))); }
internal Task <IEnumerable <Discussion> > GetDiscussionsAsync(MergeRequestKey mrk) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (IEnumerable <Discussion>)(await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.LoadAllTaskAsync()))))); }
internal Task AddSpanAsync(bool add, TimeSpan span, MergeRequestKey mrk) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).AddSpentTimeAsync( new AddSpentTimeParameters(add, span)))))); }
internal Task <MergeRequest> AcceptMergeRequest(MergeRequestKey mrk, AcceptMergeRequestParameters parameters) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (MergeRequest)(await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId) .AcceptMergeRequestTaskAsync(parameters)))))); }
internal Task <Discussion> ResolveDiscussionAsync(MergeRequestKey mrk, string discussionId, bool resolve) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (Discussion)await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.Get(discussionId).ResolveTaskAsync( new ResolveThreadParameters(resolve)))))); }
internal Task ReplyAsync(MergeRequestKey mrk, string discussionId, string body) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.Get(discussionId).CreateNewNoteTaskAsync( new CreateNewNoteParameters(body)))))); }
internal Task ResolveNoteAsync(MergeRequestKey mrk, string discussionId, int noteId, bool resolve) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.Get(discussionId).ModifyNoteTaskAsync(noteId, new ModifyDiscussionNoteParameters( ModifyDiscussionNoteParameters.ModificationType.Resolved, null, resolve)))))); }
internal Task <IEnumerable <Commit> > GetCommitsAsync(string projectName, int iid) { // If MaxCommitsToLoad exceeds 100, need to call LoadAllTaskAsync() w/o PageFilter Debug.Assert(Constants.MaxCommitsToLoad <= 100); return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (IEnumerable <Commit>) await client.RunAsync( async(gl) => await gl.Projects.Get(projectName).MergeRequests.Get(iid).Commits.LoadTaskAsync( new GitLabSharp.Accessors.PageFilter(Constants.MaxCommitsToLoad, 1)))))); }
internal Task <DiscussionNote> ModifyNoteBodyAsync(MergeRequestKey mrk, string discussionId, int noteId, string body) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (DiscussionNote)await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Discussions.Get(discussionId).ModifyNoteTaskAsync(noteId, new ModifyDiscussionNoteParameters( ModifyDiscussionNoteParameters.ModificationType.Body, body, false)))))); }
internal Task <Tuple <Note, int> > GetMostRecentUpdatedNoteAndCountAsync(MergeRequestKey mrk) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => { Tuple <IEnumerable <Note>, int> notesAndCount = (Tuple <IEnumerable <Note>, int>)(await client.RunAsync( async(gl) => await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId). Notes.LoadAndCalculateTotalCountAsync(new PageFilter(1, 1), new SortFilter(false, "updated_at")))); return new Tuple <Note, int>(notesAndCount.Item1.FirstOrDefault(), notesAndCount.Item2); }))); }
async internal Task <User> SearchUserByNameAsync(string name) { IEnumerable <User> users = await callWithSharedClient( async (client) => await OperatorCallWrapper.Call( async() => (IEnumerable <User>) await client.RunAsync( async(gl) => await gl.Users.SearchTaskAsync(name)))); if (!users.Any()) { return(null); } return(users.First()); }
async internal static Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync( GitLabTaskRunner client, SearchCriteria searchCriteria, int?maxResults, bool onlyOpen) { List <MergeRequest> mergeRequests = new List <MergeRequest>(); foreach (object search in searchCriteria.Criteria) { mergeRequests.AddRange( await OperatorCallWrapper.Call( async() => (IEnumerable <MergeRequest>)(await client.RunAsync( async(gl) => await MergeRequestSearchProcessorFactory.Create(search, onlyOpen).Process(gl, maxResults))))); } return(mergeRequests); }
async internal Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync( SearchCriteria searchCriteria, int?maxResults, bool onlyOpen) { List <MergeRequest> mergeRequests = new List <MergeRequest>(); foreach (object search in searchCriteria.Criteria) { mergeRequests.AddRange( await callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await CommonOperator.SearchMergeRequestsAsync(client, searchCriteria, maxResults, onlyOpen)))); } return(mergeRequests); }
internal Task <Commit> GetCommitAsync(string projectName, string id) { // TODO Add ability to store free commits in GlobalCache Commit cachedCommit = GlobalCache.GetCommit(new ProjectKey(Hostname, projectName), id); if (cachedCommit != null) { return(Task.FromResult(cachedCommit)); } return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (Commit)await client.RunAsync( async(gl) => await gl.Projects.Get(projectName).Repository.Commits.Get(id).LoadTaskAsync())))); }
internal Task ReplyAndResolveDiscussionAsync(MergeRequestKey mrk, string discussionId, string body, bool resolve) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => await client.RunAsync( async(gl) => { GitLabSharp.Accessors.SingleProjectAccessor projectAccessor = gl.Projects.Get(mrk.ProjectKey.ProjectName); GitLabSharp.Accessors.SingleMergeRequestAccessor mrAccessor = projectAccessor.MergeRequests.Get(mrk.IId); GitLabSharp.Accessors.SingleDiscussionAccessor accessor = mrAccessor.Discussions.Get(discussionId); await accessor.CreateNewNoteTaskAsync(new CreateNewNoteParameters(body)); await accessor.ResolveTaskAsync(new ResolveThreadParameters(resolve)); return true; })))); }
async internal Task <User> SearchUserByUsernameAsync(string username) { User user = GlobalCache.GetUser(Hostname, username); if (user == null) { var users = await callWithSharedClient( async (client) => await OperatorCallWrapper.Call( async() => (IEnumerable <User>) await client.RunAsync( async(gl) => await gl.Users.SearchByUsernameTaskAsync(username)))); if (!users.Any()) { return(null); } user = users.First(); GlobalCache.AddUser(Hostname, user); } return(user); }