diff --git a/Octokit.Reactive/Clients/IObservableIssuesLabelsClient.cs b/Octokit.Reactive/Clients/IObservableIssuesLabelsClient.cs
index 4fe6f11d73..aa84153ee5 100644
--- a/Octokit.Reactive/Clients/IObservableIssuesLabelsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableIssuesLabelsClient.cs
@@ -263,7 +263,7 @@ public interface IObservableIssuesLabelsClient
/// The name of the repository
/// The number of the issue
/// The name of the label to remove
- IObservable RemoveFromIssue(string owner, string name, int number, string labelName);
+ IObservable RemoveFromIssue(string owner, string name, int number, string labelName);
///
/// Removes a label from an issue
@@ -274,7 +274,7 @@ public interface IObservableIssuesLabelsClient
/// The Id of the repository
/// The number of the issue
/// The name of the label to remove
- IObservable RemoveFromIssue(long repositoryId, int number, string labelName);
+ IObservable RemoveFromIssue(long repositoryId, int number, string labelName);
///
/// Replaces all labels on the specified issues with the provided labels
diff --git a/Octokit.Reactive/Clients/IObservableSearchClient.cs b/Octokit.Reactive/Clients/IObservableSearchClient.cs
index d3eb61358f..4a47cd0540 100644
--- a/Octokit.Reactive/Clients/IObservableSearchClient.cs
+++ b/Octokit.Reactive/Clients/IObservableSearchClient.cs
@@ -38,5 +38,13 @@ public interface IObservableSearchClient
///
/// List of files
IObservable SearchCode(SearchCodeRequest search);
+
+ ///
+ /// search labels
+ /// https://developer.github.com/v3/search/#search-labels
+ ///
+ ///
+ /// List of labels
+ IObservable SearchLabels(SearchLabelsRequest search);
}
}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableIssuesLabelsClient.cs b/Octokit.Reactive/Clients/ObservableIssuesLabelsClient.cs
index ff23308b4c..f3400c140d 100644
--- a/Octokit.Reactive/Clients/ObservableIssuesLabelsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableIssuesLabelsClient.cs
@@ -71,7 +71,7 @@ public IObservable GetAllForIssue(string owner, string name, int number,
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.IssueLabels(owner, name, number), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueLabels(owner, name, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -87,7 +87,7 @@ public IObservable GetAllForIssue(long repositoryId, int number, ApiOptio
{
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.IssueLabels(repositoryId, number), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -133,7 +133,7 @@ public IObservable GetAllForRepository(string owner, string name, ApiOpti
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.Labels(owner, name), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.Labels(owner, name), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -148,7 +148,7 @@ public IObservable GetAllForRepository(long repositoryId, ApiOptions opti
{
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.Labels(repositoryId), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.Labels(repositoryId), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -197,7 +197,7 @@ public IObservable GetAllForMilestone(string owner, string name, int numb
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.MilestoneLabels(owner, name, number), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.MilestoneLabels(owner, name, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -213,7 +213,7 @@ public IObservable GetAllForMilestone(long repositoryId, int number, ApiO
{
Ensure.ArgumentNotNull(options, nameof(options));
- return _connection.GetAndFlattenAllPages(ApiUrls.MilestoneLabels(repositoryId, number), options);
+ return _connection.GetAndFlattenAllPages(ApiUrls.MilestoneLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -401,13 +401,15 @@ public IObservable AddToIssue(long repositoryId, int number, string[] lab
/// The name of the repository
/// The number of the issue
/// The name of the label to remove
- public IObservable RemoveFromIssue(string owner, string name, int number, string labelName)
+ public IObservable RemoveFromIssue(string owner, string name, int number, string labelName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName));
- return _client.RemoveFromIssue(owner, name, number, labelName).ToObservable();
+ return _client.RemoveFromIssue(owner, name, number, labelName)
+ .ToObservable()
+ .SelectMany(x => x); // HACK: DELETE is not compatible with GetAndFlattenPages
}
///
@@ -419,11 +421,13 @@ public IObservable RemoveFromIssue(string owner, string name, int number,
/// The Id of the repository
/// The number of the issue
/// The name of the label to remove
- public IObservable RemoveFromIssue(long repositoryId, int number, string labelName)
+ public IObservable RemoveFromIssue(long repositoryId, int number, string labelName)
{
Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName));
- return _client.RemoveFromIssue(repositoryId, number, labelName).ToObservable();
+ return _client.RemoveFromIssue(repositoryId, number, labelName)
+ .ToObservable()
+ .SelectMany(x => x); // HACK: DELETE is not compatible with GetAndFlattenPages
}
///
diff --git a/Octokit.Reactive/Clients/ObservableSearchClient.cs b/Octokit.Reactive/Clients/ObservableSearchClient.cs
index 3505de266b..9f9b2c7f32 100644
--- a/Octokit.Reactive/Clients/ObservableSearchClient.cs
+++ b/Octokit.Reactive/Clients/ObservableSearchClient.cs
@@ -64,5 +64,17 @@ public IObservable SearchCode(SearchCodeRequest search)
Ensure.ArgumentNotNull(search, nameof(search));
return _client.SearchCode(search).ToObservable();
}
+
+ ///
+ /// search labels
+ /// https://developer.github.com/v3/search/#search-labels
+ ///
+ ///
+ /// List of labels
+ public IObservable SearchLabels(SearchLabelsRequest search)
+ {
+ Ensure.ArgumentNotNull(search, nameof(search));
+ return _client.SearchLabels(search).ToObservable();
+ }
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/IssuesLabelsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesLabelsClientTests.cs
index 59c5003818..e95b7c7f80 100644
--- a/Octokit.Tests.Integration/Clients/IssuesLabelsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/IssuesLabelsClientTests.cs
@@ -46,6 +46,7 @@ public async Task CanListIssueLabelsForAnIssue()
Assert.Equal(1, issueLabelsInfo.Count);
Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
+ Assert.Equal(newLabel.Description, issueLabelsInfo[0].Description);
}
[IntegrationTest]
@@ -69,6 +70,7 @@ public async Task CanListIssueLabelsForAnIssueWithRepositoryId()
Assert.Equal(1, issueLabelsInfo.Count);
Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
+ Assert.Equal(newLabel.Description, issueLabelsInfo[0].Description);
}
[IntegrationTest]
@@ -792,6 +794,7 @@ public async Task CanRetrieveIssueLabelByName()
Assert.Equal(label.Name, issueLabelLookupByName.Name);
Assert.Equal(label.Color, issueLabelLookupByName.Color);
+ Assert.Equal(label.Description, issueLabelLookupByName.Description);
}
[IntegrationTest]
@@ -807,6 +810,51 @@ public async Task CanRetrieveIssueLabelByNameWithRepositoryId()
Assert.Equal(label.Color, issueLabelLookupByName.Color);
}
+ [IntegrationTest]
+ public async Task CanCreateIssueLabel()
+ {
+ var newLabel = new NewLabel("test label", "FFFFFF");
+ var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);
+ Assert.NotNull(label);
+
+ var issueLabelLookupByName = await _issuesLabelsClient.Get(_context.RepositoryOwner, _context.RepositoryName, label.Name);
+
+ Assert.Equal(label.Name, issueLabelLookupByName.Name);
+ Assert.Equal(label.Color, issueLabelLookupByName.Color);
+ }
+
+ [IntegrationTest]
+ public async Task CanCreateIssueLabelWithDescription()
+ {
+ var newLabel = new NewLabel("test label", "FFFFFF") { Description = "Test label description." };
+ var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);
+ Assert.NotNull(label);
+
+ var issueLabelLookupByName = await _issuesLabelsClient.Get(_context.RepositoryOwner, _context.RepositoryName, label.Name);
+
+ Assert.Equal(label.Name, issueLabelLookupByName.Name);
+ Assert.Equal(label.Color, issueLabelLookupByName.Color);
+ Assert.Equal(label.Description, issueLabelLookupByName.Description);
+ }
+
+ [IntegrationTest]
+ public async Task CanUpdateIssueLabel()
+ {
+ var newLabel = new NewLabel("test label", "FFFFFF") { Description = "Test label description." };
+ var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);
+ Assert.NotNull(label);
+
+ var labelUpdate = new LabelUpdate("test label", "000000") { Description = "Updated label description." };
+ label = await _issuesLabelsClient.Update(_context.RepositoryOwner, _context.RepositoryName, labelUpdate.Name, labelUpdate);
+ Assert.NotNull(label);
+
+ var issueLabelLookupByName = await _issuesLabelsClient.Get(_context.RepositoryOwner, _context.RepositoryName, label.Name);
+
+ Assert.Equal(labelUpdate.Name, issueLabelLookupByName.Name);
+ Assert.Equal(labelUpdate.Color, issueLabelLookupByName.Color);
+ Assert.Equal(labelUpdate.Description, issueLabelLookupByName.Description);
+ }
+
[IntegrationTest]
public async Task CanDeleteIssueLabelByName()
{
diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
index 7f27b4d636..303fdfe0be 100644
--- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
@@ -616,4 +616,14 @@ public async Task SearchForExcludedBase()
// Ensure no items from the first search are in the results for the second
Assert.DoesNotContain(issues.Items, x1 => otherIssues.Items.Any(x2 => x2.Id == x1.Id));
}
+
+ [IntegrationTest]
+ public async Task SearchForAllLabelsUsingTermAndRepositoryId()
+ {
+ var request = new SearchLabelsRequest("category", 7528679);
+
+ var labels = await _gitHubClient.Search.SearchLabels(request);
+
+ Assert.NotEmpty(labels.Items);
+ }
}
diff --git a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs
index 786cf1201d..dfe82b7963 100644
--- a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs
+++ b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs
@@ -28,7 +28,7 @@ public async Task RequestsCorrectUrl()
await client.GetAllForIssue("fake", "repo", 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -39,7 +39,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAllForIssue(1, 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -57,7 +57,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
await client.GetAllForIssue("fake", "repo", 42, options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -75,7 +75,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
await client.GetAllForIssue(1, 42, options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -108,7 +108,7 @@ public async Task RequestsCorrectUrl()
await client.GetAllForRepository("fake", "repo");
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -119,7 +119,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAllForRepository(1);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -137,7 +137,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
await client.GetAllForRepository("fake", "repo", options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -155,7 +155,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
await client.GetAllForRepository(1, options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -188,7 +188,7 @@ public async Task RequestsCorrectUrl()
await client.GetAllForMilestone("fake", "repo", 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -199,7 +199,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAllForMilestone(1, 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.ApiOptions);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
}
[Fact]
@@ -217,7 +217,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
await client.GetAllForMilestone("fake", "repo", 42, options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -235,7 +235,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
await client.GetAllForMilestone(1, 42, options);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), options);
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), null, "application/vnd.github.symmetra-preview+json", options);
}
[Fact]
@@ -268,7 +268,7 @@ public async Task RequestsCorrectUrl()
await client.Get("fake", "repo", "label");
- connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/labels/label"));
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/labels/label"), null, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -279,7 +279,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.Get(1, "label");
- connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/labels/label"));
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/labels/label"), null, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -313,7 +313,7 @@ public void PostsToCorrectUrl()
client.AddToIssue("fake", "repo", 42, labels);
- connection.Received().Post>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any());
+ connection.Received().Post>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any(), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -324,7 +324,7 @@ public void PostsToCorrectUrlWithRepositoryId()
client.AddToIssue(1, 42, labels);
- connection.Received().Post>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any());
+ connection.Received().Post>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any(), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -353,7 +353,7 @@ public void DeleteCorrectUrl()
client.RemoveFromIssue("fake", "repo", 42, "label");
- connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"));
+ connection.Received().Delete>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -364,7 +364,7 @@ public void DeleteCorrectUrlWithRepositoryId()
client.RemoveFromIssue(1, 42, "label");
- connection.Received().Delete(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels/label"));
+ connection.Received().Delete>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -398,7 +398,7 @@ public void PutsToCorrectUrl()
client.ReplaceAllForIssue("fake", "repo", 42, labels);
- connection.Received().Put>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any());
+ connection.Received().Put>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any(), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -409,7 +409,7 @@ public void PutsToCorrectUrlWithRepositoryId()
client.ReplaceAllForIssue(1, 42, labels);
- connection.Received().Put>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any());
+ connection.Received().Put>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Any(), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -520,7 +520,7 @@ public void CreatesCorrectUrl()
client.Create("fake", "repo", newLabel);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), newLabel);
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), newLabel, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -533,7 +533,7 @@ public void CreatesCorrectUrlWithRepositoryId()
client.Create(1, newLabel);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/labels"), newLabel);
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/labels"), newLabel, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -565,7 +565,7 @@ public void UpdatesCorrectUrl()
client.Update("fake", "repo", "labelName", labelUpdate);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/labels/labelName"), labelUpdate);
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/labels/labelName"), labelUpdate, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -578,7 +578,7 @@ public void UpdatesCorrectUrlWithRepositoryId()
client.Update(1, "labelName", labelUpdate);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/labels/labelName"), labelUpdate);
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/labels/labelName"), labelUpdate, "application/vnd.github.symmetra-preview+json");
}
[Fact]
diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs
index a4eba60b66..d90f0e3ec6 100644
--- a/Octokit.Tests/Clients/SearchClientTests.cs
+++ b/Octokit.Tests/Clients/SearchClientTests.cs
@@ -1675,5 +1675,111 @@ await Assert.ThrowsAsync(
async () => await client.SearchCode(request));
}
}
+
+ public class TheSearchLabelsMethod
+ {
+ [Fact]
+ public void RequestsTheCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ client.SearchLabels(new SearchLabelsRequest("something", 1));
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Any>(),
+ "application/vnd.github.symmetra-preview+json");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var client = new SearchClient(Substitute.For());
+ await Assert.ThrowsAsync(() => client.SearchLabels(null));
+ }
+
+ [Fact]
+ public void TestingTheTermParameter()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ var request = new SearchLabelsRequest("something", 1);
+
+ client.SearchLabels(request);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Is>(d =>
+ d["q"] == "something" &&
+ d["repository_id"] == "1"),
+ "application/vnd.github.symmetra-preview+json");
+ }
+
+ [Fact]
+ public void TestingTheSortParameter()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ var request = new SearchLabelsRequest("something", 1);
+ request.SortField = LabelSearchSort.Created;
+
+ client.SearchLabels(request);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Is>(d => d["sort"] == "created"),
+ "application/vnd.github.symmetra-preview+json");
+ }
+
+ [Fact]
+ public void TestingTheOrderParameter()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ var request = new SearchLabelsRequest("something", 1);
+ request.SortField = LabelSearchSort.Created;
+ request.Order = SortDirection.Ascending;
+
+ client.SearchLabels(request);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Is>(d =>
+ d["sort"] == "created" &&
+ d["order"] == "asc"),
+ "application/vnd.github.symmetra-preview+json");
+ }
+
+ [Fact]
+ public void TestingTheDefaultOrderParameter()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ var request = new SearchLabelsRequest("something", 1);
+
+ client.SearchLabels(request);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Is>(d => d["order"] == "desc"),
+ "application/vnd.github.symmetra-preview+json");
+ }
+
+ [Fact]
+ public void TestingTheRepositoryIdParameter()
+ {
+ var connection = Substitute.For();
+ var client = new SearchClient(connection);
+ var request = new SearchLabelsRequest("something", 1);
+
+ client.SearchLabels(request);
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "search/labels"),
+ Arg.Is>(d =>
+ d["q"] == "something" &&
+ d["repository_id"] == "1"),
+ "application/vnd.github.symmetra-preview+json");
+ }
+ }
}
}
diff --git a/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs
index fe63561c1f..57b030548a 100644
--- a/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs
+++ b/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs
@@ -30,7 +30,7 @@ public async Task RequestsCorrectUrl()
client.GetAllForIssue("fake", "repo", 42);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -42,7 +42,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
client.GetAllForIssue(1, 42);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -61,7 +61,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
client.GetAllForIssue("fake", "repo", 42, options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -80,7 +80,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
client.GetAllForIssue(1, 42, options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -114,7 +114,7 @@ public async Task RequestsCorrectUrl()
client.GetAllForRepository("fake", "repo");
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -126,7 +126,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
client.GetAllForRepository(1);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -145,7 +145,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
client.GetAllForRepository("fake", "repo", options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -164,7 +164,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
client.GetAllForRepository(1, options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -198,7 +198,7 @@ public async Task RequestsCorrectUrl()
client.GetAllForMilestone("fake", "repo", 42);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -210,7 +210,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
client.GetAllForMilestone(1, 42);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.EmptyDictionary, null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.EmptyDictionary, "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -229,7 +229,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
client.GetAllForMilestone("fake", "repo", 42, options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -248,7 +248,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
client.GetAllForMilestone(1, 42, options);
- connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), Arg.Is>(d => d.Count == 2), null);
+ connection.Received().Get>(Arg.Is(u => u.ToString() == "repositories/1/milestones/42/labels"), Arg.Is>(d => d.Count == 2), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -367,7 +367,7 @@ public void DeleteCorrectUrl()
client.RemoveFromIssue("fake", "repo", 42, "label");
- connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"));
+ connection.Received().Delete>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
}
[Fact]
@@ -379,7 +379,7 @@ public void DeleteCorrectUrlWithRepositoryId()
client.RemoveFromIssue(1, 42, "label");
- connection.Received().Delete(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels/label"));
+ connection.Received().Delete>(Arg.Is(u => u.ToString() == "repositories/1/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
}
[Fact]
diff --git a/Octokit/Clients/IIssuesLabelsClient.cs b/Octokit/Clients/IIssuesLabelsClient.cs
index e34d8304ad..2c535ebec1 100644
--- a/Octokit/Clients/IIssuesLabelsClient.cs
+++ b/Octokit/Clients/IIssuesLabelsClient.cs
@@ -263,7 +263,7 @@ public interface IIssuesLabelsClient
/// The name of the repository
/// The number of the issue
/// The name of the label to remove
- Task RemoveFromIssue(string owner, string name, int number, string labelName);
+ Task> RemoveFromIssue(string owner, string name, int number, string labelName);
///
/// Removes a label from an issue
@@ -274,7 +274,7 @@ public interface IIssuesLabelsClient
/// The Id of the repository
/// The number of the issue
/// The name of the label to remove
- Task RemoveFromIssue(long repositoryId, int number, string labelName);
+ Task> RemoveFromIssue(long repositoryId, int number, string labelName);
///
/// Replaces all labels on the specified issues with the provided labels
diff --git a/Octokit/Clients/ISearchClient.cs b/Octokit/Clients/ISearchClient.cs
index ed8b9f3ad9..2246b53eda 100644
--- a/Octokit/Clients/ISearchClient.cs
+++ b/Octokit/Clients/ISearchClient.cs
@@ -41,5 +41,13 @@ public interface ISearchClient
///
/// List of files
Task SearchCode(SearchCodeRequest search);
+
+ ///
+ /// search labels
+ /// https://developer.github.com/v3/search/#search-labels
+ ///
+ ///
+ /// List of labels
+ Task SearchLabels(SearchLabelsRequest search);
}
}
\ No newline at end of file
diff --git a/Octokit/Clients/IssuesLabelsClient.cs b/Octokit/Clients/IssuesLabelsClient.cs
index 964d567516..15a51be6c7 100644
--- a/Octokit/Clients/IssuesLabelsClient.cs
+++ b/Octokit/Clients/IssuesLabelsClient.cs
@@ -62,7 +62,7 @@ public Task> GetAllForIssue(string owner, string name, int
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
- return ApiConnection.GetAll(ApiUrls.IssueLabels(owner, name, number), options);
+ return ApiConnection.GetAll(ApiUrls.IssueLabels(owner, name, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -78,7 +78,7 @@ public Task> GetAllForIssue(long repositoryId, int number,
{
Ensure.ArgumentNotNull(options, nameof(options));
- return ApiConnection.GetAll(ApiUrls.IssueLabels(repositoryId, number), options);
+ return ApiConnection.GetAll(ApiUrls.IssueLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options);
}
///
@@ -124,7 +124,7 @@ public Task> GetAllForRepository(string owner, string name,
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
- return ApiConnection.GetAll(ApiUrls.Labels(owner, name), options);
+ return ApiConnection.GetAll(ApiUrls.Labels(owner, name), null, AcceptHeaders.LabelsApiPreview, options);
}
///