-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bmoric/extract workspace api (#18996)
* Extract Operation API * Extract scheduler API * Format * extract source api * Extract source definition api * Add path * Extract State API * extract webbackend api * extract webbackend api * extract workspace api
- Loading branch information
1 parent
b05a5b2
commit 1cdf1ba
Showing
6 changed files
with
168 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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
78 changes: 78 additions & 0 deletions
78
airbyte-server/src/main/java/io/airbyte/server/apis/WorkspaceApiController.java
This file contains 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,78 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.WorkspaceApi; | ||
import io.airbyte.api.model.generated.ConnectionIdRequestBody; | ||
import io.airbyte.api.model.generated.SlugRequestBody; | ||
import io.airbyte.api.model.generated.WorkspaceCreate; | ||
import io.airbyte.api.model.generated.WorkspaceGiveFeedback; | ||
import io.airbyte.api.model.generated.WorkspaceIdRequestBody; | ||
import io.airbyte.api.model.generated.WorkspaceRead; | ||
import io.airbyte.api.model.generated.WorkspaceReadList; | ||
import io.airbyte.api.model.generated.WorkspaceUpdate; | ||
import io.airbyte.api.model.generated.WorkspaceUpdateName; | ||
import io.airbyte.server.handlers.WorkspacesHandler; | ||
import javax.ws.rs.Path; | ||
import lombok.AllArgsConstructor; | ||
|
||
@Path("/v1/workspaces") | ||
@AllArgsConstructor | ||
public class WorkspaceApiController implements WorkspaceApi { | ||
|
||
private final WorkspacesHandler workspacesHandler; | ||
|
||
@Override | ||
public WorkspaceRead createWorkspace(final WorkspaceCreate workspaceCreate) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.createWorkspace(workspaceCreate)); | ||
} | ||
|
||
@Override | ||
public void deleteWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
ConfigurationApi.execute(() -> { | ||
workspacesHandler.deleteWorkspace(workspaceIdRequestBody); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public WorkspaceRead getWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.getWorkspace(workspaceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public WorkspaceRead getWorkspaceBySlug(final SlugRequestBody slugRequestBody) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.getWorkspaceBySlug(slugRequestBody)); | ||
} | ||
|
||
@Override | ||
public WorkspaceReadList listWorkspaces() { | ||
return ConfigurationApi.execute(workspacesHandler::listWorkspaces); | ||
} | ||
|
||
@Override | ||
public WorkspaceRead updateWorkspace(final WorkspaceUpdate workspaceUpdate) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.updateWorkspace(workspaceUpdate)); | ||
} | ||
|
||
@Override | ||
public void updateWorkspaceFeedback(final WorkspaceGiveFeedback workspaceGiveFeedback) { | ||
ConfigurationApi.execute(() -> { | ||
workspacesHandler.setFeedbackDone(workspaceGiveFeedback); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public WorkspaceRead updateWorkspaceName(final WorkspaceUpdateName workspaceUpdateName) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.updateWorkspaceName(workspaceUpdateName)); | ||
} | ||
|
||
@Override | ||
public WorkspaceRead getWorkspaceByConnectionId(final ConnectionIdRequestBody connectionIdRequestBody) { | ||
return ConfigurationApi.execute(() -> workspacesHandler.getWorkspaceByConnectionId(connectionIdRequestBody)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/WorkspaceApiBinder.java
This file contains 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,21 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.binders; | ||
|
||
import io.airbyte.server.apis.WorkspaceApiController; | ||
import io.airbyte.server.apis.factories.WorkspaceApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class WorkspaceApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(WorkspaceApiFactory.class) | ||
.to(WorkspaceApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
airbyte-server/src/main/java/io/airbyte/server/apis/factories/WorkspaceApiFactory.java
This file contains 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,29 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.factories; | ||
|
||
import io.airbyte.server.apis.WorkspaceApiController; | ||
import io.airbyte.server.handlers.WorkspacesHandler; | ||
import org.glassfish.hk2.api.Factory; | ||
|
||
public class WorkspaceApiFactory implements Factory<WorkspaceApiController> { | ||
|
||
private static WorkspacesHandler workspacesHandler; | ||
|
||
public static void setValues(final WorkspacesHandler workspacesHandler) { | ||
WorkspaceApiFactory.workspacesHandler = workspacesHandler; | ||
} | ||
|
||
@Override | ||
public WorkspaceApiController provide() { | ||
return new WorkspaceApiController(WorkspaceApiFactory.workspacesHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final WorkspaceApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |