-
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.
Extract source definition api (#18977)
* Extract Operation API * Extract scheduler API * Format * extract source api * Extract source definition api * Add path
- Loading branch information
1 parent
f9863d6
commit 29676e1
Showing
7 changed files
with
245 additions
and
25 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
110 changes: 110 additions & 0 deletions
110
airbyte-server/src/main/java/io/airbyte/server/apis/SourceDefinitionApiController.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,110 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.SourceDefinitionApi; | ||
import io.airbyte.api.model.generated.CustomSourceDefinitionCreate; | ||
import io.airbyte.api.model.generated.CustomSourceDefinitionUpdate; | ||
import io.airbyte.api.model.generated.PrivateSourceDefinitionRead; | ||
import io.airbyte.api.model.generated.PrivateSourceDefinitionReadList; | ||
import io.airbyte.api.model.generated.SourceDefinitionCreate; | ||
import io.airbyte.api.model.generated.SourceDefinitionIdRequestBody; | ||
import io.airbyte.api.model.generated.SourceDefinitionIdWithWorkspaceId; | ||
import io.airbyte.api.model.generated.SourceDefinitionRead; | ||
import io.airbyte.api.model.generated.SourceDefinitionReadList; | ||
import io.airbyte.api.model.generated.SourceDefinitionUpdate; | ||
import io.airbyte.api.model.generated.WorkspaceIdRequestBody; | ||
import io.airbyte.server.handlers.SourceDefinitionsHandler; | ||
import javax.ws.rs.Path; | ||
import lombok.AllArgsConstructor; | ||
|
||
@Path("/v1/source_definitions") | ||
@AllArgsConstructor | ||
public class SourceDefinitionApiController implements SourceDefinitionApi { | ||
|
||
private final SourceDefinitionsHandler sourceDefinitionsHandler; | ||
|
||
@Override | ||
public SourceDefinitionRead createCustomSourceDefinition(final CustomSourceDefinitionCreate customSourceDefinitionCreate) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.createCustomSourceDefinition(customSourceDefinitionCreate)); | ||
} | ||
|
||
// TODO: Deprecate this route in favor of createCustomSourceDefinition | ||
// since all connector definitions created through the API are custom | ||
@Override | ||
public SourceDefinitionRead createSourceDefinition(final SourceDefinitionCreate sourceDefinitionCreate) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.createPrivateSourceDefinition(sourceDefinitionCreate)); | ||
} | ||
|
||
@Override | ||
public void deleteCustomSourceDefinition(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) { | ||
ConfigurationApi.execute(() -> { | ||
sourceDefinitionsHandler.deleteCustomSourceDefinition(sourceDefinitionIdWithWorkspaceId); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public void deleteSourceDefinition(final SourceDefinitionIdRequestBody sourceDefinitionIdRequestBody) { | ||
ConfigurationApi.execute(() -> { | ||
sourceDefinitionsHandler.deleteSourceDefinition(sourceDefinitionIdRequestBody); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionRead getSourceDefinition(final SourceDefinitionIdRequestBody sourceDefinitionIdRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.getSourceDefinition(sourceDefinitionIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionRead getSourceDefinitionForWorkspace(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.getSourceDefinitionForWorkspace(sourceDefinitionIdWithWorkspaceId)); | ||
} | ||
|
||
@Override | ||
public PrivateSourceDefinitionRead grantSourceDefinitionToWorkspace(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.grantSourceDefinitionToWorkspace(sourceDefinitionIdWithWorkspaceId)); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionReadList listLatestSourceDefinitions() { | ||
return ConfigurationApi.execute(sourceDefinitionsHandler::listLatestSourceDefinitions); | ||
} | ||
|
||
@Override | ||
public PrivateSourceDefinitionReadList listPrivateSourceDefinitions(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.listPrivateSourceDefinitions(workspaceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionReadList listSourceDefinitions() { | ||
return ConfigurationApi.execute(sourceDefinitionsHandler::listSourceDefinitions); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionReadList listSourceDefinitionsForWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.listSourceDefinitionsForWorkspace(workspaceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public void revokeSourceDefinitionFromWorkspace(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) { | ||
ConfigurationApi.execute(() -> { | ||
sourceDefinitionsHandler.revokeSourceDefinitionFromWorkspace(sourceDefinitionIdWithWorkspaceId); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionRead updateCustomSourceDefinition(final CustomSourceDefinitionUpdate customSourceDefinitionUpdate) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.updateCustomSourceDefinition(customSourceDefinitionUpdate)); | ||
} | ||
|
||
@Override | ||
public SourceDefinitionRead updateSourceDefinition(final SourceDefinitionUpdate sourceDefinitionUpdate) { | ||
return ConfigurationApi.execute(() -> sourceDefinitionsHandler.updateSourceDefinition(sourceDefinitionUpdate)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/SourceDefinitionApiBinder.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.SourceDefinitionApiController; | ||
import io.airbyte.server.apis.factories.SourceDefinitionApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class SourceDefinitionApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(SourceDefinitionApiFactory.class) | ||
.to(SourceDefinitionApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...yte-server/src/main/java/io/airbyte/server/apis/factories/SourceDefinitionApiFactory.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.SourceDefinitionApiController; | ||
import io.airbyte.server.handlers.SourceDefinitionsHandler; | ||
import org.glassfish.hk2.api.Factory; | ||
|
||
public class SourceDefinitionApiFactory implements Factory<SourceDefinitionApiController> { | ||
|
||
private static SourceDefinitionsHandler sourceDefinitionsHandler; | ||
|
||
public static void setValues(final SourceDefinitionsHandler sourceDefinitionsHandler) { | ||
SourceDefinitionApiFactory.sourceDefinitionsHandler = sourceDefinitionsHandler; | ||
} | ||
|
||
@Override | ||
public SourceDefinitionApiController provide() { | ||
return new SourceDefinitionApiController(SourceDefinitionApiFactory.sourceDefinitionsHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final SourceDefinitionApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |
Oops, something went wrong.