Class GHMyself


public class GHMyself extends GHUser
Represents the account that's logging into GitHub.
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • GHMyself

      public GHMyself()
      Create default GHMyself instance
  • Method Details

    • getEmails

      @Deprecated public List<String> getEmails() throws IOException
      Deprecated.
      Gets emails.
      Returns:
      the emails
      Throws:
      IOException - the io exception
    • getEmails2

      @Deprecated public List<GHEmail> getEmails2() throws IOException
      Deprecated.
      Returns the read-only list of e-mail addresses configured for you.

      This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with GHPerson.getEmail() that shows your public e-mail address set in https://github.com/settings/profile

      Returns:
      Always non-null.
      Throws:
      IOException - the io exception
    • listEmails

      public PagedIterable<GHEmail> listEmails()
      Returns the read-only list of e-mail addresses configured for you.

      This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with GHPerson.getEmail() that shows your public e-mail address set in https://github.com/settings/profile

      Returns:
      Always non-null.
    • getPublicKeys

      public List<GHKey> getPublicKeys() throws IOException
      Returns the read-only list of all the public keys of the current user.

      NOTE: When using OAuth authentication, the READ/WRITE User scope is required by the GitHub APIs, otherwise you will get a 404 NOT FOUND.

      Returns:
      Always non-null.
      Throws:
      IOException - the io exception
    • addPublicKey

      public GHKey addPublicKey(String title, String key) throws IOException
      Add public SSH key for the user.

      https://docs.github.com/en/rest/users/keys?apiVersion=2022-11-28#create-a-public-ssh-key-for-the-authenticated-user

      Parameters:
      title - Title of the SSH key
      key - the public key
      Returns:
      the newly created Github key
      Throws:
      IOException - the io exception
    • getPublicVerifiedKeys

      public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException
      Returns the read-only list of all the public verified keys of the current user.

      Differently from the getPublicKeys() method, the retrieval of the user's verified public keys does not require any READ/WRITE OAuth Scope to the user's profile.

      Returns:
      Always non-null.
      Throws:
      IOException - the io exception
    • getAllOrganizations

      public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException
      Gets the organization that this user belongs to.
      Returns:
      the all organizations
      Throws:
      IOException - the io exception
    • getAllRepositories

      public Map<String,GHRepository> getAllRepositories() throws IOException
      Gets the all repositories this user owns (public and private).
      Returns:
      the all repositories
      Throws:
      IOException - the io exception
    • listRepositories

      public PagedIterable<GHRepository> listRepositories()
      Lists up all repositories this user owns (public and private). Unlike getAllRepositories(), this does not wait until all the repositories are returned. Repositories are returned by GitHub API with a 30 items per page.
      Overrides:
      listRepositories in class GHPerson
      Returns:
      the paged iterable
    • listRepositories

      public PagedIterable<GHRepository> listRepositories(int pageSize)
      List repositories that are accessible to the authenticated user (public and private) using the specified page size. This includes repositories owned by the authenticated user, repositories that belong to other users where the authenticated user is a collaborator, and other organizations' repositories that the authenticated user has access to through an organization membership.
      Overrides:
      listRepositories in class GHPerson
      Parameters:
      pageSize - size for each page of items returned by GitHub. Maximum page size is 100. Unlike GHPerson.getRepositories(), this does not wait until all the repositories are returned.
      Returns:
      the paged iterable
    • listRepositories

      public PagedIterable<GHRepository> listRepositories(int pageSize, GHMyself.RepositoryListFilter repoType)
      List repositories of a certain type that are accessible by current authenticated user using the specified page size.
      Parameters:
      pageSize - size for each page of items returned by GitHub. Maximum page size is 100.
      repoType - type of repository returned in the listing
      Returns:
      the paged iterable
    • listOrgMemberships

      public PagedIterable<GHMembership> listOrgMemberships()
      List your organization memberships.
      Returns:
      the paged iterable
    • listOrgMemberships

      public PagedIterable<GHMembership> listOrgMemberships(GHMembership.State state)
      List your organization memberships.
      Parameters:
      state - Filter by a specific state
      Returns:
      the paged iterable
    • getMembership

      public GHMembership getMembership(GHOrganization o) throws IOException
      Gets your membership in a specific organization.
      Parameters:
      o - the o
      Returns:
      the membership
      Throws:
      IOException - the io exception
    • getAppInstallations

      public PagedIterable<GHAppInstallation> getAppInstallations()
      Lists installations of your GitHub App that the authenticated user has explicit permission to access. You must use a user-to-server OAuth access token, created for a user who has authorized your GitHub App, to access this endpoint.
      Returns:
      the paged iterable
      See Also: