-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
EnterpriseSearchIndexingClient.cs
157 lines (135 loc) · 7.22 KB
/
EnterpriseSearchIndexingClient.cs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System.Globalization;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Enterprise Search Indexing API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/search_indexing/">Enterprise Search Indexing API documentation</a> for more information.
///</remarks>
public class EnterpriseSearchIndexingClient : ApiClient, IEnterpriseSearchIndexingClient
{
public EnterpriseSearchIndexingClient(IApiConnection apiConnection)
: base(apiConnection)
{ }
/// <summary>
/// Queue an indexing job for a user or organization account (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> Queue(string owner)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}", owner));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for a repository (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <param name="repository">A repository</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> Queue(string owner, string repository)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
Ensure.ArgumentNotNull(repository, nameof(repository));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, repository));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for all of a user or organization's repositories (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> QueueAll(string owner)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*", owner));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for all the issues in a repository (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <param name="repository">A repository</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> QueueAllIssues(string owner, string repository)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
Ensure.ArgumentNotNull(repository, nameof(repository));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/issues", owner, repository));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for all the issues in all of a user or organization's repositories (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> QueueAllIssues(string owner)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/issues", owner));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for all the source code in a repository (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <param name="repository">A repository</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> QueueAllCode(string owner, string repository)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
Ensure.ArgumentNotNull(repository, nameof(repository));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/code", owner, repository));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
/// <summary>
/// Queue an indexing job for all the source code in all of a user or organization's repositories (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job
/// </remarks>
/// <param name="owner">A user or organization account</param>
/// <returns>The <see cref="SearchIndexingResponse"/> message.</returns>
[ManualRoute("POST", "/staff/indexing_jobs")]
public Task<SearchIndexingResponse> QueueAllCode(string owner)
{
Ensure.ArgumentNotNull(owner, nameof(owner));
var endpoint = ApiUrls.EnterpriseSearchIndexing();
var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/code", owner));
return ApiConnection.Post<SearchIndexingResponse>(endpoint, target);
}
}
}