| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Issues |
|
| 1.0;1 | ||||
| Issues$Qualifier |
|
| 1.0;1 | ||||
| Issues$Sort |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * Copyright (c) 2013-2017, jcabi.com | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: 1) Redistributions of source code must retain the above | |
| 8 | * copyright notice, this list of conditions and the following | |
| 9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
| 10 | * copyright notice, this list of conditions and the following | |
| 11 | * disclaimer in the documentation and/or other materials provided | |
| 12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
| 13 | * the names of its contributors may be used to endorse or promote | |
| 14 | * products derived from this software without specific prior written | |
| 15 | * permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | */ | |
| 30 | package com.jcabi.github; | |
| 31 | ||
| 32 | import com.jcabi.aspects.Immutable; | |
| 33 | import java.io.IOException; | |
| 34 | import java.util.EnumMap; | |
| 35 | import java.util.Map; | |
| 36 | ||
| 37 | /** | |
| 38 | * Github issues. | |
| 39 | * | |
| 40 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
| 41 | * @author Chris Rebert (github@chrisrebert.com) | |
| 42 | * @version $Id: 277ea4d1ac1300f4db1e804092e800ae0965ca5b $ | |
| 43 | * @since 0.1 | |
| 44 | * @see <a href="http://developer.github.com/v3/issues/">Issues API</a> | |
| 45 | */ | |
| 46 | @Immutable | |
| 47 | public interface Issues { | |
| 48 | ||
| 49 | /** | |
| 50 | * Owner of them. | |
| 51 | * @return Repo | |
| 52 | */ | |
| 53 | Repo repo(); | |
| 54 | ||
| 55 | /** | |
| 56 | * Get specific issue by number. | |
| 57 | * @param number Issue number | |
| 58 | * @return Issue | |
| 59 | * @see <a href="http://developer.github.com/v3/issues/#get-a-single-issue">Get a Single Issue</a> | |
| 60 | */ | |
| 61 | Issue get(int number); | |
| 62 | ||
| 63 | /** | |
| 64 | * Create new issue. | |
| 65 | * @param title Title | |
| 66 | * @param body Body of it | |
| 67 | * @return Issue just created | |
| 68 | * @throws IOException If there is any I/O problem | |
| 69 | * @see <a href="http://developer.github.com/v3/issues/#create-an-issue">Create an Issue</a> | |
| 70 | */ | |
| 71 | Issue create(String title, String body) throws IOException; | |
| 72 | ||
| 73 | /** | |
| 74 | * Iterate them all. | |
| 75 | * @param params Iterating parameters, as requested by API | |
| 76 | * @return Iterator of issues | |
| 77 | * @see <a href="http://developer.github.com/v3/issues/#list-issues">List Issues</a> | |
| 78 | */ | |
| 79 | Iterable<Issue> iterate(Map<String, String> params); | |
| 80 | ||
| 81 | /** | |
| 82 | * Search for issues within the given repository. | |
| 83 | * | |
| 84 | * @param sort The sort field | |
| 85 | * @param direction The sort direction | |
| 86 | * @param qualifiers The search qualifier | |
| 87 | * @return Issues | |
| 88 | * @throws java.io.IOException If there is any I/O problem | |
| 89 | * @since 0.22.0 | |
| 90 | * @see <a href="https://developer.github.com/v3/issues/#list-issues-for-a-repository">List issues for a repository</a> | |
| 91 | */ | |
| 92 | Iterable<Issue> search( | |
| 93 | Sort sort, Search.Order direction, | |
| 94 | EnumMap<Qualifier, String> qualifiers) | |
| 95 | throws IOException; | |
| 96 | ||
| 97 | 2 | enum Qualifier implements StringEnum { |
| 98 | /** | |
| 99 | * Filter issues based on which milestone they are assigned to. | |
| 100 | * "none" means no assigned milestone. "*" means any milestone. | |
| 101 | */ | |
| 102 | 1 | MILESTONE("milestone"), |
| 103 | /** | |
| 104 | * Filter issues based on whether they're open or closed. | |
| 105 | */ | |
| 106 | 1 | STATE("state"), |
| 107 | /** | |
| 108 | * Finds issues that are assigned to a certain user. | |
| 109 | * "none" means no assigned user. "*" means assigned to any user. | |
| 110 | */ | |
| 111 | 1 | ASSIGNEE("assignee"), |
| 112 | /** | |
| 113 | * Finds issues created by a certain user. | |
| 114 | */ | |
| 115 | 1 | CREATOR("creator"), |
| 116 | /** | |
| 117 | * Finds issues that mention a certain user. | |
| 118 | */ | |
| 119 | 1 | MENTIONED("mentioned"), |
| 120 | /** | |
| 121 | * Filters issues based on their labels, | |
| 122 | * as a comma-separated list of label names. | |
| 123 | * An issue must have all of the labels in the list in order to | |
| 124 | * appear in the search results. | |
| 125 | */ | |
| 126 | 1 | LABELS("labels"), |
| 127 | /** | |
| 128 | * Filters issues based on date last updated (as an ISO 8601 timestamp). | |
| 129 | */ | |
| 130 | 1 | SINCE("since"); |
| 131 | ||
| 132 | /** | |
| 133 | * Search qualifier. | |
| 134 | */ | |
| 135 | private final transient String qualifier; | |
| 136 | ||
| 137 | /** | |
| 138 | * Ctor. | |
| 139 | * @param key Search qualifier | |
| 140 | */ | |
| 141 | 7 | Qualifier(final String key) { |
| 142 | 7 | this.qualifier = key; |
| 143 | 7 | } |
| 144 | ||
| 145 | /** | |
| 146 | * Get search qualifier. | |
| 147 | * @return String | |
| 148 | */ | |
| 149 | @Override | |
| 150 | public String identifier() { | |
| 151 | 0 | return this.qualifier; |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | 1 | enum Sort implements StringEnum { |
| 156 | /** | |
| 157 | * Issue creation timestamp. | |
| 158 | */ | |
| 159 | 1 | CREATED("created"), |
| 160 | /** | |
| 161 | * Issue last updated timestamp. | |
| 162 | */ | |
| 163 | 1 | UPDATED("updated"), |
| 164 | /** | |
| 165 | * Number of comments on the issue. | |
| 166 | */ | |
| 167 | 1 | COMMENTS("comments"); |
| 168 | ||
| 169 | /** | |
| 170 | * Search results sort field. | |
| 171 | */ | |
| 172 | private final transient String sort; | |
| 173 | ||
| 174 | /** | |
| 175 | * Ctor. | |
| 176 | * @param field Search results sort field | |
| 177 | */ | |
| 178 | 3 | Sort(final String field) { |
| 179 | 3 | this.sort = field; |
| 180 | 3 | } |
| 181 | ||
| 182 | /** | |
| 183 | * Get search results sort field. | |
| 184 | * @return String | |
| 185 | */ | |
| 186 | @Override | |
| 187 | public String identifier() { | |
| 188 | 1 | return this.sort; |
| 189 | } | |
| 190 | } | |
| 191 | } |