Package org.kohsuke.github
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:
GHRepository#getFileContent(String)
-
-
Constructor Summary
Constructors Constructor Description GHContent()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description GHContentUpdateResponse
delete(String message)
Delete gh content update response.GHContentUpdateResponse
delete(String commitMessage, String branch)
Delete gh content update response.String
getContent()
Deprecated.Useread()
String
getDownloadUrl()
URL to retrieve the raw content of the file.String
getEncodedContent()
Deprecated.Useread()
String
getEncoding()
Gets encoding.String
getGitUrl()
Gets git url.String
getHtmlUrl()
Gets html url.String
getName()
Gets name.GHRepository
getOwner()
Gets owner.String
getPath()
Gets path.GitHub
getRoot()
Deprecated.For access to theGitHub
instance, use a local copy instead of pulling it out of objects.String
getSha()
Gets sha.long
getSize()
Gets size.String
getTarget()
Gets target of a symlink.String
getType()
Gets type.String
getUrl()
Gets url.boolean
isDirectory()
Is directory boolean.boolean
isFile()
Is file boolean.PagedIterable<GHContent>
listDirectoryContent()
List immediate children of this directory.protected void
populate()
Fully populate the data by retrieving missing data.InputStream
read()
Retrieves the actual bytes of the blob.void
refresh()
Fully populate the data by retrieving missing data.GHContentUpdateResponse
update(byte[] newContentBytes, String commitMessage)
Update gh content update response.GHContentUpdateResponse
update(byte[] newContentBytes, String commitMessage, String branch)
Update gh content update response.GHContentUpdateResponse
update(String newContent, String commitMessage)
Update gh content update response.GHContentUpdateResponse
update(String newContent, String commitMessage, String branch)
Update gh content update response.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.kohsuke.github.Refreshable
refresh
-
-
-
-
Method Detail
-
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.Useread()
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.Useread()
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 contentcommitMessage
- 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 contentcommitMessage
- the commit messagebranch
- 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 bytescommitMessage
- 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 bytescommitMessage
- the commit messagebranch
- 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 messagebranch
- 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 interfaceRefreshable
- Throws:
IOException
- the io exception
-
getRoot
@Deprecated public GitHub getRoot()
Deprecated.For access to theGitHub
instance, use a local copy instead of pulling it out of objects.Get the rootGitHub
instance for this object.- Returns:
- the root
GitHub
instance
-
-