/// <summary> /// Get the XML for a view /// </summary> /// <param name="jenkinsClient">IViewDomain to bind the extension method to</param> /// <param name="viewName">the name of the view</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>XDocument</returns> public static async Task <XDocument> GetXmlAsync(this IViewDomain jenkinsClient, string viewName, CancellationToken cancellationToken = default(CancellationToken)) { if (viewName == null) { throw new ArgumentNullException(nameof(viewName)); } Log.Debug().WriteLine("Retrieving view XML for {0}", viewName); var viewXmlUri = jenkinsClient.JenkinsBaseUri.AppendSegments("view", viewName, "config.xml"); jenkinsClient.Behaviour.MakeCurrent(); var response = await viewXmlUri.GetAsAsync <HttpResponse <XDocument> >(cancellationToken).ConfigureAwait(false); return(response.HandleErrors()); }
/// <summary> /// Delete view by name /// </summary> /// <param name="jenkinsClient">IViewDomain to bind the extension method to</param> /// <param name="viewName">name of the view to delete</param> /// <param name="cancellationToken">CancellationToken</param> public static async Task DeleteAsync(this IViewDomain jenkinsClient, string viewName, CancellationToken cancellationToken = default(CancellationToken)) { if (viewName == null) { throw new ArgumentNullException(nameof(viewName)); } Log.Debug().WriteLine("Deleting view {0}", viewName); var deleteViewUri = jenkinsClient.JenkinsBaseUri.AppendSegments("view", viewName, "doDelete"); jenkinsClient.Behaviour.MakeCurrent(); var response = await deleteViewUri.PostAsync <HttpResponse>(null, cancellationToken).ConfigureAwait(false); response.HandleStatusCode(); }
/// <summary> /// Create view /// </summary> /// <param name="jenkinsClient">IViewDomain to bind the extension method to</param> /// <param name="viewName">name of the view to create</param> /// <param name="viewXmlDocument">XDocument with config.xml for the view</param> /// <param name="cancellationToken">CancellationToken</param> public static async Task CreateAsync(this IViewDomain jenkinsClient, string viewName, XDocument viewXmlDocument, CancellationToken cancellationToken = default(CancellationToken)) { if (viewName == null) { throw new ArgumentNullException(nameof(viewName)); } Log.Debug().WriteLine("Creating view {0}", viewName); var createViewUri = jenkinsClient.JenkinsBaseUri.AppendSegments("createView").ExtendQuery("name", viewName); jenkinsClient.Behaviour.MakeCurrent(); var response = await createViewUri.PostAsync <HttpResponse>(viewXmlDocument, cancellationToken).ConfigureAwait(false); response.HandleStatusCode(); }