예제 #1
0
 /// <summary>
 /// Add a custom field to an IssueEdit
 /// </summary>
 /// <typeparam name="TCustomField">type for the custom field</typeparam>
 /// <param name="issueToEdit">IssueEdit to add a custom field with value to</param>
 /// <param name="customFieldName">string with the name of the custom field</param>
 /// <param name="customFieldValue">TCustomField with the value</param>
 /// <returns>IssueEdit for a fluent usage</returns>
 public static IssueEdit AddCustomField <TCustomField>(this IssueEdit issueToEdit, string customFieldName, TCustomField customFieldValue)
 {
     // Make sure that IssueFields is available
     issueToEdit.Fields ??= new IssueFields();
     issueToEdit.Fields.CustomFields.Add(customFieldName, customFieldValue);
     return(issueToEdit);
 }
예제 #2
0
        /// <summary>
        ///     Change the state of the issue (make a transition)
        /// </summary>
        /// <param name="jiraClient">IIssueDomain to bind the extension method to</param>
        /// <param name="issueKey">string with the key for the issue to update</param>
        /// <param name="transition">Transition</param>
        /// <param name="cancellationToken">CancellationToken</param>
        public static Task TransitionAsync(this IIssueDomain jiraClient, string issueKey, Transition transition, CancellationToken cancellationToken = default)
        {
            var issueEdit = new IssueEdit
            {
                Transition = transition
            };

            return(TransitionAsync(jiraClient, issueKey, issueEdit, cancellationToken));
        }
예제 #3
0
 public async Task Test_EditIssue()
 {
     var updateIssue = new IssueEdit
     {
         Fields = new IssueFields
         {
             Description = "Test run at " + DateTime.Now.ToLocalTime()
         }
     };
     await Client.Issue.EditAsync(TestIssueKey, updateIssue);
 }
예제 #4
0
        public static void Main()
        {
            // Settings needed to connect and use the Regular Service.
            string user     = ConfigurationManager.AppSettings["User"];
            string password = ConfigurationManager.AppSettings["Password"];
            string serviceEndpointAddress = ConfigurationManager.AppSettings["ServiceEndpointAddress"];

            // Creation of a channel connected to the Regular Service.
            var endpoint = new EndpointAddress(serviceEndpointAddress);
            var binding  = new BasicHttpBinding();
            ChannelFactory <IGitHubSoapService> channelFactory = new ChannelFactory <IGitHubSoapService>(binding, endpoint);

            channelFactory.Endpoint.Behaviors.Add(new AuthenticationHeaderBehavior());
            var serviceChannel = channelFactory.CreateChannel();

            // Create a new repository.
            var newRepo = new RepoCreate
            {
                name          = "Test-Repository",
                description   = "Just a test repository",
                has_downloads = true,
                has_issues    = true,
                has_wiki      = false,
                @private      = false
            };

            var createdRepo = serviceChannel.CreateRepo(user, password, newRepo);

            // Get the created repository.
            var repo = serviceChannel.GetRepo(user, "Test-Repository");

            // Edit the repository.
            var editRepo = new RepoEdit {
                has_downloads = false, name = "Test-Repository"
            };

            serviceChannel.EditRepo(user, password, "Test-Repository", editRepo);

            // Create an issue in the created repository.
            var newIssue = new IssueCreate {
                title = "Found a bug", body = "I'm having a problem with this.", assignee = "luismdcp"
            };
            var createdIssue = serviceChannel.CreateIssue(user, password, "Test-Repository", newIssue);

            // Edit the created issue.
            var editIssue = new IssueEdit {
                milestone = 1
            };

            serviceChannel.EditIssue(user, password, "Test-Repository", createdIssue.id, editIssue);
        }
        public Issue Edit(string user, string password, string repo, int id, IssueEdit editIssue)
        {
            var client  = new HttpClient();
            var uri     = String.Format("https://api.github.com/repos/{0}/{1}/issues/{2}", user, repo, id);
            var request = new HttpRequestMessage <IssueEdit>(editIssue,
                                                             new HttpMethod("PATCH"),
                                                             new Uri(uri),
                                                             new List <MediaTypeFormatter> {
                new JsonMediaTypeFormatter()
            });

            request.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/json");
            client.DefaultRequestHeaders.Authorization = CreateBasicAuthentication(user, password);
            var response = client.SendAsync(request).Result;
            var result   = response.Content.ReadAsAsync <Issue>().Result;

            return(result);
        }
예제 #6
0
 public Issue Edit(string user, string password, string repo, int id, IssueEdit editIssue)
 {
     return(this.issuesRepository.Edit(user, password, repo, id, editIssue));
 }
예제 #7
0
        public Issue EditIssue(string user, string password, string repo, int id, IssueEdit editIssue)
        {
            IIssuesService issuesService = ObjectFactory.GetInstance <IIssuesService>();

            return(issuesService.Edit(user, password, repo, id, editIssue));
        }
예제 #8
0
 public Issue Edit(int projectId, IssueEdit issueEdit)
 {
     return(_api.Put().With(issueEdit).To <Issue>(string.Format(SingleIssueUrl, projectId, issueEdit.Id)));
 }
예제 #9
0
        /// <summary>
        ///     Edit an issue
        /// </summary>
        /// <param name="jiraClient">IIssueDomain to bind the extension method to</param>
        /// <param name="issueKey">string with the key for the issue to update</param>
        /// <param name="issueEdit">IssueEdit which describes what to edit</param>
        /// <param name="notifyUsers">
        ///     send the email with notification that the issue was updated to users that watch it. Admin or
        ///     project admin permissions are required to disable the notification. default = true
        /// </param>
        /// <param name="overrideScreenSecurity">
        ///     allows to update fields that are not on the screen. Only connect add-on users with
        ///     admin scope permission are allowed to use this flag. default = false
        /// </param>
        /// <param name="overrideEditableFlag">
        ///     Updates the issue even if the issue is not editable due to being in a status with
        ///     jira.issue.editable set to false or missing. Only connect add-on users with admin scope permission are allowed to
        ///     use this flag. default = false
        /// </param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>TIssue</returns>
        public static async Task EditAsync(this IIssueDomain jiraClient, string issueKey, IssueEdit issueEdit, bool notifyUsers = true, bool overrideScreenSecurity = false,
                                           bool overrideEditableFlag = false, CancellationToken cancellationToken = default)
        {
            if (issueEdit == null)
            {
                throw new ArgumentNullException(nameof(issueEdit));
            }

            Log.Debug().WriteLine("Editing issue {0}", issueKey);
            jiraClient.Behaviour.MakeCurrent();
            var issueUri = jiraClient.JiraRestUri.AppendSegments("issue", issueKey).ExtendQuery(new Dictionary <string, bool>
            {
                {
                    "notifyUsers", notifyUsers
                },
                {
                    "overrideScreenSecurity", overrideScreenSecurity
                },
                {
                    "overrideEditableFlag", overrideEditableFlag
                }
            });
            var response = await issueUri.PutAsync <HttpResponseWithError <Error> >(issueEdit, cancellationToken).ConfigureAwait(false);

            // Expect HttpStatusCode.NoContent throw error if not
            response.HandleStatusCode(HttpStatusCode.NoContent);
        }
예제 #10
0
        /// <summary>
        ///     Change the state of the issue (make a transition)
        /// </summary>
        /// <param name="jiraClient">IIssueDomain to bind the extension method to</param>
        /// <param name="issueKey">string with the key for the issue to update</param>
        /// <param name="issueEdit">IssueEdit which describes what to edit</param>
        /// <param name="cancellationToken">CancellationToken</param>
        public static async Task TransitionAsync(this IIssueDomain jiraClient, string issueKey, IssueEdit issueEdit, CancellationToken cancellationToken = default)
        {
            if (issueEdit?.Transition == null)
            {
                throw new ArgumentNullException(nameof(issueEdit));
            }

            Log.Debug().WriteLine("Transitioning issue {0} to {1}", issueKey, issueEdit.Transition.Name);
            jiraClient.Behaviour.MakeCurrent();
            var issueUri = jiraClient.JiraRestUri.AppendSegments("issue", issueKey, "transitions");
            var response = await issueUri.PostAsync <HttpResponseWithError <Error> >(issueEdit, cancellationToken).ConfigureAwait(false);

            // Expect HttpStatusCode.NoContent throw error if not
            response.HandleStatusCode(HttpStatusCode.NoContent);
        }