public async Task <IEnumerable <Comment> > GetPullRequestComments(string repositoryName, string ownerName, long id)
        {
            var url     = ApiUrls.PullRequestCommentsV1(ownerName, repositoryName, id);
            var request = new YouTrackRestRequest(url, Method.GET);

            return((await _versionOneClient.ExecuteTaskAsync <List <CommentV1> >(request)).Data.MapTo <List <Comment> >());
        }
        public async Task <IteratorBasedPage <PullRequest> > GetPullRequestsPage(string repositoryName, string ownerName, int page, int limit = 50,
                                                                                 IPullRequestQueryBuilder builder = null)
        {
            var url     = EnterpriseApiUrls.PullRequests(ownerName, repositoryName);
            var request = new YouTrackRestRequest(url, Method.GET);

            if (builder != null)
            {
                foreach (var param in builder.GetQueryParameters())
                {
                    request.AddQueryParameter(param.Key, param.Value);
                }
            }


            request.AddQueryParameter("limit", limit.ToString()).AddQueryParameter("start", ((page - 1) * limit).ToString());

            var res = (await RestClient.ExecuteTaskAsync <EnterpriseIteratorBasedPage <EnterprisePullRequest> >(request)).Data;

            return(new IteratorBasedPage <PullRequest>()
            {
                Values = res.Values.MapTo <List <PullRequest> >(),
                Size = res.Size,
                Next = res.NextPageStart.ToString(),
            });
        }
        /// <summary>
        /// Updates a user.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/POST-User.html">Update a user</a>.</remarks>
        /// <param name="username">Login name of the user to be updated.</param>
        /// <param name="fullName">Full name of a user.</param>
        /// <param name="email">E-mail address of the user.</param>
        /// <param name="jabber">Jabber address for the user.</param>
        /// <param name="password">Password for the user.</param>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task UpdateUser(string username, string fullName = null, string email = null, string jabber = null, string password = null)
        {
            var queryString = new Dictionary <string, string>(4);

            if (!string.IsNullOrEmpty(fullName))
            {
                queryString.Add("fullName", WebUtility.UrlEncode(fullName));
            }
            if (!string.IsNullOrEmpty(email))
            {
                queryString.Add("email", WebUtility.UrlEncode(email));
            }
            if (!string.IsNullOrEmpty(jabber))
            {
                queryString.Add("jabber", WebUtility.UrlEncode(jabber));
            }
            if (!string.IsNullOrEmpty(password))
            {
                queryString.Add("password", WebUtility.UrlEncode(password));
            }


            var url     = UsersUrls.GetUser(username);
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(new FormUrlEncodedContent(queryString)), ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync(request);
        }
        /// <summary>
        /// Attaches a file to an issue on the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Attach-File-to-an-Issue.html">Attach File to an Issue</a>.</remarks>
        /// <param name="issueId">Id of the issue to attach the file to.</param>
        /// <param name="attachmentName">Filename for the attachment.</param>
        /// <param name="attachmentStream">The <see cref="T:System.IO.Stream"/> to attach.</param>
        /// <param name="group">Attachment visibility group.</param>
        /// <param name="author">Creator of the attachment. Note to define author the 'Low-Level Administration' permission is required.</param>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/>, <paramref name="attachmentName"/> or <paramref name="attachmentStream"/> is null or empty.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task AttachFileToIssue(string issueId, IAttachFileQueryBuilder builder, Stream attachmentStream)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            if (attachmentStream == null)
            {
                throw new ArgumentNullException(nameof(attachmentStream));
            }

            var url     = IssuesUrls.AttachFileToIssue(issueId);
            var request = new YouTrackRestRequest(url, Method.POST);

            if (builder != null)
            {
                foreach (var param in builder.GetQueryParameters())
                {
                    request.AddQueryParameter(param.Key, param.Value);
                }
            }

            request.AddHeader("Content-Type", "multipart/form-data");


            var streamContent = new StreamContent(attachmentStream);

            streamContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
            {
                FileName = builder.GetAttachmentName(),
                Name     = builder.GetAttachmentName()
            };

            var content = new MultipartFormDataContent
            {
                streamContent
            };

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(content),
                                 ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync(request);

            //var response = await client.PostAsync($"rest/issue/{issueId}/attachment?{query}", content);

            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                //TODO THE
                // Try reading the error message
                //var responseJson = JObject.Parse(await response.Content.ReadAsStringAsync());
                //if (responseJson["value"] != null)
                //{
                //    throw new YouTrackErrorException(responseJson["value"].Value<string>());
                //}
                //else
                //{
                //    throw new YouTrackErrorException(Strings.Exception_UnknownError);
                //}
            }
        }
        /// <summary>
        /// Updates an issue on the server in a specific project.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Update-an-Issue.html">Update an Issue</a>.</remarks>
        /// <param name="issueId">Id of the issue to update.</param>
        /// <param name="summary">Updated summary of the issue.</param>
        /// <param name="description">Updated description of the issue.</param>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> is null or empty.</exception>
        /// <exception cref="T:YouTrackErrorException">When the call to the remote YouTrack server instance failed and YouTrack reported an error message.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task UpdateIssue(string issueId, string summary = null, string description = null)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            if (summary == null && description == null)
            {
                return;
            }

            var url     = IssuesUrls.UpdateIssue(issueId);
            var request = new YouTrackRestRequest(url, Method.POST);

            if (!string.IsNullOrEmpty(summary))
            {
                request.AddQueryParameter("summary", WebUtility.UrlEncode(summary));
            }

            if (!string.IsNullOrEmpty(description))
            {
                request.AddQueryParameter("description", WebUtility.UrlEncode(description));
            }

            request.AddHeader("Content-Type", "multipart/form-data");
            var response = await RestClient.ExecuteTaskAsync(request);
        }
        private async Task <string> GetAllLines(string url) //todo temporary for test
        {
            var result = new EnterpriseBrowsePage()
            {
                Lines = new List <EnterpriseBrowseText>()
            };
            IRestResponse <EnterpriseBrowsePage> response;
            ulong pageNumber = 0;

            do
            {
                var request = new YouTrackRestRequest(url, Method.GET);
                request.AddQueryParameter("start", pageNumber.ToString());

                response = await RestClient.ExecuteTaskAsync <EnterpriseBrowsePage>(request);

                if (response.Data?.Lines == null)
                {
                    break;
                }

                result.Lines.AddRange(response.Data.Lines);

                pageNumber += response.Data.Size.Value;
            } while (response.Data?.IsLastPage == false);

            return(string.Join(Environment.NewLine, result.Lines.Select(x => x.Text)));
        }
        public async Task <IEnumerable <Repository> > GetUserRepositoriesV1()
        {
            var repositories = new List <Repository>();
            var url          = ApiUrls.RepositoriesV1();
            var request      = new YouTrackRestRequest(url, Method.GET);
            var response     = await _versionOneClient.ExecuteTaskAsync <List <RepositoryV1> >(request);

            if (response.Data != null)
            {
                foreach (var repositoryV1 in response.Data)
                {
                    var repo = repositoryV1.MapTo <Repository>();
                    repo.Links = new Links
                    {
                        Clone =
                            new List <Link>()
                        {
                            new Link()
                            {
                                Href = $"{Connection.MainUrl.Scheme}://{Connection.Credentials.Login}@{Connection.MainUrl.Host}/{repositoryV1.Owner}/{repositoryV1.Slug}.git"
                            }
                        }
                    };
                    repositories.Add(repo);
                }
            }


            return(repositories);
        }
        public async Task <Comment> AddPullRequestComment(string repositoryName, string ownerName, long id, string content, long?lineFrom = null, long?lineTo = null, string fileName = null, long?parentId = null)
        {
            var url     = EnterpriseApiUrls.PullRequestComments(ownerName, repositoryName, id);
            var request = new YouTrackRestRequest(url, Method.POST);


            var body = new EnterpriseComment()
            {
                Text   = content,
                Parent = parentId.HasValue ? new EnterpriseParent()
                {
                    Id = parentId.Value
                } : null,
                Anchor = fileName != null
                    ? new EnterpriseAnchor()
                {
                    Line       = lineFrom ?? lineTo,
                    FileType   = lineFrom != null && lineTo != null ? (FileDiffType?)null : lineFrom != null ? FileDiffType.From : FileDiffType.To,
                    Path       = fileName,
                    SourcePath = fileName,
                    LineType   = lineFrom != null && lineTo != null ? "CONTEXT" : lineFrom != null ? "REMOVED" : "ADDED",
                } : null
            };

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(body), ParameterType.RequestBody);

            var response = await RestClient.ExecuteTaskAsync <EnterpriseComment>(request);

            return(response.Data.MapTo <Comment>());
        }
        /// <summary>
        /// Updates a comment for an issue on the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Update-a-Comment.html">Update a Comment</a>.</remarks>
        /// <param name="issueId">Id of the issue to which the comment belongs.</param>
        /// <param name="commentId">Id of the comment to update.</param>
        /// <param name="text">The new text of the comment.</param>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/>, <paramref name="commentId"/> or <paramref name="text"/> is null or empty.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task UpdateCommentForIssue(string issueId, string commentId, string text)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            if (string.IsNullOrEmpty(commentId))
            {
                throw new ArgumentNullException(nameof(commentId));
            }

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            var myText  = new SimpleText(text);
            var url     = IssuesUrls.UpdateCommentForIssue(issueId, commentId);
            var request = new YouTrackRestRequest(url, Method.PUT);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(myText),
                                 ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync <PullRequest>(request);
        }
        public async Task <Comment> AddPullRequestComment(string repositoryName, string ownerName, long id, string content, long?lineFrom = null, long?lineTo = null, string fileName = null, long?parentId = null)
        {
            var url     = ApiUrls.PullRequestCommentsV1(ownerName, repositoryName, id);
            var request = new YouTrackRestRequest(url, Method.POST);

            var body = new CommentV1()
            {
                Content  = content,
                LineFrom = parentId != null ? null : lineFrom,
                LineTo   = parentId != null ? null : lineTo,
                FileName = fileName,
                ParentId = parentId
            };

            if (body.LineFrom != null)//we can't set both
            {
                body.LineTo = null;
            }

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(body), ParameterType.RequestBody);

            var response = await _versionOneClient.ExecuteTaskAsync <CommentV1>(request);

            return(response.Data.MapTo <Comment>());
        }
        public async Task <PullRequest> GetPullRequest(string repositoryName, string owner, long id)
        {
            var url         = EnterpriseApiUrls.PullRequest(owner, repositoryName, id);
            var request     = new YouTrackRestRequest(url, Method.GET);
            var pullRequest = await RestClient.ExecuteTaskAsync <EnterprisePullRequest>(request);

            return(pullRequest.Data.MapTo <PullRequest>());
        }
        public async Task <IEnumerable <FileDiff> > GetPullRequestDiff(string repositoryName, string owner, long id)
        {
            var url      = ApiUrls.PullRequestDiff(owner, repositoryName, id);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync(request);

            return(DiffFileParser.Parse(response.Content));
        }
        public async Task <PullRequest> GetPullRequest(string repositoryName, string owner, long id)
        {
            var url      = ApiUrls.PullRequest(owner, repositoryName, id);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync <PullRequest>(request);

            return(response.Data);
        }
        /// <summary>
        /// Get all groups the specified user participates in.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/GET-User-Groups.html">Get all groups the specified user participates in</a>.</remarks>
        /// <param name="username">Login name of the user to retrieve information for.</param>
        /// <returns>A <see cref="T:System.Collections.Generic.ICollection`1" /> of <see cref="Group" /> instances.</returns>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <ICollection <Group> > GetGroupsForUser(string username)
        {
            var url      = UsersUrls.GetGroupsForUser(username);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync <List <Group> >(request);

            return(response.Data);
        }
        public async Task MergePullRequest(string repositoryName, string ownerName, MergeRequest mergeRequest)
        {
            var url     = ApiUrls.PullRequestMerge(ownerName, repositoryName, mergeRequest.Id);
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(mergeRequest), ParameterType.RequestBody);
            await RestClient.ExecuteTaskAsync(request);
        }
        private async Task <DefaultBranch> DefaultBranch(string repoName, string owner)
        {
            var url      = ApiUrls.DefaultBranch(owner, repoName);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await _versionOneClient.ExecuteTaskAsync <DefaultBranch>(request);

            return(response.Data);
        }
        /// <summary>
        /// Add user to group.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/POST-User-Group.html">Add user account to a group</a>.</remarks>
        /// <param name="username">Login name of the user to be updated.</param>
        /// <param name="group">Name of the group to add the user to.</param>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task AddUserToGroup(string username, string group)
        {
            var url     = $"rest/admin/user/{username}/group/{WebUtility.UrlEncode(group)}";
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(new StringContent(string.Empty)), ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync(request);
        }
        public async Task <string> GetFileContent(string repoName, string owner, string hash, string path)
        {
            var url      = ApiUrls.DownloadFile(owner, repoName, hash, path);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await _versionOneClient.ExecuteTaskAsync(request);

            return(response.Content);
        }
        /// <summary>
        /// Merge users.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Merge-Users.html">Delete a user</a>.</remarks>
        /// <param name="usernameToMerge">Login name of the user to be merged.</param>
        /// <param name="targetUser">Login name of the user to merge <paramref name="usernameToMerge"/> into.</param>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task MergeUsers(string usernameToMerge, string targetUser)
        {
            var url     = $"/admin/user/{targetUser}/merge/{usernameToMerge}";
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(new StringContent(string.Empty)), ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync(request);
        }
        public async Task <Participant> ApprovePullRequest(string repositoryName, string ownerName, long id)
        {
            var url      = EnterpriseApiUrls.PullRequestApprove(ownerName, repositoryName, id);
            var request  = new YouTrackRestRequest(url, Method.POST);
            var response = await RestClient.ExecuteTaskAsync <EnterpriseParticipant>(request);

            return(response.Data.MapTo <Participant>());
        }
Exemplo n.º 21
0
        public async Task <Commit> GetCommitById(string repoName, string owner, string id)
        {
            var url      = EnterpriseApiUrls.Commit(owner, repoName, id);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync <EnterpriseCommit>(request);

            return(response.Data.MapTo <Commit>());
        }
        /// <summary>
        /// Get a list of all accessible projects from the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Accessible-Projects.html">Get Accessible Projects</a>.</remarks>
        /// <param name="verbose">If full representation of projects is returned. If this parameter is false, only short names and id's are returned.</param>
        /// <returns>A <see cref="T:System.Collections.Generic.ICollection`1" /> of <see cref="Project" /> that are accessible for currently logged in user.</returns>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <ICollection <Project> > GetAccessibleProjects(bool verbose = false)
        {
            var url = ProjectsUrls.AccessibleProjects(verbose);

            var request = new YouTrackRestRequest(url, Method.GET);

            var response = await RestClient.ExecuteTaskAsync <List <Project> >(request);

            return(response.Data);
        }
        /// <summary>
        /// Get info about currently logged in user.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Info-For-Current-User.html">Get Info For Current User</a>.</remarks>
        /// <returns>A <see cref="User" /> instance that represents the currently logged in user.</returns>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <User> GetCurrentUserInfo()
        {
            var url = UserUrls.CurrentUserInfo();

            var request = new YouTrackRestRequest(url, Method.GET);

            var response = await RestClient.ExecuteTaskAsync <User>(request);

            return(response.Data);
        }
        public async Task <Repository> CreateRepository(Repository repository)
        {
            var url     = ApiUrls.Repository(Connection.Credentials.Login, repository.Name);
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(repository), ParameterType.RequestBody);
            var response = await RestClient.ExecuteTaskAsync <Repository>(request);

            return(response.Data);
        }
        public async Task <IEnumerable <FileDiff> > GetPullRequestDiff(string repositoryName, string owner, long id)
        {
            var url     = EnterpriseApiUrls.PullRequestDiff(owner, repositoryName, id);
            var request = new YouTrackRestRequest(url, Method.GET);

            var response = await RestClient.ExecuteTaskAsync <EnterpriseDiffResponse>(request);

            var fileDiffs = ParseFileDiffs(response);

            return(fileDiffs);
        }
        /// <summary>
        /// Applies a command to a specific issue on the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Apply-Command-to-an-Issue.html">Apply Command to an Issue</a>.</remarks>
        /// <param name="issueId">Id of the issue to apply the command to.</param>
        /// <param name="command">The command to apply. A command might contain a string of attributes and their values - you can change multiple fields with one complex command.</param>
        /// <param name="comment">A comment to add to an issue.</param>
        /// <param name="disableNotifications">When <value>true</value>, no notifications about changes made with the specified command will be sent. Defaults to <value>false</value>.</param>
        /// <param name="runAs">Login name for a user on whose behalf the command should be applied.</param>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> or <paramref name="command"/> is null or empty.</exception>
        /// <exception cref="T:YouTrackErrorException">When the call to the remote YouTrack server instance failed and YouTrack reported an error message.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task ApplyCommand(string issueId, string command, string comment = null,
                                       bool disableNotifications = false, string runAs = null)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            if (string.IsNullOrEmpty(command))
            {
                throw new ArgumentNullException(nameof(command));
            }

            var url     = IssuesUrls.ApplyCommand(issueId);
            var request = new YouTrackRestRequest(url, Method.POST);


            request.AddQueryParameter("command", WebUtility.UrlEncode(command));

            if (!string.IsNullOrEmpty(comment))
            {
                request.AddQueryParameter("comment", WebUtility.UrlEncode(comment));
            }

            if (disableNotifications)
            {
                request.AddQueryParameter("disableNotifications", WebUtility.UrlEncode("true"));
            }

            if (!string.IsNullOrEmpty(runAs))
            {
                request.AddQueryParameter("runAs", WebUtility.UrlEncode(runAs));
            }


            request.AddHeader("Content-Type", "multipart/form-data");
            var response = await RestClient.ExecuteTaskAsync(request);

            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                //TODO THE implement that.
                // Try reading the error message
                //var responseJson = response.
                //if (responseJson["value"] != null)
                //{
                //    throw new YouTrackErrorException(responseJson["value"].Value<string>());
                //}
                //else
                //{
                //    throw new YouTrackErrorException(Strings.Exception_UnknownError);
                //}
            }
        }
        public async Task CreatePullRequest(PullRequest pullRequest, string repositoryName, string owner)
        {
            //pullRequest.Author = new User()
            //{
            //    Username = Connection.Credentials.Login
            //};
            var url     = EnterpriseApiUrls.PullRequests(owner, repositoryName);
            var request = new YouTrackRestRequest(url, Method.POST);

            request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(pullRequest.MapTo <EnterprisePullRequest>()), ParameterType.RequestBody);
            await RestClient.ExecuteTaskAsync(request);
        }
        /// <summary>
        /// Get a specific issue from the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-an-Issue.html">Get an Issue</a>.</remarks>
        /// <param name="issueId">Id of an issue to get.</param>
        /// <param name="wikifyDescription">If set to <value>true</value>, then issue description in the response will be formatted ("wikified"). Defaults to <value>false</value>.</param>
        /// <returns>The <see cref="Issue" /> that matches the requested <paramref name="issueId"/>.</returns>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> is null or empty.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <Issue> GetIssue(string issueId, bool wikifyDescription = false)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            var url      = IssuesUrls.GetIssue(issueId, wikifyDescription);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync <Issue>(request);

            return(response.Data);
        }
        /// <summary>
        /// Get links for a specific issue from the server.
        /// </summary>
        /// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Links-of-an-Issue.html">Get Links of an Issue</a>.</remarks>
        /// <param name="issueId">Id of the issue to get links for.</param>
        /// <returns>An <see cref="T:System.Collections.Generic.IEnumerable`1" /> of <see cref="Link" /> for the requested issue <paramref name="issueId"/>.</returns>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> is null or empty.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <IEnumerable <Link> > GetLinksForIssue(string issueId)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException(nameof(issueId));
            }

            var url      = IssuesUrls.GetLinksForIssue(issueId);
            var request  = new YouTrackRestRequest(url, Method.GET);
            var response = await RestClient.ExecuteTaskAsync <List <Link> >(request);

            return(response.Data);
        }
        /// <summary>
        /// Downloads an attachment from the server.
        /// </summary>
        /// <param name="attachmentUrl">The <see cref="T:System.Uri" /> of the attachment.</param>
        /// <returns>A <see cref="T:System.IO.Stream" /> containing the attachment data.</returns>
        /// <exception cref="T:System.ArgumentNullException">When the <paramref name="attachmentUrl"/> is null.</exception>
        /// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
        public async Task <Stream> DownloadAttachment(Uri attachmentUrl)
        {
            if (attachmentUrl == null)
            {
                throw new ArgumentNullException(nameof(attachmentUrl));
            }


            var request  = new YouTrackRestRequest(attachmentUrl.ToString(), Method.GET);
            var response = await RestClient.ExecuteTaskAsync <Stream>(request);

            return(response.Data);
        }