Class GHOrganisation

All Implemented Interfaces:
HttpRequestInterface, JSONHelper

public class GHOrganisation extends EntityBase
Represents a GitHub organization. This class provides methods and properties to access information about an organization on GitHub.
  • Constructor Details

    • GHOrganisation

      public GHOrganisation(Github github, org.json.JSONObject jsonObject, String name)
      Constructs a new GHOrganisation instance with the provided GitHub instance, JSON object, and name.
      Parameters:
      github - the GitHub instance
      jsonObject - the JSON object containing the organization data
      name - the name of the organization
  • Method Details

    • getOrganisation

      public static GHOrganisation getOrganisation(Github github, String name)
      Fetches a GitHub organization by its name.
      Parameters:
      github - the GitHub instance
      name - the name of the organization to fetch
      Returns:
      a GHOrganisation instance representing the fetched organization
    • findRepositoryByName

      public GHRepository findRepositoryByName(String name)
      Finds a repository by its name within the organization.
      Parameters:
      name - the name of the repository to find
      Returns:
      a GHRepository instance representing the found repository
    • getRepositories

      public List<GHRepository> getRepositories()
      Returns a list of repositories within the organization.
      Returns:
      a list of GHRepository instances
    • getName

      public String getName()
      Returns the name of the organization.
      Returns:
      the name of the organization
    • getDescription

      public String getDescription()
      Returns the description of the organization.
      Returns:
      the description of the organization
    • getGithub

      public Github getGithub()
      Returns the GitHub instance associated with this organization.
      Returns:
      the GitHub instance
    • getCompany

      public String getCompany()
      Returns the company associated with the organization.
      Returns:
      the company associated with the organization
    • getHooksUrl

      public String getHooksUrl()
      Returns the URL for fetching hooks of the organization.
      Returns:
      the hooks URL
    • getIssuesUrl

      public String getIssuesUrl()
      Returns the URL for fetching issues of the organization.
      Returns:
      the issues URL
    • getMembersUrl

      public String getMembersUrl()
      Returns the URL for fetching members of the organization.
      Returns:
      the members URL
    • getPublicMembersUrl

      public String getPublicMembersUrl()
      Returns the URL for fetching public members of the organization.
      Returns:
      the public members URL
    • getFollowers

      public int getFollowers()
      Returns the number of followers of the organization.
      Returns:
      the number of followers
    • getBlog

      public String getBlog()
      Returns the blog URL of the organization.
      Returns:
      the blog URL
    • getFollowing

      public int getFollowing()
      Returns the number of following of the organization.
      Returns:
      the number of following
    • getPublicGists

      public int getPublicGists()
      Returns the number of public gists of the organization.
      Returns:
      the number of public gists
    • getPublicRepos

      public int getPublicRepos()
      Returns the number of public repositories of the organization.
      Returns:
      the number of public repositories
    • getEmail

      public String getEmail()
      Returns the email of the organization.
      Returns:
      the email of the organization
    • getArchivedAt

      public OffsetDateTime getArchivedAt()
      Returns the date and time when the organization was archived.
      Returns:
      the archived date and time
    • getLocation

      public String getLocation()
      Returns the location of the organization.
      Returns:
      the location of the organization
    • getCreatedAt

      public OffsetDateTime getCreatedAt()
      Returns the creation date and time of the organization.
      Returns:
      the creation date and time
    • getTwitterUsername

      public String getTwitterUsername()
      Returns the Twitter username of the organization.
      Returns:
      the Twitter username
    • getUpdatedAt

      public OffsetDateTime getUpdatedAt()
      Returns the last updated date and time of the organization.
      Returns:
      the last updated date and time
    • isHasOrganizationProjects

      public boolean isHasOrganizationProjects()
      Returns whether the organization has organization projects enabled.
      Returns:
      true if organization projects are enabled, false otherwise
    • isHasRepositoryProjects

      public boolean isHasRepositoryProjects()
      Returns whether the organization has repository projects enabled.
      Returns:
      true if repository projects are enabled, false otherwise
    • isVerified

      public boolean isVerified()
      Returns whether the organization is verified.
      Returns:
      true if the organization is verified, false otherwise
    • getPlan

      public GHPlan getPlan()
      Returns the plan associated with the organization.
      Returns:
      the plan associated with the organization
    • getCollaborators

      public int getCollaborators()
      Returns the number of collaborators in the organization.
      Returns:
      the number of collaborators
    • getOwnedPrivateRepos

      public int getOwnedPrivateRepos()
      Returns the number of owned private repositories in the organization.
      Returns:
      the number of owned private repositories
    • getPrivateGists

      public int getPrivateGists()
      Returns the number of private gists in the organization.
      Returns:
      the number of private gists
    • getTotalPrivateRepos

      public int getTotalPrivateRepos()
      Returns the total number of private repositories in the organization.
      Returns:
      the total number of private repositories
    • getDiskUsage

      public long getDiskUsage()
      Returns the disk usage of the organization.
      Returns:
      the disk usage
    • getBillingEmail

      public String getBillingEmail()
      Returns the billing email of the organization.
      Returns:
      the billing email
    • getDefaultRepositoryPermission

      public String getDefaultRepositoryPermission()
      Returns the default repository permission for the organization.
      Returns:
      the default repository permission
    • getMembersAllowedRepositoryCreationType

      public String getMembersAllowedRepositoryCreationType()
      Returns the allowed repository creation type for members of the organization.
      Returns:
      the allowed repository creation type for members
    • getSecretScanningPushProtectionCustomLink

      public String getSecretScanningPushProtectionCustomLink()
      Returns the custom link for secret scanning push protection.
      Returns:
      the custom link for secret scanning push protection
    • isAdvancedSecurityEnabledForNewRepositories

      public boolean isAdvancedSecurityEnabledForNewRepositories()
      Returns whether advanced security is enabled for new repositories in the organization.
      Returns:
      true if advanced security is enabled for new repositories, false otherwise
    • isDependabotAlertsEnabledForNewRepositories

      public boolean isDependabotAlertsEnabledForNewRepositories()
      Returns whether Dependabot alerts are enabled for new repositories in the organization.
      Returns:
      true if Dependabot alerts are enabled for new repositories, false otherwise
    • isDependabotSecurityUpdatesEnabledForNewRepositories

      public boolean isDependabotSecurityUpdatesEnabledForNewRepositories()
      Returns whether Dependabot security updates are enabled for new repositories in the organization.
      Returns:
      true if Dependabot security updates are enabled for new repositories, false otherwise
    • isDependencyGraphEnabledForNewRepositories

      public boolean isDependencyGraphEnabledForNewRepositories()
      Returns whether the dependency graph is enabled for new repositories in the organization.
      Returns:
      true if the dependency graph is enabled for new repositories, false otherwise
    • isMembersCanCreateInternalRepositories

      public boolean isMembersCanCreateInternalRepositories()
      Returns whether members can create internal repositories in the organization.
      Returns:
      true if members can create internal repositories, false otherwise
    • isMembersCanCreatePages

      public boolean isMembersCanCreatePages()
      Returns whether members can create pages in the organization.
      Returns:
      true if members can create pages, false otherwise
    • isMembersCanCreatePrivatePages

      public boolean isMembersCanCreatePrivatePages()
      Returns whether members can create private pages in the organization.
      Returns:
      true if members can create private pages, false otherwise
    • isMembersCanCreatePrivateRepositories

      public boolean isMembersCanCreatePrivateRepositories()
      Returns whether members can create private repositories in the organization.
      Returns:
      true if members can create private repositories, false otherwise
    • isMembersCanCreatePublicPages

      public boolean isMembersCanCreatePublicPages()
      Returns whether members can create public pages in the organization.
      Returns:
      true if members can create public pages, false otherwise
    • isMembersCanCreatePublicRepositories

      public boolean isMembersCanCreatePublicRepositories()
      Returns whether members can create public repositories in the organization.
      Returns:
      true if members can create public repositories, false otherwise
    • isMembersCanCreateRepositories

      public boolean isMembersCanCreateRepositories()
      Returns whether members can create repositories in the organization.
      Returns:
      true if members can create repositories, false otherwise
    • isMembersCanForkPrivateRepositories

      public boolean isMembersCanForkPrivateRepositories()
      Returns whether members can fork private repositories in the organization.
      Returns:
      true if members can fork private repositories, false otherwise
    • isSecretScanningEnabledForNewRepositories

      public boolean isSecretScanningEnabledForNewRepositories()
      Returns whether secret scanning is enabled for new repositories in the organization.
      Returns:
      true if secret scanning is enabled for new repositories, false otherwise
    • isSecretScanningPushProtectionCustomLinkEnabled

      public boolean isSecretScanningPushProtectionCustomLinkEnabled()
      Returns whether the custom link for secret scanning push protection is enabled.
      Returns:
      true if the custom link for secret scanning push protection is enabled, false otherwise
    • isSecretScanningPushProtectionEnabledForNewRepositories

      public boolean isSecretScanningPushProtectionEnabledForNewRepositories()
      Returns whether secret scanning push protection is enabled for new repositories in the organization.
      Returns:
      true if secret scanning push protection is enabled for new repositories, false otherwise
    • isSecretScanningValidityChecksEnabled

      public boolean isSecretScanningValidityChecksEnabled()
      Returns whether secret scanning validity checks are enabled.
      Returns:
      true if secret scanning validity checks are enabled, false otherwise
    • isTwoFactorRequirementEnabled

      public boolean isTwoFactorRequirementEnabled()
      Returns whether two-factor authentication is required for members of the organization.
      Returns:
      true if two-factor authentication is required, false otherwise
    • isWebCommitSignoffRequired

      public boolean isWebCommitSignoffRequired()
      Returns whether web commit signoff is required for the organization.
      Returns:
      true if web commit signoff is required, false otherwise
    • getGivenName

      public String getGivenName()
      Returns the given name of the organization.
      Returns:
      the given name of the organization
    • toJSONObject

      public org.json.JSONObject toJSONObject()
      Converts this organization instance to a JSONObject.
      Overrides:
      toJSONObject in class EntityBase
      Returns:
      a JSONObject representation of this organization
    • getTeams

      public List<GHTeam> getTeams()
      Returns a list of teams within the organization.
      Returns:
      a list of GHTeam instances
    • listTeams

      public List<GHTeam> listTeams()
      Returns a list of teams within the organization.
      Returns:
      a list of GHTeam instances
    • findTeamByName

      public GHTeam findTeamByName(String name)
      Finds a team by its name within the organization.
      Parameters:
      name - the name of the team to find
      Returns:
      a GHTeam instance representing the found team
    • findTeamBySlug

      public GHTeam findTeamBySlug(String slug)
      Finds a team by its slug within the organization.
      Parameters:
      slug - the slug of the team to find
      Returns:
      a GHTeam instance representing the found team
    • hasMember

      public Boolean hasMember(@NotNull @NotNull GHUser user)
      Checks if a user is a member of the organization.
      Parameters:
      user - the user to check
      Returns:
      true if the user is a member, false otherwise
    • addMember

      public void addMember(String email, @NotNull @NotNull GHRole role, List<Integer> teamIds)
      Adds a member to the organization. This method sends a POST request to the GitHub API to add a member to the organization. The member is identified by their email, and the role they should have in the organization is specified. The member is also added to specific teams within the organization, identified by their IDs.
      Parameters:
      email - the email of the member to add
      role - the role the member should have in the organization
      teamIds - the IDs of the teams the member should be added to
    • removeMember

      public void removeMember(@NotNull @NotNull GHUser user)
      Removes a member from the organization.
      Parameters:
      user - the user to remove
    • hasPublicMember

      public Boolean hasPublicMember(GHUser user)
      Checks if a user is a public member of the organization.
      Parameters:
      user - the user to check
      Returns:
      true if the user is a public member, false otherwise
    • listMembers

      public List<GHUser> listMembers()
      Returns a list of members of the organization.
      Returns:
      a list of GHUser instances
    • listPublicMembers

      public List<GHUser> listPublicMembers()
      Returns a list of public members of the organization.
      Returns:
      a list of GHUser instances
    • listOutsideCollaborators

      public List<GHUser> listOutsideCollaborators()
      Returns a list of outside collaborators of the organization.
      Returns:
      a list of GHUser instances
    • listProjects

      public List<GHProject> listProjects()
      Returns a list of projects in the organization.
      Returns:
      a list of GHProject instances
    • createProject

      public GHProjectBuilder createProject()
      Creates a project in the organization.
    • createProject

      public GHProject createProject(String name, String body)
      Creates a project in the organization.
    • createTeam

      public GHTeam createTeam(String name)
      Creates a team in the organization.
      Parameters:
      name - the name of the team to create
    • createTeam

      public GHTeamBuilder createTeam()
      Creates a team in the organization.
      Returns:
      a TeamBuilder instance to build the team
    • getRepositorysWithOpenPullRequests

      public List<GHRepository> getRepositorysWithOpenPullRequests()
      Returns a list of repositories with open pull requests in the organization.
      Returns:
      a list of GHRepository instances
    • getPullRequests

      public List<GHRepository> getPullRequests()
      Returns a list of pull requests in the organization.
      Returns:
      a list of GHRepository instances
    • listEvents

      public List<GHEvent> listEvents()
      Returns a list of events in the organization.
      Returns:
      a list of GHEvent instances
    • getHooks

      public List<GHHook> getHooks()
      Returns a list of hooks in the organization.
      Returns:
      a list of GHHook instances
    • getHook

      public GHHook getHook(Long id)
      Returns a specific hook in the organization by its ID.
      Parameters:
      id - the ID of the hook to fetch
      Returns:
      a GHHook instance representing the fetched hook
    • getHook

      public GHHook getHook(int id)
      Returns a specific hook in the organization by its ID.
      Parameters:
      id - the ID of the hook to fetch
      Returns:
      a GHHook instance representing the fetched hook
    • createHook

      public GHHookBuilder createHook()
      Creates a hook in the organization.
    • deleteHook

      public void deleteHook(Long id)
      Deletes a hook in the organization by its ID.
      Parameters:
      id - the ID of the hook to delete
    • listDockerConflictsPackages

      public List<GHPackage> listDockerConflictsPackages()
      Returns a list of Docker conflict packages in the organization.
      Returns:
      a list of GHPackage instances
    • listPackages

      public List<GHPackage> listPackages(GHPackageType packageType)
      Returns a list of packages in the organization filtered by package type.
      Parameters:
      packageType - the type of packages to list
      Returns:
      a list of GHPackage instances
    • getPackage

      public GHPackage getPackage(String name, GHPackageType packageType)
      Returns a specific package in the organization by its name and package type.
      Parameters:
      name - the name of the package
      packageType - the type of the package
      Returns:
      a GHPackage instance representing the fetched package
    • listSecretScanningAlerts

      public List<GHAlert> listSecretScanningAlerts()
      Returns a list of secret scanning alerts in the organization.
      Returns:
      a list of GHAlert instances
    • getCacheUsageActiveCount

      public int getCacheUsageActiveCount()
      Returns the total active cache usage count for the organization.
      Returns:
      the total active cache usage count
    • getCacheUsageSizeInBytes

      public int getCacheUsageSizeInBytes()
      Returns the total active cache usage size in bytes for the organization.
      Returns:
      the total active cache usage size in bytes
    • listRepositoryCaches

      public List<GHRepositoryCache> listRepositoryCaches()
      Returns a list of repository caches in the organization.
      Returns:
      a list of GHRepositoryCache instances
    • listSecrets

      public List<GHSecret> listSecrets()
      Returns a list of secrets in the organization.
      Returns:
      a list of GHSecret instances
    • getPublicKey

      public GHPublicKey getPublicKey()
      Returns the public key for secrets in the organization.
      Returns:
      a GHPublicKey instance representing the public key
    • getSecret

      public GHSecret getSecret(String name)
      Returns a specific secret in the organization by its name.
      Parameters:
      name - the name of the secret to fetch
      Returns:
      a GHSecret instance representing the fetched secret
    • deleteSecret

      public boolean deleteSecret(String name)
      Deletes a specific secret in the organization by its name.
      Parameters:
      name - the name of the secret to delete
      Returns:
      true if the secret was deleted successfully, false otherwise
    • listSecretRepositorys

      public List<GHRepository> listSecretRepositorys()
      Returns a list of repositories associated with a specific secret in the organization.
      Returns:
      a list of GHRepository instances
    • deleteRepositoryFromSecret

      public boolean deleteRepositoryFromSecret(String secretName, String repoId)
      Deletes a repository from a specific secret in the organization by secret name and repository ID.
      Parameters:
      secretName - the name of the secret
      repoId - the ID of the repository
      Returns:
      true if the repository was deleted successfully, false otherwise
    • listVariables

      public List<GHVariable> listVariables()
      Returns a list of variables in the organization.
      Returns:
      a list of GHVariable instances
    • getVariable

      public GHVariable getVariable(String name)
      Returns a specific variable in the organization by its name.
      Parameters:
      name - the name of the variable to fetch
      Returns:
      a GHVariable instance representing the fetched variable
    • listVariableRepositorys

      public List<GHRepository> listVariableRepositorys(String name)
      Returns a list of repositories associated with a specific variable in the organization.
      Parameters:
      name - the name of the variable
      Returns:
      a list of GHRepository instances