Class SpaceClient
- java.lang.Object
-
- jetbrains.buildServer.serverSide.oauth.space.SpaceClient
-
public class SpaceClient extends Object
-
-
Constructor Summary
Constructors Constructor Description SpaceClient(com.google.gson.Gson gson, KeyStore keyStore, HTTPRequestBuilder.RequestHandler requestHandler, String spaceHostUrl, String rootUrl, String secret, String clientId, boolean allowNonSecureConnections, String syncEpoch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SpaceApplication
createChildApplication(String name)
Requests the creation of a Space application on behalf of the current Space applicationString
createUserPermanentToken(String accessToken, String name, String scope)
SpaceAccessToken
exchangeAuthCodeForAccessToken(String code, String redirectUrl)
List<GetAllCodeReviewsResponse.Review>
getAllCodeReviewsByProjectKey(String accessToken, String projectKey, int maxPages)
List<SpaceProject>
getAllMyProjects(String accessToken)
Lists all Space projects / repositories the user can see.List<SpaceProject>
getAllProjects(String accessToken)
Lists all Space projects / repositories depending on the access token.SpaceApplicationDTO
getApplication()
Retrieves the current application and its settings from Space.List<PermissionContext>
getApplicationAuthorizedContexts()
Retrieves all currently authorized contexts of the current application.List<String>
getApplicationAuthorizedProjectKeys()
Retrieves all currently authorized project's project keys of the current application.SpaceJwks
getApplicationPublicKeys()
Retrieves the public keys associated with the current application in form of a JSON Web Key Set (JWKS).SpaceApplicationRights
getApplicationRights(String contextIdentifier)
Retrieves all rights of the current application for the given context identifier.String
getClientSecret(SpaceAccessToken applicationToken, String clientId)
GetAllCodeReviewsResponse.Review
getCodeReview(String accessToken, String projectId, String reviewNumber)
BufferedImage
getImage(String accessToken, String imageCode)
BufferedImage
getMyAvatar(String accessToken)
SpaceUser
getProfile(String accessToken)
Optional<SpaceProject>
getProject(String accessToken, String projectKey, boolean includeRepos)
List<String>
getProjectsId(String accessToken)
String
getRepositoryUrl(String accessToken, String projectId, String repositoryName)
boolean
isPermissionReportExternalCheckEnabled(String accessToken, String projectId, String repository)
SpaceAccessToken
refreshToken(String refreshToken, String redirectUrl, String scope)
void
reportBuildFailedToMergeRequest(String accessToken, String codeReviewId, SBuild build)
void
reportBuildFinishedToMergeRequest(String accessToken, String codeReviewId, SBuild build)
void
reportBuildInterrupted(String accessToken, String codeReviewId, SBuild build)
void
reportBuildMarkedAsSuccessfulToMergeRequest(String accessToken, String codeReviewId, SBuild build)
void
reportBuildStartedToMergeRequest(String accessToken, String codeReviewId, SBuild build)
void
requestApplicationRights(String accssToken, String contextIdentifier, Set<SpaceRight> rights)
SpaceAccessToken
requestClientToken()
void
setupApplicationGettingStartedInfo(String callbackUrl, String applicationTitle, boolean useTab)
Sets up the Space Getting Started UI extension for this application.
-
-
-
Constructor Detail
-
SpaceClient
public SpaceClient(@NotNull com.google.gson.Gson gson, @Nullable KeyStore keyStore, @NotNull HTTPRequestBuilder.RequestHandler requestHandler, @NotNull String spaceHostUrl, @NotNull String rootUrl, @NotNull String secret, @NotNull String clientId, boolean allowNonSecureConnections, @Nullable String syncEpoch)
-
-
Method Detail
-
exchangeAuthCodeForAccessToken
@NotNull public SpaceAccessToken exchangeAuthCodeForAccessToken(@NotNull String code, @NotNull String redirectUrl) throws Exception
- Throws:
Exception
-
refreshToken
@NotNull public SpaceAccessToken refreshToken(@NotNull String refreshToken, @NotNull String redirectUrl, @NotNull String scope)
-
getMyAvatar
@Nullable public BufferedImage getMyAvatar(@NotNull String accessToken)
-
getImage
@Nullable public BufferedImage getImage(@NotNull String accessToken, @NotNull String imageCode)
-
getCodeReview
@Nullable public GetAllCodeReviewsResponse.Review getCodeReview(@NotNull String accessToken, @NotNull String projectId, @NotNull String reviewNumber)
-
getAllCodeReviewsByProjectKey
@NotNull public List<GetAllCodeReviewsResponse.Review> getAllCodeReviewsByProjectKey(@NotNull String accessToken, @NotNull String projectKey, int maxPages)
-
requestClientToken
@NotNull public SpaceAccessToken requestClientToken()
-
createUserPermanentToken
@NotNull public String createUserPermanentToken(@NotNull String accessToken, @NotNull String name, @NotNull String scope)
-
reportBuildStartedToMergeRequest
public void reportBuildStartedToMergeRequest(@NotNull String accessToken, @NotNull String codeReviewId, @NotNull SBuild build)
-
reportBuildFinishedToMergeRequest
public void reportBuildFinishedToMergeRequest(@NotNull String accessToken, @NotNull String codeReviewId, @NotNull SBuild build)
-
reportBuildFailedToMergeRequest
public void reportBuildFailedToMergeRequest(@NotNull String accessToken, @NotNull String codeReviewId, @NotNull SBuild build)
-
reportBuildInterrupted
public void reportBuildInterrupted(@NotNull String accessToken, @NotNull String codeReviewId, @NotNull SBuild build)
-
reportBuildMarkedAsSuccessfulToMergeRequest
public void reportBuildMarkedAsSuccessfulToMergeRequest(@NotNull String accessToken, @NotNull String codeReviewId, @NotNull SBuild build)
-
isPermissionReportExternalCheckEnabled
public boolean isPermissionReportExternalCheckEnabled(@NotNull String accessToken, @NotNull String projectId, @NotNull String repository)
-
getAllMyProjects
@NotNull public List<SpaceProject> getAllMyProjects(@NotNull String accessToken)
Lists all Space projects / repositories the user can see. Can not be used for non-user tokens.- Parameters:
accessToken
- a user access token- Returns:
- found Space projects with their repositories
-
getAllProjects
@NotNull public List<SpaceProject> getAllProjects(@NotNull String accessToken)
Lists all Space projects / repositories depending on the access token. Can be used to get a Space application specific view.- Parameters:
accessToken
- a Space access token- Returns:
- found Space projects with their repositories
-
getProject
public Optional<SpaceProject> getProject(@NotNull String accessToken, @NotNull String projectKey, boolean includeRepos)
-
getRepositoryUrl
@Nullable public String getRepositoryUrl(@NotNull String accessToken, @NotNull String projectId, @NotNull String repositoryName)
-
requestApplicationRights
public void requestApplicationRights(@NotNull String accssToken, @NotNull String contextIdentifier, @NotNull Set<SpaceRight> rights)
-
createChildApplication
@NotNull public SpaceApplication createChildApplication(@NotNull String name)
Requests the creation of a Space application on behalf of the current Space application- Returns:
- the created application with its credentials
-
getClientSecret
@NotNull public String getClientSecret(@NotNull SpaceAccessToken applicationToken, @NotNull String clientId)
-
getApplicationPublicKeys
public SpaceJwks getApplicationPublicKeys()
Retrieves the public keys associated with the current application in form of a JSON Web Key Set (JWKS).- Returns:
- JWKS
-
getApplicationRights
@NotNull public SpaceApplicationRights getApplicationRights(@NotNull String contextIdentifier)
Retrieves all rights of the current application for the given context identifier.Note: only currently supported types of
SpaceRight
will be available.- Parameters:
contextIdentifier
- Space context identifier- Returns:
- Map of rights to their respective status
-
getApplicationAuthorizedContexts
@NotNull public List<PermissionContext> getApplicationAuthorizedContexts()
Retrieves all currently authorized contexts of the current application.Note: currently unsupported types of
PermissionContext
will not be included.- Returns:
- list of permission context objects
-
getApplicationAuthorizedProjectKeys
@NotNull public List<String> getApplicationAuthorizedProjectKeys()
Retrieves all currently authorized project's project keys of the current application. This is implemented by getting all permission contexts (seegetApplicationAuthorizedContexts()
) and narrowing down to project permission contexts.- Returns:
- list of authorized project's project keys
-
getApplication
@NotNull public SpaceApplicationDTO getApplication()
Retrieves the current application and its settings from Space.- Returns:
- DTO for Space application
-
setupApplicationGettingStartedInfo
public void setupApplicationGettingStartedInfo(@NotNull String callbackUrl, @NotNull String applicationTitle, boolean useTab)
Sets up the Space Getting Started UI extension for this application. This enables the redirect back to TeamCity after application installation.- Parameters:
callbackUrl
- where the user will be redirected back toapplicationTitle
- title of the application in the Space UIuseTab
- whether a tab is used
-
-