From 81c96aed3c2f39c276cd0353c18c1a761cd87c7c Mon Sep 17 00:00:00 2001 From: khoinguyen Date: Fri, 1 Sep 2023 10:40:26 -0400 Subject: [PATCH] add search commit api --- .../github/v3/clients/SearchClient.java | 12 ++++++ .../github/v3/search/SearchCommits.java | 42 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/main/java/com/spotify/github/v3/search/SearchCommits.java diff --git a/src/main/java/com/spotify/github/v3/clients/SearchClient.java b/src/main/java/com/spotify/github/v3/clients/SearchClient.java index 764a9657..3eb6457d 100644 --- a/src/main/java/com/spotify/github/v3/clients/SearchClient.java +++ b/src/main/java/com/spotify/github/v3/clients/SearchClient.java @@ -21,6 +21,7 @@ package com.spotify.github.v3.clients; import com.google.common.base.Strings; +import com.spotify.github.v3.search.SearchCommits; import com.spotify.github.v3.search.SearchIssues; import com.spotify.github.v3.search.SearchRepositories; import com.spotify.github.v3.search.SearchUsers; @@ -37,6 +38,7 @@ public class SearchClient { static final String USERS_URI = "/search/users"; static final String REPOSITORIES_URI = "/search/repositories"; static final String ISSUES_URI = "/search/issues"; + static final String COMMIT_URI = "/search/commits"; private final GitHubClient github; SearchClient(final GitHubClient github) { @@ -47,6 +49,16 @@ static SearchClient create(final GitHubClient github) { return new SearchClient(github); } + /** + * Search commits. + * + * @param parameters commit search parameters + * @return commit search results + */ + public CompletableFuture commits(final SearchParameters parameters) { + return search(COMMIT_URI, parameters, SearchCommits.class); + } + /** * Search users. * diff --git a/src/main/java/com/spotify/github/v3/search/SearchCommits.java b/src/main/java/com/spotify/github/v3/search/SearchCommits.java new file mode 100644 index 00000000..3a4048b0 --- /dev/null +++ b/src/main/java/com/spotify/github/v3/search/SearchCommits.java @@ -0,0 +1,42 @@ +/*- + * -\-\- + * github-api + * -- + * Copyright (C) 2016 - 2023 Spotify AB + * -- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -/-/- + */ + +package com.spotify.github.v3.search; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.spotify.github.GithubStyle; +import com.spotify.github.v3.repos.Commit; +import org.immutables.value.Value; + +import java.util.List; +import javax.annotation.Nullable; + +/** Commits search result resource */ +@Value.Immutable +@GithubStyle +@JsonSerialize(as = ImmutableSearchCommits.class) +@JsonDeserialize(as = ImmutableSearchCommits.class) +public interface SearchCommits extends Search { + + /** Commits search results */ + @Nullable + List items(); +}