CPM contain rich RESTful API interface that enable you to do everything you do manually in the UI in an automated way, but it can be difficult to start using the RESTful API.
We created this examples to assist customers in understanding our API’s and start using them.
This code is just an example to assist in understanding our API’s and is given with no warranty or support, it is your responsibility to test it and 100% understand it before using code in production
The target audience for the examples are developers and each example file has a comment with the version of CPM used to create it.
The attached zip contain the following files:
- Utils.py - utility class for functions that are used in more then one example file, for example we have here the requests.post that handle the API calls for the various examples.
- WorkingWithAPIKEY.py - General example, show how to use get token and refresh token
- WorkingWithPolicies.py - General example, shows various API's for policies (get policy, list policy, list targets, create policy, update policy, delete policy)
- WorkingWithRecovery.py - General example, shows various API's for recovery (getting info and doing recovery)
- WorkingWithReports.py - General example, shows various API's for Reports (getting audit, backup and summery report)
- CustomExcelReport(AWS).py - Scenario example, here we are collecting info from environment (policy list, account list, backups, recoveries, etc...) and printing it to one xlsx file
Tip: Understanding how some operation is done via UI will help to automate it using the RestApi's, for example when you recover EC2 instance you need to select backup record in the backup monitor and then select relevant snapshot to recover, so when doing the same via Apis' you will first need to first gather info (backup record id, snapshot id, etc...) before calling the recover Api command.
How to get API Key:
Each user has it's own API key, to enable API access and key, click on User -> Setting
Then click on API Access -> enable the checkbox -> Generate and Save API Authentication Key