How to use the cumulusci.tasks.salesforce.BaseSalesforceApiTask function in cumulusci

To help you get started, we’ve selected a few cumulusci examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SFDO-Tooling / CumulusCI / cumulusci / tasks / apex / batch.py View on Github external
""" a task for waiting on a Batch Apex job to complete """

import datetime
from cumulusci.utils import parse_api_datetime
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.core.exceptions import SalesforceException

COMPLETED_STATUSES = ["Completed"]


class BatchApexWait(BaseSalesforceApiTask):
    """ BatchApexWait polls an org until the latest batch job
        for an apex class completes or fails """

    name = "BatchApexWait"
    batch = object()

    task_options = {
        "class_name": {
            "description": "Name of the Apex class to wait for.",
            "required": True,
        },
        "poll_interval": {
            "description": "Seconds to wait before polling for batch job completion. "
            "Defaults to 10 seconds."
        },
    }
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / sourcetracking.py View on Github external
import time

from cumulusci.core.sfdx import sfdx
from cumulusci.core.utils import process_bool_arg
from cumulusci.core.utils import process_list_arg
from cumulusci.tasks.salesforce import BaseRetrieveMetadata
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.tasks.metadata.package import PackageXmlGenerator
from cumulusci.utils import temporary_dir
from cumulusci.utils import touch
from cumulusci.utils import inject_namespace
from cumulusci.utils import process_text_in_directory
from cumulusci.utils import tokenize_namespace


class ListChanges(BaseSalesforceApiTask):
    api_version = "47.0"

    task_options = {
        "include": {
            "description": "A comma-separated list of strings. "
            "Components will be included if one of these strings "
            "is part of either the metadata type or name. "
            "Example: ``-o include CustomField,Admin`` matches both "
            "``CustomField: Favorite_Color__c`` and ``Profile: Admin``"
        },
        "types": {
            "description": "A comma-separated list of metadata types to include."
        },
        "exclude": {"description": "Exclude changed components matching this string."},
        "snapshot": {
            "description": "If True, all matching items will be set to be ignored at their current revision number.  This will exclude them from the results unless a new edit is made."
github SFDO-Tooling / CumulusCI / cumulusci / tasks / bulkdata / delete.py View on Github external
import requests
import time
import unicodecsv
import xml.etree.ElementTree as ET

from cumulusci.core.utils import process_bool_arg, process_list_arg
from cumulusci.tasks.bulkdata.utils import BulkJobTaskMixin
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.core.exceptions import TaskOptionsError


class DeleteData(BaseSalesforceApiTask, BulkJobTaskMixin):
    task_options = {
        "objects": {
            "description": "A list of objects to delete records from in order of deletion.  If passed via command line, use a comma separated string",
            "required": True,
        },
        "where": {
            "description": "A SOQL where-clause (without the keyword WHERE). Only available when 'objects' is length 1.",
            "required": False,
        },
        "hardDelete": {
            "description": "If True, perform a hard delete, bypassing the recycle bin. Default: False"
        },
    }

    def _init_options(self, kwargs):
        super(DeleteData, self)._init_options(kwargs)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / RetrieveUnpackaged.py View on Github external
{
        "package_xml": {
            "description": "The path to a package.xml manifest to use for the retrieve."
        },
        "include": {"description": "Retrieve changed components matching this string."},
        "api_version": {
            "description": (
                "Override the default api version for the retrieve."
                + " Defaults to project__package__api_version"
            )
        },
    }
)


class RetrieveUnpackaged(BaseRetrieveMetadata, BaseSalesforceApiTask):
    api_class = ApiRetrieveUnpackaged

    task_options = retrieve_unpackaged_options

    def _init_options(self, kwargs):
        super(RetrieveUnpackaged, self)._init_options(kwargs)

        # @@@ needs to be xor
        if "package_xml" not in self.options and "include" not in self.options:
            raise TaskOptionsError(
                "You must specify the package_xml or include option."
            )

        if "package_xml" in self.options:
            self.options["package_xml_path"] = self.options["package_xml"]
            with open(self.options["package_xml_path"], "r") as f:
github SFDO-Tooling / CumulusCI / cumulusci / tasks / debug_logs.py View on Github external
import datetime
import os
import csv

from cumulusci.tasks.salesforce import BaseSalesforceApiTask


class TurnOnDebugLogs(BaseSalesforceApiTask):
    task_docs = """
    Turn on debugging information in Salesforce
    """

    debug_level_id = None  # Class variable

    def _run_task(self):
        """Create a TraceFlag for a given user."""
        self._delete_debug_levels()
        self._delete_trace_flags()
        self.logger.info("Creating DebugLevel object")
        DebugLevel = self._get_tooling_object("DebugLevel")
        result = DebugLevel.create(
            {
                "ApexCode": "Info",
                "ApexProfiling": "Debug",
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / custom_settings.py View on Github external
import os
import yaml

from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.utils import os_friendly_path
from cumulusci.core.exceptions import TaskOptionsError, CumulusCIException


class LoadCustomSettings(BaseSalesforceApiTask):
    """Load Custom Settings (both List and Hierarchy) into an org
    from a YAML-format settings file.

    Each top-level YAML key should be the API name of a Custom Setting.
    List Custom Settings should contain a nested map of names to values.
    Hierarchy Custom settings should contain a list, each of which contains
    a `data` key and a `location` key. The `location` key may contain either
    `profile: `, `user: name: `, `user: email: `,
    or `org`. Example:

    List__c:
        Test:
            MyField__c: 1
        Test 2:
            MyField__c: 2
    Hierarchy__c:
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / CreateCommunity.py View on Github external
import json
import requests
from datetime import datetime
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.core.exceptions import SalesforceException


class CreateCommunity(BaseSalesforceApiTask):
    api_version = "46.0"
    task_docs = """
    Create a Salesforce Community via the Connect API.
    Specify the `template` "VF Template" for Visualforce Tabs community,
    or the name for a specific desired template
    """
    task_options = {
        "template": {
            "description": "Name of the template for the community.",
            "required": True,
        },
        "name": {"description": "Name of the community.", "required": True},
        "description": {
            "description": "Description of the community.",
            "required": False,
        },
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / ActivateFlowProcesses.py View on Github external
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.core.utils import process_list_arg
import click


class ActivateFlowProcesses(BaseSalesforceApiTask):
    """
    Activate the Flows with the supplied Developer Names
    """

    task_options = {
        "developer_names": {
            "description": "List of DeveloperNames to query in SOQL",
            "required": True,
        },
    }

    def _init_options(self, kwargs):
        super(ActivateFlowProcesses, self)._init_options(kwargs)
        self.options["developer_names"] = process_list_arg(
            self.task_config.options["developer_names"]
        )
github SFDO-Tooling / CumulusCI / cumulusci / tasks / push / tasks.py View on Github external
excluded_versions[0]
                )
            else:
                push_api.default_where[
                    "PackageSubscriber"
                ] += " AND MetadataPackageVersionId NOT IN {}".format(
                    "('" + "','".join(excluded_versions) + "')"
                )

            for subscriber in push_api.get_subscribers():
                orgs.append(subscriber["OrgKey"])

        return orgs


class GetSubscriberList(BaseSalesforceApiTask):
    """ Get subscribed org info and write to local CSV file """

    task_options = {
        "filename": {
            "description": "File where org IDs will be written",
            "required": True,
        }
    }

    def _run_task(self):
        raise NotImplementedError


class FilterSubscriberList(BaseTask):
    """
    Filter subscriber org list by org type, version.
github SFDO-Tooling / CumulusCI / cumulusci / tasks / bulkdata / load.py View on Github external
import yaml

from cumulusci.core.exceptions import BulkDataException
from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.tasks.bulkdata.utils import (
    BulkJobTaskMixin,
    get_lookup_key_field,
    download_file,
)
from cumulusci.tasks.salesforce import BaseSalesforceApiTask
from cumulusci.core.utils import process_bool_arg

from cumulusci.utils import os_friendly_path


class LoadData(BulkJobTaskMixin, BaseSalesforceApiTask):

    task_options = {
        "database_url": {
            "description": "The database url to a database containing the test data to load"
        },
        "mapping": {
            "description": "The path to a yaml file containing mappings of the database fields to Salesforce object fields",
            "required": True,
        },
        "start_step": {
            "description": "If specified, skip steps before this one in the mapping",
            "required": False,
        },
        "sql_path": {
            "description": "If specified, a database will be created from an SQL script at the provided path"
        },