SFDClib
*******
SFDClib is a Salesforce.com Metadata API and Tooling API client built for Python 2.7, 3.3 and 3.4.
Usage
-----
To use API classes one needs to create a session first by instantiating SfdcSession class and passing login details to the constructor.
One method is to pass in the username, password, and token:
.. code-block:: python
from sfdclib import SfdcSession
s = SfdcSession(
'username': 'sfdcadmin@company.com.sandbox',
'password': 'Pa$sw0rd',
'token': 'TOKEN',
'is_sandbox': True
)
s.login()
A second method, if you've already logged in elsewhere, is to pass in the instance and session_id. This method does not require calling login().
.. code-block:: python
from sfdclib import SfdcSession
s = SfdcSession(
'session_id': 'thiswillbeaverylongstringofcharactersincludinglettersspacesandsymbols',
'instance': 'custom-sf-site.my'
)
# Notice we are not calling the login() method for this example.
Then create an instance of corresponding API class passing session object.
.. code-block:: python
from sfdclib import SfdcToolingApi
tooling = SfdcToolingApi(s)
r = tooling.anon_query("SELECT Id, Name FROM User LIMIT 10")
Implemented methods
-------------------
SfdcSession
^^^^^^^^^^^
|
| **login()** - establishes a session with Salesforce
| **is_connected()** - returns True if session has been established
| **get_session_id()** - returns Salesforce session ID
| **get_server_url()** - returns url to the login server (https://**test**.salesforce.com when not connected and https://**instance_name**.salesforce.com when connected)
| **get_api_version()** - returns API version being used (36.0, 37.0, ...)
|
SfdcMetadataApi
^^^^^^^^^^^^^^^
|
| **deploy(zipfile, options)** - submits deploy request
| **check_deploy_status(id)** - returns 3-tuple containing state, state detail and test result errors
| **retrieve(options)** - submits retrieve request
| **check_retrieve_status(id)** - retrieves retrieve call status. returns 3-tuple containing state, state detail and warning/error messages
| **retrieve_zip(id)** - retrieves resulting ZIP file for the specified Id of retrieve call. returns 4-tuple containing state, state detail, warning/error messages and ZIP file
|
SfdcToolingApi
^^^^^^^^^^^^^^
|
| **anon_query(query)** - executes anonymous SOQL query and returns results in a form of `requests.Response <http://docs.python-requests.org/en/master/user/quickstart/#response-content>`_
| **get(uri)** - sends GET request to specified URI
| **post(uri, data)** - sends passed data in a POST request to specified URI
| **delete(uri)** - sends DELETE request to specified URI
| **anon_apex(apex)** - executes anonymous apex with a success or error message
| **execute_AnonApex(apex) ** - executes anonymous apex and returns the System output information in the form of a text body
| **apexLog_Q(auditlog_id)** - queries for and returns the AuditLog body of the AuditLog Id given to it.
| **set_Traceflag(user_id)** - sets a traceflag for the supplied user Id
| **delete_Traceflag(traceflag_id)** - deletes the TraceFlag associated with the provided TraceFlag Id
|
SfdcBulkApi
^^^^^^^^^^^
|
| **export(object_name, query=None)** - exports data of specified object. If query is not passed only Id field will be exported
| **upsert(object_name, csv_data, external_id_field)** - upserts data to specified object. Records will be matched by external id field
| **update(object_name, csv_data)** - updates data in specified object. Records will be matched by Id field
| **delete(object_name, csv_data)** - deletes data from specified object. Records will be matched by Id field
|
TroubleShooting
-------
To use the execute_AnonApex function you will need to provide a DebugLevelId to the traceFlagPL located in the function set_Traceflag().
To get your DebugLevelId log onto the Salesforce environment, open the developer console, and execute **select Id, LogType, ExpirationDate, DebugLevelId from TraceFlag**.
License
-------
This package is released under the MIT license.
Metadata
Release files for sfdclib 0.2.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sfdclib-0.2.26.tar.gz | 11.9 kB | Without provenance | Details |
Release files / sfdclib-0.2.26.tar.gz
| Download URL | sfdclib-0.2.26.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62cc8c92404480f472ad7d33eec81d1ce16f259b8be13c02b9db8c4e52a89e6f
|
|
BLAKE2b-256 checksum How to use checksums |
7eb17f6cc57722eb832a46297ec23d6ca1e73beac11c6f5135313d17e51248c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.0
|
Security for sfdclib 0.2.26
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.