本文整理汇总了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'})