-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[public-api] Add installation service #19150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
components/dashboard/src/service/json-rpc-installation-client.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /** | ||
| * Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
| * Licensed under the GNU Affero General Public License (AGPL). | ||
| * See License.AGPL.txt in the project root for license information. | ||
| */ | ||
|
|
||
| import { CallOptions, PromiseClient } from "@connectrpc/connect"; | ||
| import { PartialMessage } from "@bufbuild/protobuf"; | ||
| import { InstallationService } from "@gitpod/public-api/lib/gitpod/v1/installation_connect"; | ||
| import { | ||
| ListBlockedRepositoriesRequest, | ||
| ListBlockedRepositoriesResponse, | ||
| CreateBlockedRepositoryRequest, | ||
| CreateBlockedRepositoryResponse, | ||
| DeleteBlockedRepositoryRequest, | ||
| DeleteBlockedRepositoryResponse, | ||
| ListBlockedEmailDomainsRequest, | ||
| ListBlockedEmailDomainsResponse, | ||
| CreateBlockedEmailDomainRequest, | ||
| CreateBlockedEmailDomainResponse, | ||
| } from "@gitpod/public-api/lib/gitpod/v1/installation_pb"; | ||
| import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; | ||
| import { getGitpodService } from "./service"; | ||
| import { converter } from "./public-api"; | ||
| import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb"; | ||
|
|
||
| export class JsonRpcInstallationClient implements PromiseClient<typeof InstallationService> { | ||
| async listBlockedRepositories( | ||
| request: PartialMessage<ListBlockedRepositoriesRequest>, | ||
| _options?: CallOptions | undefined, | ||
| ): Promise<ListBlockedRepositoriesResponse> { | ||
| // dashboard params is constant, no need to implement | ||
| const info = await getGitpodService().server.adminGetBlockedRepositories({ | ||
| limit: 100, | ||
| offset: 0, | ||
| orderBy: "urlRegexp", | ||
| orderDir: "asc", | ||
| searchTerm: request.searchTerm, | ||
| }); | ||
| return new ListBlockedRepositoriesResponse({ | ||
| blockedRepositories: info.rows.map((item) => converter.toBlockedRepository(item)), | ||
| pagination: new PaginationResponse(), | ||
| }); | ||
| } | ||
|
|
||
| async createBlockedRepository( | ||
| request: PartialMessage<CreateBlockedRepositoryRequest>, | ||
| _options?: CallOptions | undefined, | ||
| ): Promise<CreateBlockedRepositoryResponse> { | ||
| if (!request.urlRegexp) { | ||
| throw new ApplicationError(ErrorCodes.BAD_REQUEST, "urlRegexp is required"); | ||
| } | ||
| if (request.blockUser === undefined) { | ||
| throw new ApplicationError(ErrorCodes.BAD_REQUEST, "blockUser is required"); | ||
| } | ||
| const info = await getGitpodService().server.adminCreateBlockedRepository(request.urlRegexp, request.blockUser); | ||
| return new CreateBlockedRepositoryResponse({ | ||
| blockedRepository: converter.toBlockedRepository(info), | ||
| }); | ||
| } | ||
|
|
||
| async deleteBlockedRepository( | ||
| request: PartialMessage<DeleteBlockedRepositoryRequest>, | ||
| _options?: CallOptions | undefined, | ||
| ): Promise<DeleteBlockedRepositoryResponse> { | ||
| if (!request.blockedRepositoryId) { | ||
| throw new ApplicationError(ErrorCodes.BAD_REQUEST, "blockedRepositoryId is required"); | ||
| } | ||
| await getGitpodService().server.adminDeleteBlockedRepository(request.blockedRepositoryId); | ||
| return new DeleteBlockedRepositoryResponse(); | ||
| } | ||
|
|
||
| async listBlockedEmailDomains( | ||
| request: PartialMessage<ListBlockedEmailDomainsRequest>, | ||
| _options?: CallOptions | undefined, | ||
| ): Promise<ListBlockedEmailDomainsResponse> { | ||
| const info = await getGitpodService().server.adminGetBlockedEmailDomains(); | ||
| return new ListBlockedEmailDomainsResponse({ | ||
| blockedEmailDomains: info.map((item) => converter.toBlockedEmailDomain(item)), | ||
| pagination: new PaginationResponse(), | ||
| }); | ||
| } | ||
|
|
||
| async createBlockedEmailDomain( | ||
| request: PartialMessage<CreateBlockedEmailDomainRequest>, | ||
| _options?: CallOptions | undefined, | ||
| ): Promise<CreateBlockedEmailDomainResponse> { | ||
| if (!request.domain) { | ||
| throw new ApplicationError(ErrorCodes.BAD_REQUEST, "domain is required"); | ||
| } | ||
| if (request.negative === undefined) { | ||
| throw new ApplicationError(ErrorCodes.BAD_REQUEST, "negative is required"); | ||
| } | ||
| await getGitpodService().server.adminSaveBlockedEmailDomain({ | ||
| domain: request.domain, | ||
| negative: request.negative, | ||
| }); | ||
| // There's no way to get blockedEmailDomain, just ignore it since dashboard don't care about the response data | ||
| return new CreateBlockedEmailDomainResponse({}); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.