|
8 | 8 | from os import mkdir, path
|
9 | 9 |
|
10 | 10 | from keboola.component.base import ComponentBase, sync_action
|
11 |
| -from keboola.component.dao import SupportedDataTypes, BaseType, ColumnDefinition |
| 11 | +from keboola.component.dao import BaseType, ColumnDefinition, SupportedDataTypes |
12 | 12 | from keboola.component.exceptions import UserException
|
13 | 13 | from keboola.component.sync_actions import MessageType, SelectElement, ValidationResult
|
14 | 14 | from keboola.utils.header_normalizer import NormalizerStrategy, get_normalizer
|
@@ -86,7 +86,7 @@ class Component(ComponentBase):
|
86 | 86 | def __init__(self):
|
87 | 87 | super().__init__()
|
88 | 88 |
|
89 |
| - def run(self): |
| 89 | + def run(self, return_data=False): |
90 | 90 | self.validate_configuration_parameters(REQUIRED_PARAMETERS)
|
91 | 91 | self.validate_image_parameters(REQUIRED_IMAGE_PARS)
|
92 | 92 |
|
@@ -130,6 +130,9 @@ def run(self):
|
130 | 130 | logging.debug([result for result in results])
|
131 | 131 | logging.info(f"Downloaded {total_records} records in total")
|
132 | 132 |
|
| 133 | + if return_data: |
| 134 | + return results |
| 135 | + |
133 | 136 | # remove headers and get columns
|
134 | 137 | output_columns = self._fix_header_from_csv(results)
|
135 | 138 | output_columns = self.normalize_column_names(output_columns)
|
@@ -419,9 +422,9 @@ def _get_login_method(self) -> LoginType:
|
419 | 422 | @staticmethod
|
420 | 423 | def process_salesforce_domain(url):
|
421 | 424 | if url.startswith("http://"):
|
422 |
| - url = url[len("http://"):] |
| 425 | + url = url[len("http://") :] |
423 | 426 | if url.startswith("https://"):
|
424 |
| - url = url[len("https://"):] |
| 427 | + url = url[len("https://") :] |
425 | 428 | if url.endswith(".salesforce.com"):
|
426 | 429 | url = url[: -len(".salesforce.com")]
|
427 | 430 |
|
@@ -619,6 +622,13 @@ def load_possible_primary_keys(self) -> list[SelectElement]:
|
619 | 622 | else:
|
620 | 623 | raise UserException(f"Invalid {KEY_QUERY_TYPE}")
|
621 | 624 |
|
| 625 | + # @sync_action("runComponent") |
| 626 | + # def sync_run_component(self): |
| 627 | + # """ |
| 628 | + # Run the component as a sync action |
| 629 | + # """ |
| 630 | + # return self.run(return_data=True) |
| 631 | + |
622 | 632 | def _get_object_name_from_custom_query(self) -> str:
|
623 | 633 | params = self.configuration.parameters
|
624 | 634 | salesforce_client = self.get_salesforce_client(params)
|
|
0 commit comments