diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..796f535 --- /dev/null +++ b/404.html @@ -0,0 +1,566 @@ + + + +
+ + + + + + + + + + + + + + + + + + +Auth
+
+
+¶
+ Bases: ABC
Base class for Salesforce authentication.
+ +src/aiosalesforce/auth/base.py
13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 |
|
expired: bool
+
+
+ property
+
+
+¶True if the access token is expired.
+get_access_token(client)
+
+
+ async
+
+
+¶Get access token.
+If this is the first time this method is called, it will acquire a new +access token from Salesforce.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
client |
+
+ Salesforce
+ |
+
+
+
+ Salesforce client. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ Access token + |
+
src/aiosalesforce/auth/base.py
refresh_access_token(client)
+
+
+ async
+
+
+¶Refresh the access token.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
client |
+
+ Salesforce
+ |
+
+
+
+ Salesforce client. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ Access token + |
+
src/aiosalesforce/auth/base.py
SoapLogin
+
+
+¶
+ Bases: Auth
Authenticate using the SOAP login method.
+https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_login.htm
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
username |
+
+ str
+ |
+
+
+
+ Username. + |
+ + required + | +
password |
+
+ str
+ |
+
+
+
+ Password. + |
+ + required + | +
security_token |
+
+ str
+ |
+
+
+
+ Security token. + |
+ + required + | +
src/aiosalesforce/auth/soap.py
19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 |
|
ClientCredentialsFlow
+
+
+¶
+ Bases: Auth
Authenticate using the OAuth 2.0 Client Credentials Flow.
+https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_client_credentials_flow.htm&type=5
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
client_id |
+
+ str
+ |
+
+
+
+ Client ID. + |
+ + required + | +
client_secret |
+
+ str
+ |
+
+
+
+ Client secret. + |
+ + required + | +
src/aiosalesforce/auth/client_credentials_flow.py
BulkClientV2
+
+
+¶Salesforce Bulk API 2.0 client.
+Use this client to execute bulk ingest and query operations.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
salesforce_client |
+
+ Salesforce
+ |
+
+
+
+ Salesforce client. + |
+ + required + | +
src/aiosalesforce/bulk/v2/client.py
23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 |
|
base_url: str = '/'.join([f'{self.salesforce_client.base_url}', 'services', 'data', f'v{self.salesforce_client.version}', 'jobs'])
+
+
+ instance-attribute
+
+
+¶Base URL in the format https://[subdomain(s)].my.salesforce.com/services/data/v[version]/jobs
+ingest: BulkIngestClient
+
+
+ cached
+ property
+
+
+¶Manage ingest jobs at a low level.
+insert(sobject, data, assignment_rule_id=None)
+
+
+ async
+
+
+¶Create new records in Salesforce.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
data |
+
+ Iterable[dict[str, Any]]
+ |
+
+
+
+ Records to create. + |
+ + required + | +
assignment_rule_id |
+
+ str | None
+ |
+
+
+
+ The ID of an assignment rule to run for a Case or a Lead. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ IngestResult
+ |
+
+
+
+ Bulk API 2.0 ingest job results. + |
+
src/aiosalesforce/bulk/v2/client.py
update(sobject, data, assignment_rule_id=None)
+
+
+ async
+
+
+¶Update existing records in Salesforce.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
data |
+
+ Iterable[dict[str, Any]]
+ |
+
+
+
+ Records to update. + |
+ + required + | +
assignment_rule_id |
+
+ str | None
+ |
+
+
+
+ The ID of an assignment rule to run for a Case or a Lead. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ IngestResult
+ |
+
+
+
+ Bulk API 2.0 ingest job results. + |
+
src/aiosalesforce/bulk/v2/client.py
upsert(sobject, data, external_id_field, assignment_rule_id=None)
+
+
+ async
+
+
+¶Create or update records in Salesforce.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
data |
+
+ Iterable[dict[str, Any]]
+ |
+
+
+
+ Records to create or update. + |
+ + required + | +
external_id_field |
+
+ str
+ |
+
+
+
+ External ID field name. + |
+ + required + | +
assignment_rule_id |
+
+ str | None
+ |
+
+
+
+ The ID of an assignment rule to run for a Case or a Lead. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ IngestResult
+ |
+
+
+
+ Bulk API 2.0 ingest job results. + |
+
src/aiosalesforce/bulk/v2/client.py
delete(sobject, data, hard=False)
+
+
+ async
+
+
+¶Delete records from Salesforce.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
data |
+
+ Iterable[dict[str, Any]]
+ |
+
+
+
+ Records to delete. + |
+ + required + | +
hard |
+
+ bool
+ |
+
+
+
+ Whether to hard delete records. + |
+
+ False
+ |
+
Returns:
+Type | +Description | +
---|---|
+ IngestResult
+ |
+
+
+
+ Bulk API 2.0 ingest job results. + |
+
src/aiosalesforce/bulk/v2/client.py
JobInfo
+
+
+
+ dataclass
+
+
+¶Bulk API 2.0 ingest job information.
+ +src/aiosalesforce/bulk/v2/ingest.py
JobResult
+
+
+
+ dataclass
+
+
+¶Bulk API 2.0 ingest job result.
+ +src/aiosalesforce/bulk/v2/ingest.py
BulkIngestClient
+
+
+¶Salesforce Bulk API 2.0 ingest client.
+This is a low-level client used to manage ingest jobs.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
bulk_client |
+
+ BulkClientV2
+ |
+
+
+
+ Bulk API 2.0 client from this client is invoked. + |
+ + required + | +
src/aiosalesforce/bulk/v2/ingest.py
98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 |
|
base_url: str = '/'.join([self.bulk_client.base_url, 'ingest'])
+
+
+ instance-attribute
+
+
+¶Base URL in the format https://[subdomain(s)].my.salesforce.com/services/data/v[version]/jobs/ingest
+create_job(operation, sobject, external_id_field=None, assignment_rule_id=None)
+
+
+ async
+
+
+¶Create a new ingest job.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
operation |
+
+ (insert, delete, hardDelete, update, upsert)
+ |
+
+
+
+ Operation to perform. + |
+
+ "insert"
+ |
+
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
external_id_field |
+
+ str | None
+ |
+
+
+
+ External ID field name, by default None. +Used for upsert operations. + |
+
+ None
+ |
+
assignment_rule_id |
+
+ str | None
+ |
+
+
+
+ The ID of an assignment rule to run for a Case or a Lead. +By default None. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ JobInfo
+ |
+
+
+
+ description + |
+
src/aiosalesforce/bulk/v2/ingest.py
get_job(job_id)
+
+
+ async
+
+
+¶Get information about ingest job.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
job_id |
+
+ str
+ |
+
+
+
+ Ingest job ID. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ JobInfo
+ |
+
+
+
+ Job information. + |
+
src/aiosalesforce/bulk/v2/ingest.py
list_jobs(is_pk_chunking_enabled=None)
+
+
+ async
+
+
+¶List all ingest jobs.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
is_pk_chunking_enabled |
+
+ bool | None
+ |
+
+
+
+ Filter by primary key chunking enabled, by default None. + |
+
+ None
+ |
+
Yields:
+Type | +Description | +
---|---|
+ JobInfo
+ |
+
+
+
+ Job information. + |
+
src/aiosalesforce/bulk/v2/ingest.py
abort_job(job_id)
+
+
+ async
+
+
+¶Abort ingest job.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
job_id |
+
+ str
+ |
+
+
+
+ Ingest job ID. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ JobInfo
+ |
+
+
+
+ Job information. + |
+
src/aiosalesforce/bulk/v2/ingest.py
delete_job(job_id)
+
+
+ async
+
+
+¶Delete ingest job.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
job_id |
+
+ str
+ |
+
+
+
+ Ingest job ID. + |
+ + required + | +
src/aiosalesforce/bulk/v2/ingest.py
upload_job_data(job_id, data)
+
+
+ async
+
+
+¶Upload data for an ingest job.
+Job must be in the "Open" state.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
job_id |
+
+ str
+ |
+
+
+
+ Ingest job ID. + |
+ + required + | +
data |
+
+ bytes
+ |
+
+
+
+ CSV data to upload. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ JobInfo
+ |
+
+
+
+ Job information. + |
+
src/aiosalesforce/bulk/v2/ingest.py
perform_operation(operation, sobject, data, fieldnames=None, max_size_bytes=100000000, max_records=150000000, external_id_field=None, assignment_rule_id=None, polling_interval=5.0)
+
+
+ async
+
+
+¶Perform a bulk ingest operation.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
operation |
+
+ (insert, delete, hardDelete, update, upsert)
+ |
+
+
+
+ Operation to perform. + |
+
+ "insert"
+ |
+
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. + |
+ + required + | +
data |
+
+ Iterable[dict[str, Any]]
+ |
+
+
+
+ Sequence of records to ingest. + |
+ + required + | +
fieldnames |
+
+ Collection[str]
+ |
+
+
+
+ Field names, determines order of fields in the CSV file.
+By default field names are inferred from the records. This is slow, so
+if you know the field names in advance, it is recommended to provide them.
+If a record is missing a field, it will be written as an empty string.
+If a record has a field not in |
+
+ None
+ |
+
max_size_bytes |
+
+ int
+ |
+
+
+
+ Maximum size of each CSV file in bytes. +The default of 100MB is recommended by Salesforce recommends. +This accounts for base64 encoding increases in size by up to 50%. + |
+
+ 100000000
+ |
+
max_records |
+
+ int
+ |
+
+
+
+ Maximum number of records in each CSV file. By default 150,000,000. +This corresponds to the maximum number of records in a 24-hour period. + |
+
+ 150000000
+ |
+
external_id_field |
+
+ str | None
+ |
+
+
+
+ External ID field name, by default None. +Used for upsert operations. + |
+
+ None
+ |
+
assignment_rule_id |
+
+ str | None
+ |
+
+
+
+ The ID of an assignment rule to run for a Case or a Lead. +By default None. + |
+
+ None
+ |
+
polling_interval |
+
+ float
+ |
+
+
+
+ Interval in seconds to poll the job status. +By default 5.0 seconds. + |
+
+ 5.0
+ |
+
Yields:
+Type | +Description | +
---|---|
+ JobResult
+ |
+
+
+
+ Job result containing job information and successful, failed, +and unprocessed records. + |
+
src/aiosalesforce/bulk/v2/ingest.py
364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 |
|
Salesforce
+
+
+¶Salesforce API client.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
httpx_client |
+
+ AsyncClient
+ |
+
+
+
+ HTTP client. + |
+ + required + | +
base_url |
+
+ str
+ |
+
+
+
+ Base URL of the Salesforce instance. +Must be in the format: +
|
+ + required + | +
auth |
+
+ Auth
+ |
+
+
+
+ Authentication object. + |
+ + required + | +
version |
+
+ str
+ |
+
+
+
+ Salesforce API version. +By default, uses the latest version. + |
+
+ '60.0'
+ |
+
event_hooks |
+
+ Iterable[Callable[[Event], Awaitable[None] | None]]
+ |
+
+
+
+ Functions or coroutines executed when an event occurs. +Hooks are executed concurrently and order of execution is not guaranteed. +All hooks must be thread-safe. + |
+
+ None
+ |
+
retry_policy |
+
+ RetryPolicy
+ |
+
+
+
+ Retry policy for requests. +The default policy retries requests up to 3 times with exponential backoff +and retries the following: +
Set to None to disable retries. + |
+
+ POLICY_DEFAULT
+ |
+
concurrency_limit |
+
+ int
+ |
+
+
+
+ Maximum number of simultaneous requests to Salesforce. +The default is 100. + |
+
+ 100
+ |
+
src/aiosalesforce/client.py
28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 |
|
base_url: str = str(match_.groups()[0])
+
+
+ instance-attribute
+
+
+¶Base URL in the format https://[subdomain(s)].my.salesforce.com
+sobject: SobjectClient
+
+
+ cached
+ property
+
+
+¶Salesforce REST API sObject client.
+Use this client to perform CRUD operations on individual sObjects.
+bulk_v1: NoReturn
+
+
+ cached
+ property
+
+
+¶Get Salesforce Bulk API 1.0 client.
+Use this client to execute bulk ingest and query operations.
+bulk_v2: BulkClientV2
+
+
+ cached
+ property
+
+
+¶Get Salesforce Bulk API 2.0 client.
+Use this client to execute bulk ingest and query operations.
+request(*args, **kwargs)
+
+
+ async
+
+
+¶Make an HTTP request to Salesforce.
+ +src/aiosalesforce/client.py
get_limits()
+
+
+ async
+
+
+¶Get Salesforce org limits.
+ + + +Returns:
+Type | +Description | +
---|---|
+ dict
+ |
+
+
+
+ Salesforce org limits. + |
+
src/aiosalesforce/client.py
query(query, include_all_records=False)
+
+
+ async
+
+
+¶Execute a SOQL query.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
query |
+
+ str
+ |
+
+
+
+ SOQL query. + |
+ + required + | +
include_all_records |
+
+ bool
+ |
+
+
+
+ If True, includes all (active/deleted/archived) records. + |
+
+ False
+ |
+
Yields:
+Type | +Description | +
---|---|
+ dict
+ |
+
+
+
+ Query result record. + |
+
src/aiosalesforce/client.py
EventBus
+
+
+¶Event bus used to dispatch events to subscribed callbacks.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
callbacks |
+
+ Iterable[Callable[[Event], Awaitable[None] | None]]
+ |
+
+
+
+ Callbacks to subscribe to the event bus. + |
+
+ None
+ |
+
src/aiosalesforce/events/event_bus.py
subscribe_callback(callback)
+
+¶Subscribe a callback to the event bus.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
callback |
+
+ CallbackType
+ |
+
+
+
+ Function to be called when an event is published. + |
+ + required + | +
src/aiosalesforce/events/event_bus.py
unsubscribe_callback(callback)
+
+¶Unsubscribe a callback from the event bus.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
callback |
+
+ CallbackType
+ |
+
+
+
+ Function to be unsubscribed. + |
+ + required + | +
src/aiosalesforce/events/event_bus.py
publish_event(event)
+
+
+ async
+
+
+¶Publish an event and dispatch it to all subscribed callbacks.
+ +src/aiosalesforce/events/event_bus.py
Event
+
+
+
+ dataclass
+
+
+¶Base class for all events.
+ +src/aiosalesforce/events/events.py
RequestEvent
+
+
+
+ dataclass
+
+
+¶
+ Bases: Event
Emitted before a request is sent for the first time.
+ +src/aiosalesforce/events/events.py
RetryEvent
+
+
+
+ dataclass
+
+
+¶
+ Bases: Event
, ResponseMixin
Emitted immediately before a request is retried.
+ +src/aiosalesforce/events/events.py
ResponseEvent
+
+
+
+ dataclass
+
+
+¶
+ Bases: Event
, ResponseMixin
Emitted after an OK (status code < 300) response is received.
+ +src/aiosalesforce/events/events.py
RestApiCallConsumptionEvent
+
+
+
+ dataclass
+
+
+¶
+ Bases: Event
, ResponseMixin
Emitted after a REST API call is consumed.
+ +src/aiosalesforce/events/events.py
BulkApiBatchConsumptionEvent
+
+
+
+ dataclass
+
+
+¶
+ Bases: Event
, ResponseMixin
Emitted after a Bulk API batch is consumed.
+ +src/aiosalesforce/events/events.py
ResponseMixin
+
+
+¶Mixin class providing properties for events which may have response.
+ +src/aiosalesforce/events/events.py
SalesforceWarning
+
+
+¶SalesforceError
+
+
+¶
+ Bases: Exception
Base class for all Salesforce errors.
+ +src/aiosalesforce/exceptions.py
MoreThanOneRecordError
+
+
+¶
+ Bases: SalesforceError
Raised when more than one record is found by external ID.
+ + + +AuthenticationError
+
+
+¶
+ Bases: SalesforceError
Raised when authentication fails.
+ + + +AuthorizationError
+
+
+¶
+ Bases: SalesforceError
Raised when user has insufficient permissions to perform an action.
+ + + +RequestLimitExceededError
+
+
+¶
+ Bases: SalesforceError
Raised when org REST API request limit is exceeded.
+ + + +NotFoundError
+
+
+¶
+ Bases: SalesforceError
Raised when a resource is not found.
+ + + +ServerError
+
+
+¶
+ Bases: SalesforceError
Base class for 5xx errors.
+ + + +raise_salesforce_error(response)
+
+¶Given an HTTP response, raise an appropriate SalesforceError.
+https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/errorcodes.htm
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
response |
+
+ Response
+ |
+
+
+
+ HTTP response. + |
+ + required + | +
Raises:
+Type | +Description | +
---|---|
+ SalesforceError
+ |
+
+
+
+
+ |
+
src/aiosalesforce/exceptions.py
RetryPolicy
+
+
+¶
+ Bases: RetryBase
Policy for retrying requests.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
response_rules |
+
+ list[ResponseRule]
+ |
+
+
+
+ Rules for retrying requests based on their responses. + |
+
+ None
+ |
+
exception_rules |
+
+ list[ExceptionRule]
+ |
+
+
+
+ Rules for retrying requests after an exception. + |
+
+ None
+ |
+
max_retries |
+
+ int
+ |
+
+
+
+ Maximum total number of retries. By default 3. + |
+
+ 3
+ |
+
timeout |
+
+ float
+ |
+
+
+
+ Maximum time to retry. By default 60 seconds.
+Timeout is best effort and may exceed the specified time
+by up to |
+
+ 60
+ |
+
backoff_base |
+
+ float
+ |
+
+
+
+ Base time to sleep between retries. By default 0.5 seconds. + |
+
+ 0.5
+ |
+
backoff_factor |
+
+ float
+ |
+
+
+
+ Factor to increase sleep time between retries. By default 2. + |
+
+ 2
+ |
+
backoff_max |
+
+ float
+ |
+
+
+
+ Maximum time to sleep between retries. By default 10 seconds. + |
+
+ 10
+ |
+
backoff_jitter |
+
+ bool
+ |
+
+
+
+ If True, adds jitter to sleep time. By default True. + |
+
+ True
+ |
+
src/aiosalesforce/retries/policy.py
create_context()
+
+¶Create a new retry context.
+Retry context is used to handle retries for a single request.
+ +src/aiosalesforce/retries/policy.py
ExceptionRule
+
+
+¶
+ Bases: Generic[E]
Rule for deciding if a request should be retried after an exception.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
exc_type |
+
+ type[Exception]
+ |
+
+
+
+ Type of exception to retry. + |
+ + required + | +
func |
+
+ Callable[[Exception], Awaitable[bool] | bool] | None
+ |
+
+
+
+ Function or coroutine to determine if the request should be retried. +By default the provided exception is always retried. + |
+
+ None
+ |
+
max_retries |
+
+ int
+ |
+
+
+
+ Maximum number of retries. By default 3. + |
+
+ 3
+ |
+
src/aiosalesforce/retries/rules.py
62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 |
|
should_retry(exc)
+
+
+ async
+
+
+¶Determine if the request should be retried.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
exc |
+
+ Exception
+ |
+
+
+
+ Exception from the request. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+ True if the request should be retried, False otherwise. + |
+
src/aiosalesforce/retries/rules.py
ResponseRule
+
+
+¶Rule for deciding if a request should be retried based its response.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
func |
+
+ Callable[[Response], Awaitable[bool] | bool]
+ |
+
+
+
+ Function or coroutine to determine if the request should be retried. + |
+ + required + | +
max_retries |
+
+ int
+ |
+
+
+
+ Maximum number of retries. By default 3. + |
+
+ 3
+ |
+
src/aiosalesforce/retries/rules.py
should_retry(response)
+
+
+ async
+
+
+¶Determine if the request should be retried.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
response |
+
+ Response
+ |
+
+
+
+ Response from the request. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+ True if the request should be retried, False otherwise. + |
+
src/aiosalesforce/retries/rules.py
RetryContext
+
+
+¶
+ Bases: RetryBase
Context for handling retries for a single request.
+ +src/aiosalesforce/retries/policy.py
62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 |
|
send_request_with_retries(httpx_client, event_bus, semaphore, request)
+
+
+ async
+
+
+¶Send a request and retry it if necessary in accordance with the retry policy.
+Does not guarantee that the returned response is OK (status code < 300), +only that the request was retried according to the policy.
+Emits the following events:
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
httpx_client |
+
+ AsyncClient
+ |
+
+
+
+ HTTP client to send the request. + |
+ + required + | +
event_bus |
+
+ EventBus
+ |
+
+
+
+ Event bus to publish events. + |
+ + required + | +
semaphore |
+
+ Semaphore
+ |
+
+
+
+ Semaphore to limit the number of simultaneous requests. + |
+ + required + | +
request |
+
+ Request
+ |
+
+
+
+ Request to send. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Response
+ |
+
+
+
+ Response from the request. +Not guaranteed to be OK (status code < 300). + |
+
src/aiosalesforce/retries/policy.py
99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 |
|
should_retry(value)
+
+
+ async
+
+
+¶Determine if the request should be retried.
+If the request should be retried, the total retry count and the retry count +for the rule responsible for the retry are incremented.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
value |
+
+ Response | Exception
+ |
+
+
+
+ Response or Exception from the request. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+ True if the request should be retried, False otherwise. + |
+
src/aiosalesforce/retries/policy.py
sleep()
+
+
+ async
+
+
+¶Sleep between retries based on the backoff policy.
+ +src/aiosalesforce/retries/policy.py
SobjectClient
+
+
+¶Salesforce REST API sObject client.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
salesforce_client |
+
+ Salesforce
+ |
+
+
+
+ Salesforce client. + |
+ + required + | +
src/aiosalesforce/sobject.py
20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 |
|
base_url: str = '/'.join([f'{self.salesforce_client.base_url}', 'services', 'data', f'v{self.salesforce_client.version}', 'sobjects'])
+
+
+ instance-attribute
+
+
+¶Base URL in the format https://[subdomain(s)].my.salesforce.com/services/data/v[version]/sobjects
+create(sobject, /, data)
+
+
+ async
+
+
+¶Create a new record.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. +E.g. "Account", "Contact", etc. + |
+ + required + | +
data |
+
+ dict | str | bytes | bytearray
+ |
+
+
+
+ Data to create the record with. +Either a dict or a JSON string/bytes representing a dict. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ ID of the created record. + |
+
src/aiosalesforce/sobject.py
get(sobject, id_, /, external_id_field=None, fields=None)
+
+
+ async
+
+
+¶Get record by ID or external ID.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. +E.g. "Account", "Contact", etc. + |
+ + required + | +
id_ |
+
+ str
+ |
+
+
+
+ Salesforce record ID or external ID (if external_id_field is provided). + |
+ + required + | +
external_id_field |
+
+ str
+ |
+
+
+
+ External ID field name, by default None. + |
+
+ None
+ |
+
fields |
+
+ Iterable[str]
+ |
+
+
+
+ Fields to get for the record. +By default returns all fields. + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ dict
+ |
+
+
+
+ description + |
+
src/aiosalesforce/sobject.py
update(sobject, id_, /, data)
+
+
+ async
+
+
+¶Update record by ID.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. +E.g. "Account", "Contact", etc. + |
+ + required + | +
id_ |
+
+ str
+ |
+
+
+
+ Salesforce record ID. + |
+ + required + | +
data |
+
+ dict | str | bytes | bytearray
+ |
+
+
+
+ Data to update the record with. +Either a dict or a JSON string/bytes representing a dict. + |
+ + required + | +
src/aiosalesforce/sobject.py
delete(sobject, id_, /, external_id_field=None)
+
+
+ async
+
+
+¶Delete record by ID.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. +E.g. "Account", "Contact", etc. + |
+ + required + | +
id_ |
+
+ str
+ |
+
+
+
+ Salesforce record ID or external ID (if external_id_field is provided). + |
+ + required + | +
external_id_field |
+
+ str
+ |
+
+
+
+ External ID field name. +If not provided, id_ is treated as a record ID. + |
+
+ None
+ |
+
src/aiosalesforce/sobject.py
upsert(sobject, id_, /, external_id_field, data, validate=True)
+
+
+ async
+
+
+¶Upsert (update if exists, create if not) record by external ID.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
sobject |
+
+ str
+ |
+
+
+
+ Salesforce object name. +E.g. "Account", "Contact", etc. + |
+ + required + | +
id_ |
+
+ str
+ |
+
+
+
+ Salesforce record external ID. + |
+ + required + | +
external_id_field |
+
+ str
+ |
+
+
+
+ External ID field name. + |
+ + required + | +
data |
+
+ dict | str | bytes | bytearray
+ |
+
+
+
+ Data to upsert the record with. +Either a dict or a JSON string/bytes representing a dict. + |
+ + required + | +
validate |
+
+ bool
+ |
+
+
+
+ If True, validates the request and removes the external ID field +from the data if it's present. By default True. +The reason for this is that Salesforce does not allow +payload to contain an external ID field when upserting on it. +Set this to False if you know you data is correct and +you want to improve performance. + |
+
+ True
+ |
+
Returns:
+Type | +Description | +
---|---|
+ UpsertResponse
+ |
+
+
+
+ Dataclass with 'id' and 'created' fields. + |
+
src/aiosalesforce/sobject.py
179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 |
|
json_dumps(data)
+
+¶Serialize data to a JSON formatted bytes object.
+Utility function used to allow users to pass an already serialized JSON.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
data |
+
+ str | bytes | bytearray | Any
+ |
+
+
+
+ Data to be serialized. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ bytes
+ |
+
+
+
+ JSON formatted bytes object. + |
+
src/aiosalesforce/utils.py
json_loads(data)
+
+¶Deserialize JSON formatted data.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
data |
+
+ str | bytes | bytearray
+ |
+
+
+
+ JSON formatted data. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Any
+ |
+
+
+
+ Deserialized data. + |
+
src/aiosalesforce/utils.py
format_soql(query, *args, **kwargs)
+
+¶Format SOQL query template with dynamic parameters.
+While SOQL queries are safe by design (cannot create/update/delete records), +it is still possible to expose sensitive information via SOQL injection. +It is always recommended to use this function instead of string formatting.
+You should never surround your parameters with single quotes in the query +template - this is done automatically by this function when necessary. +E.g., "SELECT Id FROM Object WHERE Value = {value}"
+The only exception to this rule is when you use the 'like' format spec. +The 'like' format spec is used to escape special characters in a LIKE pattern +when a portion of it is dynamic. +E.g., "SELECT Id FROM Object WHERE Value LIKE '%{value:like}'"
+If you don't use the 'like' format spec when formatting LIKE statements, +you will get unnecessary quotes and special query characters +(% and _) will not be escaped. This would make you vulnerable to SOQL injection.
+ + + +Examples:
+>>> format_soql("SELECT Id FROM Account WHERE Name = {}", "John Doe")
+"SELECT Id FROM Account WHERE Name = 'John Doe'"
+>>> format_soql("SELECT Id FROM Account WHERE Name = {name}", name="John Doe")
+"SELECT Id FROM Account WHERE Name = 'John Doe'"
+>>> format_soql("SELECT Id FROM Account WHERE Name LIKE {value}", value="John%")
+"SELECT Id FROM Account WHERE Name LIKE 'John%'"
+>>> format_soql(
+>>> "SELECT Id FROM Record WHERE Description LIKE '% fails {pattern:like}'",
+>>> pattern="50% of the time",
+>>> )
+"SELECT Id FROM Record WHERE Description LIKE '% fails 50\% of the time'"
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
query |
+
+ LiteralString
+ |
+
+
+
+ SOQL query template. + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+ Formatted SOQL query. + |
+
src/aiosalesforce/utils.py
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Va=/["'&<>]/;qn.exports=za;function za(e){var t=""+e,r=Va.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i