Class GHContent

java.lang.Object
org.kohsuke.github.GHContent
All Implemented Interfaces:
Refreshable

public class GHContent extends Object implements Refreshable
A Content of a repository.
Author:
Alexandre COLLIGNON
See Also:
  • Constructor Details

    • GHContent

      public GHContent()
  • Method Details

    • getOwner

      public GHRepository getOwner()
      Gets owner.
      Returns:
      the owner
    • getType

      public String getType()
      Gets type.
      Returns:
      the type
    • getEncoding

      public String getEncoding()
      Gets encoding.
      Returns:
      the encoding
    • getSize

      public long getSize()
      Gets size.
      Returns:
      the size
    • getSha

      public String getSha()
      Gets sha.
      Returns:
      the sha
    • getName

      public String getName()
      Gets name.
      Returns:
      the name
    • getPath

      public String getPath()
      Gets path.
      Returns:
      the path
    • getTarget

      public String getTarget()
      Gets target of a symlink. This will only be set if "symlink".equals(getType())
      Returns:
      the target
    • getContent

      public String getContent() throws IOException
      Deprecated.
      Use read()
      Retrieve the decoded content that is stored at this location.

      Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may trigger network activity, and can throw an IOException.

      Returns:
      the content
      Throws:
      IOException - the io exception
    • getEncodedContent

      public String getEncodedContent() throws IOException
      Deprecated.
      Use read()
      Retrieve the base64-encoded content that is stored at this location.

      Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may trigger network activity, and can throw an IOException.

      Returns:
      the encoded content
      Throws:
      IOException - the io exception
    • getUrl

      public String getUrl()
      Gets url.
      Returns:
      the url
    • getGitUrl

      public String getGitUrl()
      Gets git url.
      Returns:
      the git url
    • getHtmlUrl

      public String getHtmlUrl()
      Gets html url.
      Returns:
      the html url
    • read

      public InputStream read() throws IOException
      Retrieves the actual bytes of the blob.
      Returns:
      the input stream
      Throws:
      IOException - the io exception
    • getDownloadUrl

      public String getDownloadUrl() throws IOException
      URL to retrieve the raw content of the file. Null if this is a directory.
      Returns:
      the download url
      Throws:
      IOException - the io exception
    • isFile

      public boolean isFile()
      Is file boolean.
      Returns:
      the boolean
    • isDirectory

      public boolean isDirectory()
      Is directory boolean.
      Returns:
      the boolean
    • populate

      protected void populate() throws IOException
      Fully populate the data by retrieving missing data.

      Depending on the original API call where this object is created, it may not contain everything.

      Throws:
      IOException - the io exception
    • listDirectoryContent

      public PagedIterable<GHContent> listDirectoryContent() throws IOException
      List immediate children of this directory.
      Returns:
      the paged iterable
      Throws:
      IOException - the io exception
    • update

      public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException
      Update gh content update response.
      Parameters:
      newContent - the new content
      commitMessage - the commit message
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • update

      public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException
      Update gh content update response.
      Parameters:
      newContent - the new content
      commitMessage - the commit message
      branch - the branch
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • update

      public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException
      Update gh content update response.
      Parameters:
      newContentBytes - the new content bytes
      commitMessage - the commit message
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • update

      public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException
      Update gh content update response.
      Parameters:
      newContentBytes - the new content bytes
      commitMessage - the commit message
      branch - the branch
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • delete

      public GHContentUpdateResponse delete(String message) throws IOException
      Delete gh content update response.
      Parameters:
      message - the message
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • delete

      public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException
      Delete gh content update response.
      Parameters:
      commitMessage - the commit message
      branch - the branch
      Returns:
      the gh content update response
      Throws:
      IOException - the io exception
    • refresh

      public void refresh() throws IOException
      Fully populate the data by retrieving missing data. Depending on the original API call where this object is created, it may not contain everything.
      Specified by:
      refresh in interface Refreshable
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getRoot

      @Deprecated public GitHub getRoot()
      Deprecated.
      For access to the GitHub instance, use a local copy instead of pulling it out of objects.
      Get the root GitHub instance for this object.
      Returns:
      the root GitHub instance