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()
      Create default GHContent instance
  • Method Details

    • 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
    • getContent

      @Deprecated 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
    • 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
    • getEncodedContent

      @Deprecated 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
    • getEncoding

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

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

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

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

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

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

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

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

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

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

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

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

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

      public PagedIterable<GHContent> listDirectoryContent()
      List immediate children of this directory.
      Returns:
      the paged iterable
    • read

      public InputStream read() throws IOException
      Retrieves the actual bytes of the blob.
      Returns:
      the input stream
      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.
    • 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
    • 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