-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker image tag of actor definition version to ConnectorTitleBlo…
…ck on actor pages (#7101) Co-authored-by: Joey Marshment-Howell <josephkmh@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
288 additions
and
8 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
65 changes: 65 additions & 0 deletions
65
...erver/src/main/java/io/airbyte/commons/server/handlers/ActorDefinitionVersionHandler.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,65 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.commons.server.handlers; | ||
|
||
import io.airbyte.api.model.generated.ActorDefinitionVersionRead; | ||
import io.airbyte.api.model.generated.DestinationIdRequestBody; | ||
import io.airbyte.api.model.generated.SourceIdRequestBody; | ||
import io.airbyte.config.ActorDefinitionVersion; | ||
import io.airbyte.config.DestinationConnection; | ||
import io.airbyte.config.SourceConnection; | ||
import io.airbyte.config.StandardDestinationDefinition; | ||
import io.airbyte.config.StandardSourceDefinition; | ||
import io.airbyte.config.persistence.ActorDefinitionVersionHelper; | ||
import io.airbyte.config.persistence.ConfigNotFoundException; | ||
import io.airbyte.config.persistence.ConfigRepository; | ||
import io.airbyte.validation.json.JsonValidationException; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import java.io.IOException; | ||
|
||
/** | ||
* DestinationHandler. Javadocs suppressed because api docs should be used as source of truth. | ||
*/ | ||
@SuppressWarnings({"MissingJavadocMethod", "ParameterName"}) | ||
@Singleton | ||
public class ActorDefinitionVersionHandler { | ||
|
||
private final ConfigRepository configRepository; | ||
private final ActorDefinitionVersionHelper actorDefinitionVersionHelper; | ||
|
||
@Inject | ||
public ActorDefinitionVersionHandler(final ConfigRepository configRepository, | ||
final ActorDefinitionVersionHelper actorDefinitionVersionHelper) { | ||
this.configRepository = configRepository; | ||
this.actorDefinitionVersionHelper = actorDefinitionVersionHelper; | ||
} | ||
|
||
public ActorDefinitionVersionRead getActorDefinitionVersionForSourceId(final SourceIdRequestBody sourceIdRequestBody) | ||
throws JsonValidationException, ConfigNotFoundException, IOException { | ||
final SourceConnection sourceConnection = configRepository.getSourceConnection(sourceIdRequestBody.getSourceId()); | ||
final StandardSourceDefinition sourceDefinition = configRepository.getSourceDefinitionFromSource(sourceConnection.getSourceId()); | ||
final ActorDefinitionVersion actorDefinitionVersion = | ||
actorDefinitionVersionHelper.getSourceVersion(sourceDefinition, sourceConnection.getWorkspaceId(), sourceConnection.getSourceId()); | ||
return createActorDefinitionVersionRead(actorDefinitionVersion); | ||
} | ||
|
||
public ActorDefinitionVersionRead getActorDefinitionVersionForDestinationId(final DestinationIdRequestBody destinationIdRequestBody) | ||
throws JsonValidationException, ConfigNotFoundException, IOException { | ||
final DestinationConnection destinationConnection = configRepository.getDestinationConnection(destinationIdRequestBody.getDestinationId()); | ||
final StandardDestinationDefinition destinationDefinition = | ||
configRepository.getDestinationDefinitionFromDestination(destinationConnection.getDestinationId()); | ||
final ActorDefinitionVersion actorDefinitionVersion = actorDefinitionVersionHelper.getDestinationVersion(destinationDefinition, | ||
destinationConnection.getWorkspaceId(), destinationConnection.getDestinationId()); | ||
return createActorDefinitionVersionRead(actorDefinitionVersion); | ||
} | ||
|
||
private ActorDefinitionVersionRead createActorDefinitionVersionRead(final ActorDefinitionVersion actorDefinitionVersion) { | ||
return new ActorDefinitionVersionRead() | ||
.dockerRepository(actorDefinitionVersion.getDockerRepository()) | ||
.dockerImageTag(actorDefinitionVersion.getDockerImageTag()); | ||
} | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
airbyte-server/src/main/java/io/airbyte/server/apis/ActorDefinitionVersionApiController.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,48 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import static io.airbyte.commons.auth.AuthRoleConstants.AUTHENTICATED_USER; | ||
|
||
import io.airbyte.api.generated.ActorDefinitionVersionApi; | ||
import io.airbyte.api.model.generated.ActorDefinitionVersionRead; | ||
import io.airbyte.api.model.generated.DestinationIdRequestBody; | ||
import io.airbyte.api.model.generated.SourceIdRequestBody; | ||
import io.airbyte.commons.server.handlers.ActorDefinitionVersionHandler; | ||
import io.airbyte.commons.server.scheduling.AirbyteTaskExecutors; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Post; | ||
import io.micronaut.scheduling.annotation.ExecuteOn; | ||
import io.micronaut.security.annotation.Secured; | ||
import io.micronaut.security.rules.SecurityRule; | ||
|
||
@SuppressWarnings("MissingJavadocType") | ||
@Controller("/api/v1/actor_definition_versions") | ||
@Secured(SecurityRule.IS_AUTHENTICATED) | ||
public class ActorDefinitionVersionApiController implements ActorDefinitionVersionApi { | ||
|
||
private final ActorDefinitionVersionHandler actorDefinitionVersionHandler; | ||
|
||
public ActorDefinitionVersionApiController(final ActorDefinitionVersionHandler actorDefinitionVersionHandler) { | ||
this.actorDefinitionVersionHandler = actorDefinitionVersionHandler; | ||
} | ||
|
||
@Post("/get_for_source") | ||
@Secured({AUTHENTICATED_USER}) | ||
@ExecuteOn(AirbyteTaskExecutors.IO) | ||
@Override | ||
public ActorDefinitionVersionRead getActorDefinitionVersionForSourceId(final SourceIdRequestBody sourceIdRequestBody) { | ||
return ApiHelper.execute(() -> actorDefinitionVersionHandler.getActorDefinitionVersionForSourceId(sourceIdRequestBody)); | ||
} | ||
|
||
@Post("/get_for_destination") | ||
@Secured({AUTHENTICATED_USER}) | ||
@ExecuteOn(AirbyteTaskExecutors.IO) | ||
@Override | ||
public ActorDefinitionVersionRead getActorDefinitionVersionForDestinationId(final DestinationIdRequestBody destinationIdRequestBody) { | ||
return ApiHelper.execute(() -> actorDefinitionVersionHandler.getActorDefinitionVersionForDestinationId(destinationIdRequestBody)); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
airbyte-server/src/test/java/io/airbyte/server/apis/ActorDefinitionVersionApiTest.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,53 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.model.generated.ActorDefinitionVersionRead; | ||
import io.airbyte.api.model.generated.DestinationIdRequestBody; | ||
import io.airbyte.api.model.generated.SourceIdRequestBody; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.config.persistence.ConfigNotFoundException; | ||
import io.airbyte.validation.json.JsonValidationException; | ||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.HttpStatus; | ||
import java.io.IOException; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
/** | ||
* Test class for {@link ActorDefinitionVersionApiController}. | ||
*/ | ||
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") | ||
class ActorDefinitionVersionApiTest extends BaseControllerTest { | ||
|
||
@Test | ||
void testGetActorDefinitionForSource() throws JsonValidationException, ConfigNotFoundException, IOException { | ||
Mockito.when(actorDefinitionVersionHandler.getActorDefinitionVersionForSourceId(Mockito.any())) | ||
.thenReturn(new ActorDefinitionVersionRead()) | ||
.thenThrow(new ConfigNotFoundException("", "")); | ||
final String path = "/api/v1/actor_definition_versions/get_for_source"; | ||
testEndpointStatus( | ||
HttpRequest.POST(path, Jsons.serialize(new SourceIdRequestBody())), | ||
HttpStatus.OK); | ||
testErrorEndpointStatus( | ||
HttpRequest.POST(path, Jsons.serialize(new SourceIdRequestBody())), | ||
HttpStatus.NOT_FOUND); | ||
} | ||
|
||
@Test | ||
void testGetActorDefinitionForDestination() throws JsonValidationException, ConfigNotFoundException, IOException { | ||
Mockito.when(actorDefinitionVersionHandler.getActorDefinitionVersionForDestinationId(Mockito.any())) | ||
.thenReturn(new ActorDefinitionVersionRead()) | ||
.thenThrow(new ConfigNotFoundException("", "")); | ||
final String path = "/api/v1/actor_definition_versions/get_for_destination"; | ||
testEndpointStatus( | ||
HttpRequest.POST(path, Jsons.serialize(new DestinationIdRequestBody())), | ||
HttpStatus.OK); | ||
testErrorEndpointStatus( | ||
HttpRequest.POST(path, Jsons.serialize(new DestinationIdRequestBody())), | ||
HttpStatus.NOT_FOUND); | ||
} | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
airbyte-webapp/src/core/api/hooks/actorDefinitionVersions.ts
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,24 @@ | ||
import { SCOPE_WORKSPACE } from "services/Scope"; | ||
|
||
import { | ||
getActorDefinitionVersionForDestinationId, | ||
getActorDefinitionVersionForSourceId, | ||
} from "../generated/AirbyteClient"; | ||
import { useRequestOptions } from "../useRequestOptions"; | ||
import { useSuspenseQuery } from "../useSuspenseQuery"; | ||
|
||
export function useSourceDefinitionVersion(sourceId: string) { | ||
const requestOptions = useRequestOptions(); | ||
|
||
return useSuspenseQuery([SCOPE_WORKSPACE, "actorDefinitionVersion", sourceId], () => | ||
getActorDefinitionVersionForSourceId({ sourceId }, requestOptions) | ||
); | ||
} | ||
|
||
export function useDestinationDefinitionVersion(destinationId: string) { | ||
const requestOptions = useRequestOptions(); | ||
|
||
return useSuspenseQuery([SCOPE_WORKSPACE, "actorDefinitionVersion", destinationId], () => | ||
getActorDefinitionVersionForDestinationId({ destinationId }, requestOptions) | ||
); | ||
} |
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
Oops, something went wrong.