Skip to content

Commit

Permalink
remove un-used update/delete custom connector api (airbytehq#20034)
Browse files Browse the repository at this point in the history
* remove un-used update/delete custom connector api

* also remove create path

* more tests to fix
  • Loading branch information
xiaohansong authored Dec 5, 2022
1 parent 92f71ac commit 2a16285
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 921 deletions.
143 changes: 1 addition & 142 deletions airbyte-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,7 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/source_definitions/create:
post:
tags:
- source_definition
summary: Creates a sourceDefinition
operationId: createSourceDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SourceDefinitionCreate"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/SourceDefinitionRead"
"422":
$ref: "#/components/responses/InvalidInputResponse"

/v1/source_definitions/update:
post:
tags:
Expand Down Expand Up @@ -469,47 +450,6 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/source_definitions/update_custom:
post:
tags:
- source_definition
summary: Update a custom sourceDefinition for the given workspace
operationId: updateCustomSourceDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CustomSourceDefinitionUpdate"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/SourceDefinitionRead"
"404":
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/source_definitions/delete_custom:
post:
tags:
- source_definition
summary: Delete a custom source definition for the given workspace
operationId: deleteCustomSourceDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SourceDefinitionIdWithWorkspaceId"
required: true
responses:
"204":
description: The resource was deleted successfully.
"404":
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/source_definitions/grant_definition:
post:
tags:
Expand Down Expand Up @@ -798,26 +738,6 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_definitions/create:
post:
tags:
- destination_definition
summary: Creates a destinationsDefinition
operationId: createDestinationDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/DestinationDefinitionCreate"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/DestinationDefinitionRead"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_definitions/update:
post:
tags:
Expand Down Expand Up @@ -991,47 +911,6 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_definitions/update_custom:
post:
tags:
- destination_definition
summary: Update a custom destinationDefinition for the given workspace
operationId: updateCustomDestinationDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CustomDestinationDefinitionUpdate"
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/DestinationDefinitionRead"
"404":
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_definitions/delete_custom:
post:
tags:
- destination_definition
summary: Delete a custom destination definition for the given workspace
operationId: deleteCustomDestinationDefinition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/DestinationDefinitionIdWithWorkspaceId"
required: true
responses:
"204":
description: The destination was deleted successfully.
"404":
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_definitions/grant_definition:
post:
tags:
Expand Down Expand Up @@ -2680,16 +2559,6 @@ components:
$ref: "#/components/schemas/WorkspaceId"
sourceDefinition:
$ref: "#/components/schemas/SourceDefinitionCreate"
CustomSourceDefinitionUpdate:
type: object
required:
- workspaceId
- sourceDefinition
properties:
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
sourceDefinition:
$ref: "#/components/schemas/SourceDefinitionUpdate"
SourceDefinitionIdWithWorkspaceId:
type: object
required:
Expand Down Expand Up @@ -3050,16 +2919,6 @@ components:
$ref: "#/components/schemas/WorkspaceId"
destinationDefinition:
$ref: "#/components/schemas/DestinationDefinitionCreate"
CustomDestinationDefinitionUpdate:
type: object
required:
- workspaceId
- destinationDefinition
properties:
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
destinationDefinition:
$ref: "#/components/schemas/DestinationDefinitionUpdate"
DestinationDefinitionIdWithWorkspaceId:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import io.airbyte.api.generated.DestinationDefinitionApi;
import io.airbyte.api.model.generated.CustomDestinationDefinitionCreate;
import io.airbyte.api.model.generated.CustomDestinationDefinitionUpdate;
import io.airbyte.api.model.generated.DestinationDefinitionCreate;
import io.airbyte.api.model.generated.DestinationDefinitionIdRequestBody;
import io.airbyte.api.model.generated.DestinationDefinitionIdWithWorkspaceId;
import io.airbyte.api.model.generated.DestinationDefinitionRead;
Expand All @@ -31,21 +29,6 @@ public DestinationDefinitionRead createCustomDestinationDefinition(final CustomD
return ApiHelper.execute(() -> destinationDefinitionsHandler.createCustomDestinationDefinition(customDestinationDefinitionCreate));
}

// TODO: Deprecate this route in favor of createCustomDestinationDefinition
// since all connector definitions created through the API are custom
@Override
public DestinationDefinitionRead createDestinationDefinition(final DestinationDefinitionCreate destinationDefinitionCreate) {
return ApiHelper.execute(() -> destinationDefinitionsHandler.createPrivateDestinationDefinition(destinationDefinitionCreate));
}

@Override
public void deleteCustomDestinationDefinition(final DestinationDefinitionIdWithWorkspaceId destinationDefinitionIdWithWorkspaceId) {
ApiHelper.execute(() -> {
destinationDefinitionsHandler.deleteCustomDestinationDefinition(destinationDefinitionIdWithWorkspaceId);
return null;
});
}

@Override
public void deleteDestinationDefinition(final DestinationDefinitionIdRequestBody destinationDefinitionIdRequestBody) {
ApiHelper.execute(() -> {
Expand Down Expand Up @@ -98,11 +81,6 @@ public void revokeDestinationDefinitionFromWorkspace(final DestinationDefinition
});
}

@Override
public DestinationDefinitionRead updateCustomDestinationDefinition(final CustomDestinationDefinitionUpdate customDestinationDefinitionUpdate) {
return ApiHelper.execute(() -> destinationDefinitionsHandler.updateCustomDestinationDefinition(customDestinationDefinitionUpdate));
}

@Override
public DestinationDefinitionRead updateDestinationDefinition(final DestinationDefinitionUpdate destinationDefinitionUpdate) {
return ApiHelper.execute(() -> destinationDefinitionsHandler.updateDestinationDefinition(destinationDefinitionUpdate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

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;
Expand All @@ -31,21 +29,6 @@ public SourceDefinitionRead createCustomSourceDefinition(final CustomSourceDefin
return ApiHelper.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 ApiHelper.execute(() -> sourceDefinitionsHandler.createPrivateSourceDefinition(sourceDefinitionCreate));
}

@Override
public void deleteCustomSourceDefinition(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) {
ApiHelper.execute(() -> {
sourceDefinitionsHandler.deleteCustomSourceDefinition(sourceDefinitionIdWithWorkspaceId);
return null;
});
}

@Override
public void deleteSourceDefinition(final SourceDefinitionIdRequestBody sourceDefinitionIdRequestBody) {
ApiHelper.execute(() -> {
Expand Down Expand Up @@ -97,11 +80,6 @@ public void revokeSourceDefinitionFromWorkspace(final SourceDefinitionIdWithWork
});
}

@Override
public SourceDefinitionRead updateCustomSourceDefinition(final CustomSourceDefinitionUpdate customSourceDefinitionUpdate) {
return ApiHelper.execute(() -> sourceDefinitionsHandler.updateCustomSourceDefinition(customSourceDefinitionUpdate));
}

@Override
public SourceDefinitionRead updateSourceDefinition(final SourceDefinitionUpdate sourceDefinitionUpdate) {
return ApiHelper.execute(() -> sourceDefinitionsHandler.updateSourceDefinition(sourceDefinitionUpdate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.google.common.annotations.VisibleForTesting;
import io.airbyte.api.model.generated.CustomDestinationDefinitionCreate;
import io.airbyte.api.model.generated.CustomDestinationDefinitionUpdate;
import io.airbyte.api.model.generated.DestinationDefinitionCreate;
import io.airbyte.api.model.generated.DestinationDefinitionIdRequestBody;
import io.airbyte.api.model.generated.DestinationDefinitionIdWithWorkspaceId;
Expand Down Expand Up @@ -184,20 +183,6 @@ public DestinationDefinitionRead getDestinationDefinitionForWorkspace(
return getDestinationDefinition(new DestinationDefinitionIdRequestBody().destinationDefinitionId(definitionId));
}

public DestinationDefinitionRead createPrivateDestinationDefinition(final DestinationDefinitionCreate destinationDefCreate)
throws JsonValidationException, IOException {
final StandardDestinationDefinition destinationDefinition = destinationDefinitionFromCreate(destinationDefCreate)
.withPublic(false)
.withCustom(false);
if (!protocolVersionRange.isSupported(new Version(destinationDefinition.getProtocolVersion()))) {
throw new UnsupportedProtocolVersionException(destinationDefinition.getProtocolVersion(), protocolVersionRange.min(),
protocolVersionRange.max());
}
configRepository.writeStandardDestinationDefinition(destinationDefinition);

return buildDestinationDefinitionRead(destinationDefinition);
}

public DestinationDefinitionRead createCustomDestinationDefinition(final CustomDestinationDefinitionCreate customDestinationDefinitionCreate)
throws IOException {
final StandardDestinationDefinition destinationDefinition = destinationDefinitionFromCreate(
Expand Down Expand Up @@ -281,16 +266,6 @@ public DestinationDefinitionRead updateDestinationDefinition(final DestinationDe
return buildDestinationDefinitionRead(newDestination);
}

public DestinationDefinitionRead updateCustomDestinationDefinition(final CustomDestinationDefinitionUpdate customDestinationDefinitionUpdate)
throws IOException, JsonValidationException, ConfigNotFoundException {
final UUID definitionId = customDestinationDefinitionUpdate.getDestinationDefinition().getDestinationDefinitionId();
final UUID workspaceId = customDestinationDefinitionUpdate.getWorkspaceId();
if (!configRepository.workspaceCanUseCustomDefinition(definitionId, workspaceId)) {
throw new IdNotFoundKnownException("Cannot find the requested definition with given id for this workspace", definitionId.toString());
}
return updateDestinationDefinition(customDestinationDefinitionUpdate.getDestinationDefinition());
}

public void deleteDestinationDefinition(final DestinationDefinitionIdRequestBody destinationDefinitionIdRequestBody)
throws JsonValidationException, ConfigNotFoundException, IOException {
// "delete" all destinations associated with the destination definition as well. This will cascade
Expand All @@ -309,16 +284,6 @@ public void deleteDestinationDefinition(final DestinationDefinitionIdRequestBody
configRepository.writeStandardDestinationDefinition(persistedDestinationDefinition);
}

public void deleteCustomDestinationDefinition(final DestinationDefinitionIdWithWorkspaceId destinationDefinitionIdWithWorkspaceId)
throws IOException, JsonValidationException, ConfigNotFoundException {
final UUID definitionId = destinationDefinitionIdWithWorkspaceId.getDestinationDefinitionId();
final UUID workspaceId = destinationDefinitionIdWithWorkspaceId.getWorkspaceId();
if (!configRepository.workspaceCanUseCustomDefinition(definitionId, workspaceId)) {
throw new IdNotFoundKnownException("Cannot find the requested definition with given id for this workspace", definitionId.toString());
}
deleteDestinationDefinition(new DestinationDefinitionIdRequestBody().destinationDefinitionId(definitionId));
}

private ConnectorSpecification getSpecForImage(final String dockerRepository, final String imageTag) throws IOException {
final String imageName = DockerUtils.getTaggedImageName(dockerRepository, imageTag);
final SynchronousResponse<ConnectorSpecification> getSpecResponse = schedulerSynchronousClient.createGetSpecJob(imageName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.google.common.annotations.VisibleForTesting;
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.ReleaseStage;
Expand Down Expand Up @@ -190,19 +189,6 @@ public SourceDefinitionRead getSourceDefinitionForWorkspace(final SourceDefiniti
return getSourceDefinition(new SourceDefinitionIdRequestBody().sourceDefinitionId(definitionId));
}

public SourceDefinitionRead createPrivateSourceDefinition(final SourceDefinitionCreate sourceDefinitionCreate)
throws JsonValidationException, IOException {
final StandardSourceDefinition sourceDefinition = sourceDefinitionFromCreate(sourceDefinitionCreate)
.withPublic(false)
.withCustom(false);
if (!protocolVersionRange.isSupported(new Version(sourceDefinition.getProtocolVersion()))) {
throw new UnsupportedProtocolVersionException(sourceDefinition.getProtocolVersion(), protocolVersionRange.min(), protocolVersionRange.max());
}
configRepository.writeStandardSourceDefinition(sourceDefinition);

return buildSourceDefinitionRead(sourceDefinition);
}

public SourceDefinitionRead createCustomSourceDefinition(final CustomSourceDefinitionCreate customSourceDefinitionCreate)
throws IOException {
final StandardSourceDefinition sourceDefinition = sourceDefinitionFromCreate(customSourceDefinitionCreate.getSourceDefinition())
Expand Down Expand Up @@ -280,16 +266,6 @@ public SourceDefinitionRead updateSourceDefinition(final SourceDefinitionUpdate
return buildSourceDefinitionRead(newSource);
}

public SourceDefinitionRead updateCustomSourceDefinition(final CustomSourceDefinitionUpdate customSourceDefinitionUpdate)
throws IOException, JsonValidationException, ConfigNotFoundException {
final UUID definitionId = customSourceDefinitionUpdate.getSourceDefinition().getSourceDefinitionId();
final UUID workspaceId = customSourceDefinitionUpdate.getWorkspaceId();
if (!configRepository.workspaceCanUseCustomDefinition(definitionId, workspaceId)) {
throw new IdNotFoundKnownException("Cannot find the requested definition with given id for this workspace", definitionId.toString());
}
return updateSourceDefinition(customSourceDefinitionUpdate.getSourceDefinition());
}

public void deleteSourceDefinition(final SourceDefinitionIdRequestBody sourceDefinitionIdRequestBody)
throws JsonValidationException, IOException, ConfigNotFoundException {
// "delete" all sources associated with the source definition as well. This will cascade to
Expand All @@ -307,16 +283,6 @@ public void deleteSourceDefinition(final SourceDefinitionIdRequestBody sourceDef
configRepository.writeStandardSourceDefinition(persistedSourceDefinition);
}

public void deleteCustomSourceDefinition(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId)
throws IOException, JsonValidationException, ConfigNotFoundException {
final UUID definitionId = sourceDefinitionIdWithWorkspaceId.getSourceDefinitionId();
final UUID workspaceId = sourceDefinitionIdWithWorkspaceId.getWorkspaceId();
if (!configRepository.workspaceCanUseCustomDefinition(definitionId, workspaceId)) {
throw new IdNotFoundKnownException("Cannot find the requested definition with given id for this workspace", definitionId.toString());
}
deleteSourceDefinition(new SourceDefinitionIdRequestBody().sourceDefinitionId(definitionId));
}

private ConnectorSpecification getSpecForImage(final String dockerRepository, final String imageTag) throws IOException {
final String imageName = DockerUtils.getTaggedImageName(dockerRepository, imageTag);
final SynchronousResponse<ConnectorSpecification> getSpecResponse = schedulerSynchronousClient.createGetSpecJob(imageName);
Expand Down
Loading

0 comments on commit 2a16285

Please sign in to comment.