-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathViewCreateCommand.cs
More file actions
42 lines (35 loc) · 1.28 KB
/
ViewCreateCommand.cs
File metadata and controls
42 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using JenkinsNET.Models;
using System;
namespace JenkinsNET.Internal.Commands
{
internal class ViewCreateCommand : JenkinsHttpCommand
{
public ViewCreateCommand(IJenkinsContext context, string viewName, JenkinsProject view)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
if (string.IsNullOrEmpty(viewName))
throw new ArgumentException("Value cannot be empty!", nameof(viewName));
if (view == null)
throw new ArgumentNullException(nameof(view));
Url = NetPath.Combine(context.BaseUrl, "createView")
+ NetPath.Query(new { name = viewName });
UserName = context.UserName;
Password = context.ApiToken;
Crumb = context.Crumb;
OnWrite = request =>
{
request.Method = "POST";
request.ContentType = "application/xml";
WriteXml(request, view.Node);
};
#if NET_ASYNC
OnWriteAsync = async (request, token) => {
request.Method = "POST";
request.ContentType = "application/xml";
await WriteXmlAsync(request, view.Node, token);
};
#endif
}
}
}