Coverage Report - com.jcabi.github.Contents
 
Classes in this File Line Coverage Branch Coverage Complexity
Contents
N/A
N/A
1
 
 1  
 /**
 2  
  * Copyright (c) 2013-2015, 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 javax.json.JsonObject;
 35  
 import javax.validation.constraints.NotNull;
 36  
 
 37  
 /**
 38  
  * Github contents.
 39  
  *
 40  
  * @author Andres Candal (andres.candal@rollasolution.com)
 41  
  * @version $Id$
 42  
  * @since 0.8
 43  
  * @see <a href="http://developer.github.com/v3/repos/contents/">Contents API</a>
 44  
  * @checkstyle MultipleStringLiteralsCheck (500 lines)
 45  
  */
 46  
 @Immutable
 47  
 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
 48  
 public interface Contents {
 49  
 
 50  
     /**
 51  
      * Owner of them.
 52  
      * @return Repo
 53  
      */
 54  
     @NotNull(message = "repository is never NULL")
 55  
     Repo repo();
 56  
 
 57  
     /**
 58  
      * Get the Readme file of the default branch (usually master).
 59  
      *
 60  
      * @return The Content of the readme file.
 61  
      * @throws IOException If an IO Exception occurs.
 62  
      * @see <a href="http://http://developer.github.com/v3/repos/contents/#get-the-readme">Get the README</a>
 63  
      */
 64  
     @NotNull(message = "Content is never NULL")
 65  
     Content readme() throws IOException;
 66  
 
 67  
     /**
 68  
      * Get the Readme file of the specified branch.
 69  
      *
 70  
      * @param branch The branch name
 71  
      * @return The Content of the readme file.
 72  
      * @throws IOException If an IO Exception occurs.
 73  
      * @see <a href="http://http://developer.github.com/v3/repos/contents/#get-the-readme">Get the README</a>
 74  
      */
 75  
     @NotNull(message = "Content is never NULL")
 76  
     Content readme(@NotNull(message = "branch is never NULL") String branch)
 77  
         throws IOException;
 78  
 
 79  
     /**
 80  
      * Create new file.
 81  
      * @param content Parameters to create new content
 82  
      * @return Content just created
 83  
      * @throws IOException If there is any I/O problem
 84  
      * @see <a href="http://developer.github.com/v3/repos/contents/#create-a-file">Create a file</a>
 85  
      */
 86  
     @NotNull(message = "Content is never NULL")
 87  
     Content create(
 88  
         @NotNull(message = "content is never NULL") JsonObject content)
 89  
         throws IOException;
 90  
 
 91  
     /**
 92  
      * Get the contents of a file or symbolic link in a repository.
 93  
      * @param path The content path
 94  
      * @param ref The name of the commit/branch/tag.
 95  
      * @return Content fetched
 96  
      * @throws IOException If there is any I/O problem
 97  
      * @see <a href="http://developer.github.com/v3/repos/contents/#get-contents">Get contents</a>
 98  
      */
 99  
     @NotNull(message = "Content is never NULL")
 100  
     Content get(
 101  
         @NotNull(message = "path  is never NULL") String path,
 102  
         @NotNull(message = "ref is never NULL") String ref
 103  
     ) throws IOException;
 104  
 
 105  
     /**
 106  
      * Get the contents of a file or symbolic link in a repository's default
 107  
      * branch (usually master).
 108  
      * @param path The content path
 109  
      * @return Content fetched
 110  
      * @throws IOException If there is any I/O problem
 111  
      * @see <a href="http://developer.github.com/v3/repos/contents/#get-contents">Get contents</a>
 112  
      */
 113  
     @NotNull(message = "Content is never NULL")
 114  
     Content get(
 115  
         @NotNull(message = "path  is never NULL") String path
 116  
     ) throws IOException;
 117  
 
 118  
     /**
 119  
      * Get the contents of a directory in a repository.
 120  
      * @param path The content path
 121  
      * @param ref The name of the commit/branch/tag. Default: the repository's default branch (usually master)
 122  
      * @return Contents fetched
 123  
      * @throws IOException If there is any I/O problem
 124  
      * @see <a href="http://developer.github.com/v3/repos/contents/#get-contents">Get contents</a>
 125  
      */
 126  
     @NotNull(message = "iterable is never NULL")
 127  
     Iterable<Content> iterate(
 128  
         @NotNull(message = "path  is never NULL") String path,
 129  
         @NotNull(message = "ref is never NULL") String ref)
 130  
         throws IOException;
 131  
 
 132  
     /**
 133  
      * Removes a file.
 134  
      * @param content Parameters to remove a file
 135  
      * @return RepoCommit referring to this operation
 136  
      * @throws IOException If there is any I/O problem
 137  
      * @see <a href="http://developer.github.com/v3/repos/contents/#delete-a-file">Delete a file</a>
 138  
      */
 139  
     @NotNull(message = "Content is never NULL")
 140  
     RepoCommit remove(
 141  
         @NotNull(message = "content is never NULL") JsonObject content)
 142  
         throws IOException;
 143  
 
 144  
     /**
 145  
      * Updates a file.
 146  
      * @param path The content path.
 147  
      * @param json JSON object containing updates to the content.
 148  
      * @return Commit referring to this operation
 149  
      * @throws IOException If any I/O problems occur.
 150  
      * @see <a href="http://developer.github.com/v3/repos/contents/#update-a-file">Update a file</a>
 151  
      */
 152  
     @NotNull(message = "RepoCommit is never NULL")
 153  
     RepoCommit update(
 154  
         @NotNull(message = "path is never NULL") String path,
 155  
         @NotNull(message = "json is never NULL") JsonObject json)
 156  
         throws IOException;
 157  
 
 158  
     /**
 159  
      * Check whether content exists or not.
 160  
      * @param path The content path
 161  
      * @param ref The name of the commit/branch/tag.
 162  
      * @return True if content exists, false otherwise.
 163  
      * @throws IOException If there is any I/O problem
 164  
      */
 165  
     boolean exists(
 166  
         @NotNull(message = "path  is never NULL") String path,
 167  
         @NotNull(message = "ref is never NULL") String ref
 168  
     ) throws IOException;
 169  
 
 170  
 }