From 720d484018861626ff0249301464c7d3dbfb516b Mon Sep 17 00:00:00 2001 From: aditya-balachander Date: Tue, 20 Aug 2024 16:52:20 +0530 Subject: [PATCH] Move DataApi import to utils --- .../bulkdata/extract_dataset_utils/extract_yml.py | 9 +-------- cumulusci/tasks/bulkdata/step.py | 10 +--------- cumulusci/tasks/bulkdata/utils.py | 9 +++++++++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/cumulusci/tasks/bulkdata/extract_dataset_utils/extract_yml.py b/cumulusci/tasks/bulkdata/extract_dataset_utils/extract_yml.py index 9679da5a1a..cec42d0bd9 100644 --- a/cumulusci/tasks/bulkdata/extract_dataset_utils/extract_yml.py +++ b/cumulusci/tasks/bulkdata/extract_dataset_utils/extract_yml.py @@ -5,6 +5,7 @@ from pydantic import Field, validator from cumulusci.core.enums import StrEnum +from cumulusci.tasks.bulkdata.utils import DataApi from cumulusci.utils.yaml.model_parser import CCIDictModel, HashableBaseModel object_decl = re.compile(r"objects\((\w+)\)", re.IGNORECASE) @@ -24,14 +25,6 @@ class SFFieldGroupTypes(StrEnum): required = "required" -class DataApi(StrEnum): - """Enum defining requested Salesforce data API for an operation.""" - - BULK = "bulk" - REST = "rest" - SMART = "smart" - - class ExtractDeclaration(HashableBaseModel): where: T.Optional[str] = None fields_: T.Union[T.List[str], str] = Field(["FIELDS(ALL)"], alias="fields") diff --git a/cumulusci/tasks/bulkdata/step.py b/cumulusci/tasks/bulkdata/step.py index 14f37db181..4770cab37e 100644 --- a/cumulusci/tasks/bulkdata/step.py +++ b/cumulusci/tasks/bulkdata/step.py @@ -21,7 +21,7 @@ random_generate_query, random_post_process, ) -from cumulusci.tasks.bulkdata.utils import iterate_in_chunks +from cumulusci.tasks.bulkdata.utils import DataApi, iterate_in_chunks from cumulusci.utils.classutils import namedtuple_as_simple_dict from cumulusci.utils.xml import lxml_parse_string @@ -45,14 +45,6 @@ class DataOperationType(StrEnum): SELECT = "select" -class DataApi(StrEnum): - """Enum defining requested Salesforce data API for an operation.""" - - BULK = "bulk" - REST = "rest" - SMART = "smart" - - class DataOperationStatus(StrEnum): """Enum defining outcome values for a data operation.""" diff --git a/cumulusci/tasks/bulkdata/utils.py b/cumulusci/tasks/bulkdata/utils.py index 082277fb16..b5c195a817 100644 --- a/cumulusci/tasks/bulkdata/utils.py +++ b/cumulusci/tasks/bulkdata/utils.py @@ -10,10 +10,19 @@ from sqlalchemy.engine.base import Connection from sqlalchemy.orm import Session, mapper +from cumulusci.core.enums import StrEnum from cumulusci.core.exceptions import BulkDataException from cumulusci.utils.iterators import iterate_in_chunks +class DataApi(StrEnum): + """Enum defining requested Salesforce data API for an operation.""" + + BULK = "bulk" + REST = "rest" + SMART = "smart" + + class SqlAlchemyMixin: logger: logging.Logger metadata: MetaData