当前位置: 首页>>代码示例>>Python>>正文


Python Salesforce._call_salesforce方法代码示例

本文整理汇总了Python中simple_salesforce.Salesforce._call_salesforce方法的典型用法代码示例。如果您正苦于以下问题:Python Salesforce._call_salesforce方法的具体用法?Python Salesforce._call_salesforce怎么用?Python Salesforce._call_salesforce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simple_salesforce.Salesforce的用法示例。


在下文中一共展示了Salesforce._call_salesforce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SalesforcePushApi

# 需要导入模块: from simple_salesforce import Salesforce [as 别名]
# 或者: from simple_salesforce.Salesforce import _call_salesforce [as 别名]

#.........这里部分代码省略.........
            )
        return push_job_objs

    @memoize
    def get_push_jobs_by_id(self, where=None, limit=None):
        push_jobs = {}
        for push_job in self.get_push_job_objs(where, limit):
            push_jobs[push_job.sf_id] = push_job
        return push_jobs

    @memoize
    def get_push_errors(self, where=None, limit=None):
        where = self.format_where_clause(where)
        query = "SELECT Id, PackagePushJobId, ErrorSeverity, ErrorType, ErrorTitle, ErrorMessage, ErrorDetails FROM PackagePushError%s" % where
        query = self.add_query_limit(query, limit)
        return self.return_query_records(query)

    @memoize
    def get_push_error_objs(self, where=None, limit=None):
        push_error_objs = []
        lazy = 'jobs' in self.lazy
        if not lazy:
            push_jobs = self.get_push_jobs_by_id()
        for push_error in self.get_push_errors(where, limit):
            if lazy:
                jobs = self.get_push_job_objs(where="Id = '%s'" % push_error['PackagePushJobId'])
                if jobs:
                    job = jobs[0]
                else:
                    job = None
             
            push_error_objs.append(
                PackagePushError(
                    push_api = self,
                    job = job,
                    severity = push_error['ErrorSeverity'],
                    error_type = push_error['ErrorType'],
                    title = push_error['ErrorTitle'],
                    message = push_error['ErrorMessage'],
                    details = push_error['ErrorDetails'],
                    sf_id = push_error['Id'],
                )
            )
        return push_error_objs

    @memoize
    def get_push_errors_by_id(self, where=None, limit=None):
        push_errors = {}
        for push_error in self.get_push_error_objs(where, limit):
            push_errors[push_error.sf_id] = push_error
        return push_errors

    def create_push_request(self, version, orgs, start=None):
        if not start:
            # By default, delay the push start by 15 minutes to allow manual review and intervention
            start = datetime.datetime.now() + datetime.timedelta(0, 15*60)

        # Create the request
        res = self.sf.PackagePushRequest.create({
            'PackageVersionId': version.sf_id,
            'ScheduledStartTime': start.isoformat(),
        })
        request_id = res['id']

        # Schedule the orgs
        batch_size = 200
        batch_offset = 0

        for batch in batch_list(orgs, batch_size):

            batch_data = {'records': []}
            i = 0

            for org in batch:
                batch_data['records'].append({
                    'attributes': {'type': 'PackagePushJob', 'referenceId': 'org%s' % i},
                    'PackagePushRequestId': request_id,
                    'SubscriberOrganizationKey': org,
                })
                i += 1
            
            try:
                res = self.sf._call_salesforce(
                    'POST', 
                    self.sf.base_url + 'composite/tree/PackagePushJob', 
                    data=json.dumps(batch_data),
                )
            except SalesforceMalformedRequest as e:
                for result in e.content['results']:
                    for error in result['errors']:
                        if error['statusCode'] == 'INVALID_OPERATION':
                            print u'Skipping org, error message = {}'.format(error['message'])
                        else:
                            raise e

        return request_id

    def run_push_request(self, request_id):
        # Set the request to Pending status
        return self.sf.PackagePushRequest.update(request_id, {'Status': 'Pending'})
开发者ID:SalesforceRocks,项目名称:CumulusCI,代码行数:104,代码来源:push_api.py


注:本文中的simple_salesforce.Salesforce._call_salesforce方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。