Skip to content

Commit 2e9ec5b

Browse files
simplify
1 parent 475d109 commit 2e9ec5b

File tree

1 file changed

+55
-38
lines changed

1 file changed

+55
-38
lines changed

airbyte/cloud/workspaces.py

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ def get_custom_source_definition(
604604
PyAirbyteInputError: If both or neither parameters are provided, or if
605605
connector_builder_project_id is used with non-yaml definition_type
606606
"""
607+
if definition_type != "yaml":
608+
raise NotImplementedError(
609+
"Docker custom source definitions are not yet supported. "
610+
"Only YAML manifest-based custom sources are currently available."
611+
)
612+
607613
if (definition_id is None) == (connector_builder_project_id is None):
608614
raise exc.PyAirbyteInputError(
609615
message=(
@@ -615,45 +621,56 @@ def get_custom_source_definition(
615621
},
616622
)
617623

618-
if connector_builder_project_id is not None and definition_type != "yaml":
619-
raise exc.PyAirbyteInputError(
620-
message="connector_builder_project_id is only valid for yaml definition_type",
621-
context={
622-
"definition_type": definition_type,
623-
"connector_builder_project_id": connector_builder_project_id,
624-
},
624+
if connector_builder_project_id:
625+
if definition_type != "yaml":
626+
raise exc.PyAirbyteInputError(
627+
message="connector_builder_project_id is only valid for yaml definition_type",
628+
context={
629+
"definition_type": definition_type,
630+
"connector_builder_project_id": connector_builder_project_id,
631+
},
632+
)
633+
definition_id = api_util.get_definition_id_for_connector_builder_project(
634+
workspace_id=self.workspace_id,
635+
builder_project_id=connector_builder_project_id,
636+
api_root=self.api_root,
637+
client_id=self.client_id,
638+
client_secret=self.client_secret,
625639
)
626640

627-
if definition_type == "yaml":
628-
if definition_id is not None:
629-
result = api_util.get_custom_yaml_source_definition(
630-
workspace_id=self.workspace_id,
631-
definition_id=definition_id,
632-
api_root=self.api_root,
633-
client_id=self.client_id,
634-
client_secret=self.client_secret,
635-
)
636-
return CustomCloudSourceDefinition._from_yaml_response(self, result) # noqa: SLF001
637-
638-
if connector_builder_project_id is not None:
639-
definition_id = api_util.get_definition_id_for_connector_builder_project(
640-
workspace_id=self.workspace_id,
641-
builder_project_id=connector_builder_project_id,
642-
api_root=self.api_root,
643-
client_id=self.client_id,
644-
client_secret=self.client_secret,
645-
)
641+
# Definition ID is guaranteed to be set by here
642+
result = api_util.get_custom_yaml_source_definition(
643+
workspace_id=self.workspace_id,
644+
definition_id=definition_id,
645+
api_root=self.api_root,
646+
client_id=self.client_id,
647+
client_secret=self.client_secret,
648+
)
649+
return CustomCloudSourceDefinition._from_yaml_response(self, result) # noqa: SLF001
646650

647-
result = api_util.get_custom_yaml_source_definition(
648-
workspace_id=self.workspace_id,
649-
definition_id=definition_id,
650-
api_root=self.api_root,
651-
client_id=self.client_id,
652-
client_secret=self.client_secret,
653-
)
654-
return CustomCloudSourceDefinition._from_yaml_response(self, result) # noqa: SLF001
655651

656-
raise NotImplementedError(
657-
"Docker custom source definitions are not yet supported. "
658-
"Only YAML manifest-based custom sources are currently available."
659-
)
652+
def permanently_delete_custom_source_definition(
653+
self,
654+
definition_id: str,
655+
*,
656+
definition_type: Literal["yaml", "docker"],
657+
) -> None:
658+
"""Permanently delete a custom source definition.
659+
660+
Args:
661+
definition_id: The definition ID to delete
662+
definition_type: Connector type ("yaml" or "docker"). Required.
663+
"""
664+
if definition_type == "yaml":
665+
api_util.delete_custom_yaml_source_definition(
666+
workspace_id=self.workspace_id,
667+
definition_id=definition_id,
668+
api_root=self.api_root,
669+
client_id=self.client_id,
670+
client_secret=self.client_secret,
671+
)
672+
else:
673+
raise NotImplementedError(
674+
"Docker custom source definitions are not yet supported. "
675+
"Only YAML manifest-based custom sources are currently available."
676+
)

0 commit comments

Comments
 (0)