Class GHRepository
java.lang.Object
io.github.coho04.githubapi.bases.GHBase
io.github.coho04.githubapi.bases.ClassBase
io.github.coho04.githubapi.entities.repositories.GHRepository
- All Implemented Interfaces:
HttpRequestInterface
,JSONHelper
This class represents a GitHub repository.
It provides methods for fetching and manipulating data about the repository such as its size, forks, license, name, owner, watchers, and more.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.coho04.githubapi.interfaces.JSONHelper
JSONHelper.JSONToObject<T>
-
Constructor Summary
ConstructorsConstructorDescriptionGHRepository
(org.json.JSONObject jsonObject, Github github) Constructs a new GHRepository instance with the provided JSON object and GitHub instance. -
Method Summary
Modifier and TypeMethodDescriptionaddFile()
Starts the process of adding a new file to this repository.Starts the process of adding a new file to the given branch of this repository.Starts the process of adding a new file with the given path, content, and commit message to the given branch of this repository.createIssue
(String title) Creates a new issue in this repository with the given title.Creates a project in the organization.createProject
(String name, String body) Creates a project in the organization.boolean
deleteActionsCache
(int id) Deletes the actions cache with the given ID in this repository.void
deleteActionsCache
(String key) Deletes the actions cache with the given key in this repository.deleteArtifact
(int id) Deletes the artifact with the given ID in this repository.Fetches all filenames in this repository.Returns the URL for fetching the archive of this repository.getArtifact
(int id) Fetches the artifact with the given ID in this repository.Returns the URL for fetching assignees in this repository.Returns the URL for fetching blobs in this repository.Fetches the branches of this repository.Returns the URL for fetching the branches of this repository.getCache()
Fetches the cache of this repository.Returns the clone URL of this repository.Returns the URL for fetching collaborators of this repository.Returns the URL for fetching comments in this repository.Returns the URL for fetching commits in this repository.Returns the URL for comparing commits in this repository.Returns the URL for fetching contents of this repository.Fetches the contributors of this repository.Returns the URL for fetching contributors to this repository.Returns the date and time when this repository was created.Returns the default branch of this repository.Returns the URL for fetching deployments in this repository.Returns the description of this repository.getDirectoryContent
(String path) Fetches the content of the directory at the given path in this repository.Fetches the content of the directory at the given path in this repository, including the content of each file.Returns the URL for fetching downloads in this repository.getEnvironmentPublicKey
(String environment) Fetches the public key of the given environment in this repository.getEnvironmentSecret
(String environment, String name) Fetches the secret with the given name in the specified environment.getEnvironmentVariable
(String environment, String name) Fetches the variable with the given name in the specified environment.int
getForks()
Returns the number of forks of this repository.int
Returns the number of forks of this repository.Returns the URL for fetching forks of this repository.Returns the full name of this repository.Returns the URL for fetching git commits in this repository.Returns the URL for fetching git references in this repository.Returns the URL for fetching git tags in this repository.Returns the git URL of this repository.Returns the homepage URL of this repository.Returns the URL for fetching hooks in this repository.getIssueById
(int id) Fetches the issue with the given ID in this repository.Returns the URL for fetching issue comments in this repository.Returns the URL for fetching issue events in this repository.Fetches the issues of this repository with the given state.Returns the URL for fetching issues in this repository.getJobFromWorkflowRun
(int id) Fetches the workflow job with the given ID in this repository.Returns the URL for fetching keys in this repository.Returns the URL for fetching labels in this repository.Returns the primary programming language used in this repository.Returns the URL for fetching languages used in this repository.Returns the license associated with this repository.Returns the URL for fetching merges in this repository.Returns the URL for fetching milestones in this repository.Returns the mirror URL of this repository.getName()
Returns the name of this repository.Returns the URL for fetching notifications in this repository.int
Returns the number of open issues in this repository.int
Returns the number of open issues in this repository.getOwner()
Returns the owner of this repository.Returns the permissions associated with this repository.Fetches the public key of this repository.Returns the URL for fetching pull requests in this repository.Returns the date and time when this repository was last pushed to.Returns the URL for fetching releases in this repository.static GHRepository
getRepository
(Github github, String owner, String name) Fetches and returns a GitHub repository based on the provided owner and name.Fetches the secret with the given name in this repository.int
getSize()
Returns the size of this repository.Returns the SSH URL of this repository.int
Returns the number of stargazers for this repository.Returns the URL for fetching stargazers of this repository.Returns the URL for fetching statuses in this repository.Returns the URL for fetching subscribers of this repository.Returns the URL for subscribing to this repository.Returns the SVN URL of this repository.Returns the URL for fetching tags in this repository.Returns the URL for fetching teams associated with this repository.Returns the list of topics associated with this repository.Returns the URL for fetching trees in this repository.Returns the date and time when this repository was last updated.getVariable
(String name) Fetches the variable with the given name in this repository.Returns the visibility of this repository.int
Returns the number of watchers of this repository.int
Returns the number of watchers in this repository.getWorkflowRun
(int id) Fetches the workflow run with the given ID in this repository.boolean
hasPullRequestsWithState
(GHState state) Checks if this repository has any pull requests with the given state.boolean
Returns whether forking is allowed for this repository.boolean
Returns whether this repository is archived.boolean
Returns whether this repository is disabled.boolean
isFork()
Returns whether this repository is a fork.boolean
Returns whether this repository has discussions enabled.boolean
Returns whether this repository has downloads enabled.boolean
Returns whether this repository has issues enabled.boolean
Returns whether this repository has GitHub Pages enabled.boolean
Returns whether this repository has projects enabled.boolean
Returns whether this repository has a wiki enabled.boolean
Returns whether this repository is private.boolean
Returns whether this repository is a template repository.boolean
Returns whether web commit signoff is required for this repository.Fetches the list of actions caches in this repository.Fetches the list of artifacts in this repository.listEnvironmentSecrets
(String environment) Fetches the list of environment secrets in this repository.listEnvironmentVariables
(String environment) Fetches the list of environment variables in the specified environment.Fetches the list of events in this repository.listJobsForWorkflowAttempt
(int id, int attempt) Fetches the list of jobs for the specified workflow attempt.listJobsFromWorkflowRun
(int id) Fetches the list of jobs in the specified workflow run.Fetches the list of organisation secrets in this repository.Fetches the list of organisation variables in this repository.Fetches the list of pull requests in this repository.Fetches the list of repository secrets in this repository.Fetches the list of repository variables in this repository.void
updateHomePage
(String homepageUrl) Updates the homepage of this repository.void
updateTopics
(List<String> topics) Updates the topics of this repository.Methods inherited from class io.github.coho04.githubapi.bases.ClassBase
getEventsUrl, getHtmlUrl, getId, getNodeId, getUrl, toJSONObject
Methods inherited from class io.github.coho04.githubapi.bases.GHBase
fetchArrayData, fetchArrayData, fetchPaginatedData, fetchPaginatedData, fetchPaginatedData, getBaseUrl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.coho04.githubapi.interfaces.HttpRequestInterface
extractNextPageUrl, sendDeleteRequest, sendDeleteRequestWithResponseCode, sendGetRequest, sendGetRequestWithLinkHeader, sendGetRequestWithResponseCode, sendPatchRequest, sendPostRequest, sendPutRequest
Methods inherited from interface io.github.coho04.githubapi.interfaces.JSONHelper
getArrayOrNull, getBooleanOrNull, getIntOrNull, getJSONArrayToStringList, getJSONObjectOrNull, getLocalDateOrNull, getLongOrNull, getStringOrNull
-
Constructor Details
-
GHRepository
Constructs a new GHRepository instance with the provided JSON object and GitHub instance.- Parameters:
jsonObject
- the JSON object containing the repository datagithub
- the GitHub instance associated with this repository
-
-
Method Details
-
getRepository
Fetches and returns a GitHub repository based on the provided owner and name.- Parameters:
github
- the GitHub instance associated with this repositoryowner
- the username of the owner of the repositoryname
- the name of the repository- Returns:
- a GHRepository instance representing the fetched repository
-
createIssue
Creates a new issue in this repository with the given title.- Parameters:
title
- the title of the new issue- Returns:
- a GHIssueBuilder instance for building the new issue
-
getBranches
Fetches the branches of this repository.- Returns:
- a HashMap mapping branch names to GHBranch instances
-
getContributors
Fetches the contributors of this repository.- Returns:
- a List of GHUser instances representing the contributors of this repository
-
getIssues
Fetches the issues of this repository with the given state.- Returns:
- a List of GHIssue instances representing the issues of this repository with the given state
-
getIssueById
Fetches the issue with the given ID in this repository.- Parameters:
id
- the ID of the issue to fetch- Returns:
- a GHIssue instance representing the fetched issue
-
addFile
Starts the process of adding a new file to this repository.- Returns:
- a GHFileBuilder instance for building the new file
-
addFile
Starts the process of adding a new file to the given branch of this repository.- Parameters:
branch
- the branch to add the new file to- Returns:
- a GHFileBuilder instance for building the new file
-
addFile
Starts the process of adding a new file with the given path, content, and commit message to the given branch of this repository.- Parameters:
branch
- the branch to add the new file topath
- the path of the new filecontent
- the content of the new filemessage
- the commit message for the new file- Returns:
- a GHFileBuilder instance for building the new file
-
getAllFilenames
Fetches all filenames in this repository.- Returns:
- a List of Strings representing all filenames in this repository
-
getDirectoryContent
Fetches the content of the directory at the given path in this repository.- Parameters:
path
- the path of the directory- Returns:
- a List of GHFile instances representing the content of the directory
-
getDirectoryContentWithFileContent
Fetches the content of the directory at the given path in this repository, including the content of each file.- Parameters:
path
- the path of the directory- Returns:
- a List of GHFile instances representing the content of the directory
-
getForks
public int getForks()Returns the number of forks of this repository.- Returns:
- the number of forks
-
getOpenIssuesCount
public int getOpenIssuesCount()Returns the number of open issues in this repository.- Returns:
- the number of open issues
-
getSize
public int getSize()Returns the size of this repository.- Returns:
- the size of the repository
-
getStargazersCount
public int getStargazersCount()Returns the number of stargazers for this repository.- Returns:
- the number of stargazers
-
getPermissions
Returns the permissions associated with this repository.- Returns:
- the permissions
-
getPushedAt
Returns the date and time when this repository was last pushed to.- Returns:
- the date and time of the last push
-
getBranchesUrl
Returns the URL for fetching the branches of this repository.- Returns:
- the branches URL
-
getIssueCommentUrl
Returns the URL for fetching issue comments in this repository.- Returns:
- the issue comment URL
-
getArchiveUrl
Returns the URL for fetching the archive of this repository.- Returns:
- the archive URL
-
getLabelsUrl
Returns the URL for fetching labels in this repository.- Returns:
- the labels URL
-
getLanguage
Returns the primary programming language used in this repository.- Returns:
- the programming language
-
getReleasesUrl
Returns the URL for fetching releases in this repository.- Returns:
- the releases URL
-
getSubscribersUrl
Returns the URL for fetching subscribers of this repository.- Returns:
- the subscribers URL
-
getSubscriptionUrl
Returns the URL for subscribing to this repository.- Returns:
- the subscription URL
-
getForksUrl
Returns the URL for fetching forks of this repository.- Returns:
- the forks URL
-
getGitRefsUrl
Returns the URL for fetching git references in this repository.- Returns:
- the git references URL
-
getWatchers
public int getWatchers()Returns the number of watchers of this repository.- Returns:
- the number of watchers
-
getSvnUrl
Returns the SVN URL of this repository.- Returns:
- the SVN URL
-
getCreatedAt
Returns the date and time when this repository was created.- Returns:
- the creation date and time
-
getUpdatedAt
Returns the date and time when this repository was last updated.- Returns:
- the update date and time
-
getBlobsUrl
Returns the URL for fetching blobs in this repository.- Returns:
- the blobs URL
-
getCloneUrl
Returns the clone URL of this repository.- Returns:
- the clone URL
-
getCollaboratorsUrl
Returns the URL for fetching collaborators of this repository.- Returns:
- the collaborators URL
-
getCommentsUrl
Returns the URL for fetching comments in this repository.- Returns:
- the comments URL
-
getCommitsUrl
Returns the URL for fetching commits in this repository.- Returns:
- the commits URL
-
getVisibility
Returns the visibility of this repository.- Returns:
- the visibility
-
getCompareUrl
Returns the URL for comparing commits in this repository.- Returns:
- the compare URL
-
getContentsUrl
Returns the URL for fetching contents of this repository.- Returns:
- the contents URL
-
getContributorsUrl
Returns the URL for fetching contributors to this repository.- Returns:
- the contributors URL
-
getDefaultBranch
Returns the default branch of this repository.- Returns:
- the default branch
-
getDeploymentsUrl
Returns the URL for fetching deployments in this repository.- Returns:
- the deployments URL
-
getDescription
Returns the description of this repository.- Returns:
- the description
-
getDownloadsUrl
Returns the URL for fetching downloads in this repository.- Returns:
- the downloads URL
-
getStatusesUrl
Returns the URL for fetching statuses in this repository.- Returns:
- the statuses URL
-
getFullName
Returns the full name of this repository.- Returns:
- the full name
-
getGitCommitsUrl
Returns the URL for fetching git commits in this repository.- Returns:
- the git commits URL
-
getLanguagesUrl
Returns the URL for fetching languages used in this repository.- Returns:
- the languages URL
-
getGitTagsUrl
Returns the URL for fetching git tags in this repository.- Returns:
- the git tags URL
-
getGitUrl
Returns the git URL of this repository.- Returns:
- the git URL
-
getSshUrl
Returns the SSH URL of this repository.- Returns:
- the SSH URL
-
getAssigneesUrl
Returns the URL for fetching assignees in this repository.- Returns:
- the assignees URL
-
getOpenIssues
public int getOpenIssues()Returns the number of open issues in this repository.- Returns:
- the number of open issues
-
getWatchersCount
public int getWatchersCount()Returns the number of watchers in this repository.- Returns:
- the watchers count
-
getHooksUrl
Returns the URL for fetching hooks in this repository.- Returns:
- the hooks URL
-
getIssueEventsUrl
Returns the URL for fetching issue events in this repository.- Returns:
- the issue events URL
-
getHomepage
Returns the homepage URL of this repository.- Returns:
- the homepage URL
-
getIssuesUrl
Returns the URL for fetching issues in this repository.- Returns:
- the issues URL
-
getForksCount
public int getForksCount()Returns the number of forks of this repository.- Returns:
- the forks count
-
getKeysUrl
Returns the URL for fetching keys in this repository.- Returns:
- the keys URL
-
getMergesUrl
Returns the URL for fetching merges in this repository.- Returns:
- the merges URL
-
getMilestonesUrl
Returns the URL for fetching milestones in this repository.- Returns:
- the milestones URL
-
getMirrorUrl
Returns the mirror URL of this repository.- Returns:
- the mirror URL
-
getName
Returns the name of this repository.- Returns:
- the name
-
getNotificationsUrl
Returns the URL for fetching notifications in this repository.- Returns:
- the notifications URL
-
getPullsUrl
Returns the URL for fetching pull requests in this repository.- Returns:
- the pulls URL
-
getStargazersUrl
Returns the URL for fetching stargazers of this repository.- Returns:
- the stargazers URL
-
getTagsUrl
Returns the URL for fetching tags in this repository.- Returns:
- the tags URL
-
getTeamsUrl
Returns the URL for fetching teams associated with this repository.- Returns:
- the teams URL
-
getTreesUrl
Returns the URL for fetching trees in this repository.- Returns:
- the trees URL
-
isWebCommitSignoffRequired
public boolean isWebCommitSignoffRequired()Returns whether web commit signoff is required for this repository.- Returns:
- true if web commit signoff is required, false otherwise
-
isHasDiscussions
public boolean isHasDiscussions()Returns whether this repository has discussions enabled.- Returns:
- true if discussions are enabled, false otherwise
-
isAllowForking
public boolean isAllowForking()Returns whether forking is allowed for this repository.- Returns:
- true if forking is allowed, false otherwise
-
isTemplate
public boolean isTemplate()Returns whether this repository is a template repository.- Returns:
- true if this is a template repository, false otherwise
-
isArchived
public boolean isArchived()Returns whether this repository is archived.- Returns:
- true if this repository is archived, false otherwise
-
isDisabled
public boolean isDisabled()Returns whether this repository is disabled.- Returns:
- true if this repository is disabled, false otherwise
-
isFork
public boolean isFork()Returns whether this repository is a fork.- Returns:
- true if this repository is a fork, false otherwise
-
isHasPages
public boolean isHasPages()Returns whether this repository has GitHub Pages enabled.- Returns:
- true if GitHub Pages is enabled, false otherwise
-
isHasDownloads
public boolean isHasDownloads()Returns whether this repository has downloads enabled.- Returns:
- true if downloads are enabled, false otherwise
-
isHasProjects
public boolean isHasProjects()Returns whether this repository has projects enabled.- Returns:
- true if projects are enabled, false otherwise
-
isHasWiki
public boolean isHasWiki()Returns whether this repository has a wiki enabled.- Returns:
- true if the wiki is enabled, false otherwise
-
isPrivate
public boolean isPrivate()Returns whether this repository is private.- Returns:
- true if this repository is private, false otherwise
-
isHasIssues
public boolean isHasIssues()Returns whether this repository has issues enabled.- Returns:
- true if issues are enabled, false otherwise
-
getTopics
Returns the list of topics associated with this repository.- Returns:
- the list of topics
-
getLicense
Returns the license associated with this repository.- Returns:
- the license
-
getOwner
Returns the owner of this repository.- Returns:
- the owner
-
listPullRequests
Fetches the list of pull requests in this repository.- Returns:
- a List of GHPullRequest instances representing the pull requests in this repository
-
hasPullRequestsWithState
Checks if this repository has any pull requests with the given state.- Parameters:
state
- the state of the pull requests to check for- Returns:
- true if this repository has any pull requests with the given state, false otherwise
-
updateTopics
Updates the topics of this repository.- Parameters:
topics
- the new topics
-
updateHomePage
Updates the homepage of this repository. -
listEvents
Fetches the list of events in this repository.- Returns:
- a List of GHEvent instances representing the events in this repository
-
listArtifacts
Fetches the list of artifacts in this repository.- Returns:
- a List of GHArtifact instances representing the artifacts in this repository
-
getArtifact
Fetches the artifact with the given ID in this repository.- Parameters:
id
- the ID of the artifact- Returns:
- a GHArtifact instance representing the artifact with the given ID
-
deleteArtifact
Deletes the artifact with the given ID in this repository.- Parameters:
id
- the ID of the artifact- Returns:
- true if the artifact was successfully deleted, false otherwise
-
getCache
Fetches the cache of this repository.- Returns:
- a GHRepositoryCache instance representing the cache of this repository
-
listActionsCaches
Fetches the list of actions caches in this repository.- Returns:
- a List of GHActionsCache instances representing the actions caches in this repository
-
deleteActionsCache
Deletes the actions cache with the given key in this repository.- Parameters:
key
- the key of the actions cache
-
deleteActionsCache
public boolean deleteActionsCache(int id) Deletes the actions cache with the given ID in this repository.- Parameters:
id
- the ID of the actions cache- Returns:
- true if the actions cache was successfully deleted, false otherwise
-
listOrganisationSecrets
Fetches the list of organisation secrets in this repository.- Returns:
- a List of GHSecret instances representing the organisation secrets in this repository
-
listRepositorySecrets
Fetches the list of repository secrets in this repository.- Returns:
- a List of GHSecret instances representing the repository secrets in this repository
-
getPublicKey
Fetches the public key of this repository.- Returns:
- a GHPublicKey instance representing the public key of this repository
-
getSecret
Fetches the secret with the given name in this repository.- Parameters:
name
- the name of the secret- Returns:
- a GHSecret instance representing the secret with the given name
-
listEnvironmentSecrets
Fetches the list of environment secrets in this repository.- Parameters:
environment
- the name of the environment- Returns:
- a List of GHSecret instances representing the environment secrets in this repository
-
getEnvironmentPublicKey
Fetches the public key of the given environment in this repository.- Parameters:
environment
- the name of the environment- Returns:
- a GHPublicKey instance representing the public key of the environment
-
getEnvironmentSecret
Fetches the secret with the given name in the specified environment.- Parameters:
environment
- the name of the environmentname
- the name of the secret- Returns:
- a GHSecret instance representing the secret with the given name
-
listOrganisationVariables
Fetches the list of organisation variables in this repository.- Returns:
- a List of GHVariable instances representing the organisation variables in this repository
-
listRepositoryVariables
Fetches the list of repository variables in this repository.- Returns:
- a List of GHVariable instances representing the repository variables in this repository
-
getVariable
Fetches the variable with the given name in this repository.- Parameters:
name
- the name of the variable- Returns:
- a GHVariable instance representing the variable with the given name
-
listEnvironmentVariables
Fetches the list of environment variables in the specified environment.- Parameters:
environment
- the name of the environment- Returns:
- a List of GHVariable instances representing the environment variables
-
getEnvironmentVariable
Fetches the variable with the given name in the specified environment.- Parameters:
environment
- the name of the environmentname
- the name of the variable- Returns:
- a GHVariable instance representing the variable with the given name
-
getJobFromWorkflowRun
Fetches the workflow job with the given ID in this repository.- Parameters:
id
- the ID of the workflow job- Returns:
- a GHWorkflowJob instance representing the workflow job with the given ID
-
listJobsFromWorkflowRun
Fetches the list of jobs in the specified workflow run.- Parameters:
id
- the ID of the workflow run- Returns:
- a List of GHWorkflowJob instances representing the jobs in the workflow run
-
listJobsForWorkflowAttempt
Fetches the list of jobs for the specified workflow attempt.- Parameters:
id
- the ID of the workflow runattempt
- the attempt number- Returns:
- a List of GHWorkflowJob instances representing the jobs for the workflow attempt
-
getWorkflowRun
Fetches the workflow run with the given ID in this repository.- Parameters:
id
- the ID of the workflow run- Returns:
- a GHWorkflowRun instance representing the workflow run with the given ID
-
createProject
Creates a project in the organization. -
createProject
Creates a project in the organization.
-