A New Door to Salesforce
Project description
DeployBit - A New Door to Salesforce
DeployBit is Salesforce Metadata API based, Lightweight Python Environment to Smoothen and Support your Development and Deployment Processes.
Supported API Calls
Login
Deploy
Check Deploy Status
Cancel Deploy
Retrieve
Check Retrieve Status
Describe Metadata
List Metadata
Query
Query More
Search
Apex Execute
Logout
Examples
1. DeployBitSalesforce Constructor - DeployBitSalesforce(username,password,security_token,session_id,api_version,environment)
DeployBitSalesforce constructor returns us the object to be used for salesforce connection, when provided with below details.
username - Username of the salesforce org
password - Password of the salesforce org
security_token - Security Token of the salesforce org
session_id - Session Id of the salesforce org
api_version - Api Version of the salesforce org eg. 45.0, default value is 50.0
environment - Environment of the salesforce org eg. login for Production org and test for sandbox, default value is login
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','aksdhjhasdas5d6asdhjasgdhasrd5a354sd678asd','45.0','test')
2. Login - login()
This method establishes connection to salesforce using details provided to DeployBitSalesforce constructor if credentials are correct and returns LoginResult.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123',None,'45.0','test')
sf.login()
3. Deploy - deploy(zip_file_path,**deploy_options)
This method deploys provided package .zip and returns deployment/validation status details using given DeployOptions.
zip_file_path - File path for .zip to be deployed
checkOnly - Flag decides type of deployment eg. Deployment or Validation
testLevel - This attributes decides the level of the test execustion eg. RunSpecifiedTests , NoTestRun
runTests - A list of Apex classes containing tests run after deployment when RunSpecifiedTests
ignoreWarnings - This setting indicates that a deployment succeeds even if there are warnings (true)
allowMissingFiles - Specifies whether a deploy succeeds even if files that are specified in package.xml are not in the zip file.
autoUpdatePackage - Specifies whether a deploy continues even if files present in the zip file are not specified in package.xml.
performRetrieve - Specifies whether a deploy continues even if files present in the zip file are not specified in package.xml.
purgeOnDelete - If true, the deleted components in the destructiveChanges.xml manifest file aren’t stored in the Recycle Bin.
rollbackOnError - Indicates whether any failure causes a complete rollback (true) or not (false).
singlePackage - Declares that the zipFile or deployRoot parameter points to a directory structure with a single package, as opposed to a set of packages.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
deploy_result=sf.deploy("/Documents/Release/TestClassPackage.zip",checkOnly=True,singlePackage=True,testLevel='runspecifiedtests',runTests=['DummyClasstest'])
4. Check Deploy Status - check_deploy_status(deployment_id,include_details)
This method checks current deployment status using provided deployment_id, include_details as True and returns deployment/validation details using DeployResult.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
deploy_result=sf.check_deploy_status('DeploymentId',include_details=True)
5. Cancel Deploy - cancel_deploy(deployment_id)
This method cancels ongoing deployment using provided deployment_id.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
deploy_result=sf.cancel_deploy('DeploymentId')
6. Retrieve - retrieve(xml_file_path,single_package)
This method initiates retrieve request for all mentioned components in the package.xml path provided in xml_file_path and returns retrieve_id to be used to get package data. Package behaviour will be based on single_package flag.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
retrieve_result=sf.retrieve("/Documents/Release/download.xml",single_package=True)
7. Check Retrieve Status - check_retrieve_status(retrieve_id,include_zip)
This method returns initiated retrieve request status using provided retrieve_id and returns RetrieveResult containing base64 zip string to be used for zip package generation if include_zip option is marked to True.
For example:
from DeployBit import DeployBitSalesforce
import base64,os
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
retrieve_result=sf.check_retrieve_status('RetrieveId',include_zip=True)
currentDirectory='/Documents/Release'
with open(os.path.join(currentDirectory,'output_file.zip'), 'wb') as result:
result.write(base64.b64decode(retrieve_result['zipFile']))
8. Describe Metadata - describe_metadata()
This method uses provided api_version in DeployBitSalesforce object and retrieves the metadata that describes your organization using DescribeMetadataResult.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
describe_result=sf.describe_metadata()
9. List Metadata - list_metadata(metadata_type)
This method retrieves property information about metadata components in your organization using provided metadata_type and api_version in DeployBitSalesforce object, returns FileProperties.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
describe_result=sf.list_metadata('ApexClass')
10. Query - query(query_string,batch_size,is_tooling_api)
This method executes a query against the specified object and returns data that matches the specified criteria using QueryResult.
query_string - A SOQL string to be used for query eg. SELECT id from Account limit 100
batch_size - Chunk size of the results to be returned from total records.
is_tooling_api - True will enable tooling API eg. SELECT id from CustomObject
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
query_result=sf.query("Select Id from Account",batch_size=250)
11. Query More - query_more(query_locator,batch_size,is_tooling_api)
This method retrieves the next batch of objects from a query() and returns data using QueryResult.
query_locator - A query_locator id returned by query() call in QueryResult
batch_size - Chunk size of the results to be returned from total records.
is_tooling_api - True will enable tooling API eg. SELECT id from CustomObject
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
query_result=sf.query_more("QueryLocatorId",batch_size=250)
12. Search - search(search_string,is_tooling_api)
This method retrieves the next batch of objects from a query() and returns data using SearchResult.
search_string - A SOSL string to be used for search eg. FIND {Test*} IN ALL FIELDS RETURNING Account(Name)
is_tooling_api - True will enable tooling API eg. FIND {Test*} in all fields returning CustomObject(Id,ManageableState)
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
search_result=sf.search("FIND {Test*} IN ALL FIELDS RETURNING Account(Name)")
13. Apex Execute - apex_execute(code_chunk,log_category,log_category_level)
This method compiles, executes your apex code chunks and returns results/debugs details using ExecuteAnonymousResult based on log_category and log_category_level options availble here DebuggingHeader.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
debugString="""List<Account> accList=[select Id,Name from Account limit 10];
for(Account acc:accList)
{
System.debug('===acc==='+acc.Name);
}"""
execute_result=sf.apex_execute(debugString)
14. Logout - logout()
This method terminates your session. New session can be created using login() method.
For example:
from DeployBit import DeployBitSalesforce
sf=DeployBitSalesforce('test@test.com','test123','tEstTesting123','45.0','test')
sf.login()
search_result=sf.search("FIND {Test*} IN ALL FIELDS RETURNING Account(Name)")
sf.logout()
Other DeployBit Implementations
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file DeployBit-1.6.tar.gz.
File metadata
- Download URL: DeployBit-1.6.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87b82600e6e52e6216f84acd12c6440e9ca8bd5061c8d6287f8c487a5422e0ac
|
|
| MD5 |
47c4d87bc4f95aa3030d2bd472614fd3
|
|
| BLAKE2b-256 |
fccf39da6bfe1e547557137388354bdbc709df294fa197f96b83798721975455
|