Skip to content

Commit ceba272

Browse files
authored
simplify
1 parent 03225f1 commit ceba272

1 file changed

Lines changed: 30 additions & 39 deletions

File tree

airbyte/cloud/workspaces.py

Lines changed: 30 additions & 39 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,48 +621,33 @@ 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-
},
625-
)
626-
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-
)
646-
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,
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+
},
653632
)
654-
return CustomCloudSourceDefinition._from_yaml_response(self, result) # noqa: SLF001
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,
639+
)
655640

656-
raise NotImplementedError(
657-
"Docker custom source definitions are not yet supported. "
658-
"Only YAML manifest-based custom sources are currently available."
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,
659648
)
649+
return CustomCloudSourceDefinition._from_yaml_response(self, result) # noqa: SLF001
650+
660651

661652
def permanently_delete_custom_source_definition(
662653
self,

0 commit comments

Comments
 (0)