Package org.kohsuke.github
Class GHMyself
- java.lang.Object
-
- org.kohsuke.github.GHObject
-
- org.kohsuke.github.GHPerson
-
- org.kohsuke.github.GHUser
-
- org.kohsuke.github.GHMyself
-
public class GHMyself extends GHUser
Represents the account that's logging into GitHub.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GHMyself.RepositoryListFilter
Type of repositories returned during listing.
-
Field Summary
-
Fields inherited from class org.kohsuke.github.GHPerson
avatar_url, bio, blog, company, email, followers, following, hireable, html_url, location, login, name, public_gists, public_repos, site_admin, total_private_repos, twitter_username, type
-
Fields inherited from class org.kohsuke.github.GHObject
responseHeaderFields
-
-
Constructor Summary
Constructors Constructor Description GHMyself()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description GHKey
addPublicKey(String title, String key)
Add public SSH key for the user.GHPersonSet<GHOrganization>
getAllOrganizations()
Gets the organization that this user belongs to.Map<String,GHRepository>
getAllRepositories()
Gets the all repositories this user owns (public and private).PagedIterable<GHAppInstallation>
getAppInstallations()
Lists installations of your GitHub App that the authenticated user has explicit permission to access.List<String>
getEmails()
Deprecated.UsegetEmails2()
List<GHEmail>
getEmails2()
Returns the read-only list of e-mail addresses configured for you.GHMembership
getMembership(GHOrganization o)
Gets your membership in a specific organization.List<GHKey>
getPublicKeys()
Returns the read-only list of all the public keys of the current user.List<GHVerifiedKey>
getPublicVerifiedKeys()
Returns the read-only list of all the public verified keys of the current user.GitHub
getRoot()
Deprecated.For access to theGitHub
instance, use a local copy instead of pulling it out of objects.PagedIterable<GHRepository>
listAllRepositories()
Deprecated.PagedIterable<GHMembership>
listOrgMemberships()
List your organization memberships.PagedIterable<GHMembership>
listOrgMemberships(GHMembership.State state)
List your organization memberships.PagedIterable<GHRepository>
listRepositories()
Lists up all repositories this user owns (public and private).PagedIterable<GHRepository>
listRepositories(int pageSize)
List repositories that are accessible to the authenticated user (public and private) using the specified page size.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.-
Methods inherited from class org.kohsuke.github.GHUser
equals, follow, getBio, getFollowers, getFollows, getKeys, getLdapDn, getOrganizations, hashCode, isHireable, isMemberOf, isMemberOf, isPublicMemberOf, listEvents, listFollowers, listFollows, listGists, listProjects, listStarredRepositories, listSubscriptions, unfollow
-
Methods inherited from class org.kohsuke.github.GHPerson
getAvatarUrl, getBlog, getCompany, getCreatedAt, getEmail, getFollowersCount, getFollowingCount, getGravatarId, getHtmlUrl, getLocation, getLogin, getName, getPublicGistCount, getPublicRepoCount, getRepositories, getRepository, getTotalPrivateRepoCount, getTwitterUsername, getType, getUpdatedAt, isSiteAdmin, iterateRepositories, populate
-
Methods inherited from class org.kohsuke.github.GHObject
getId, getNodeId, getResponseHeaderFields, getUrl, setResponseHeaderFields, toString
-
-
-
-
Method Detail
-
getEmails
public List<String> getEmails() throws IOException
Deprecated.UsegetEmails2()
Gets emails.- Returns:
- the emails
- Throws:
IOException
- the io exception
-
getEmails2
public List<GHEmail> getEmails2() throws IOException
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
-
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 keykey
- 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). UnlikegetAllRepositories()
, 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 classGHPerson
- 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 classGHPerson
- Parameters:
pageSize
- size for each page of items returned by GitHub. Maximum page size is 100. UnlikeGHPerson.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
-
listAllRepositories
@Deprecated public PagedIterable<GHRepository> listAllRepositories()
Deprecated.List all repositories paged iterable.- 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:
- List app installations accessible to the user access token
-
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
-
-