Overview
This article talks about how to change the status of a resource.
Note that you can not make a direct post to the resource endpoint to change the status. Otherwise, you will run into this error:
"requests. exceptions.HTTPError: 405 Client Error: Method Not Allowed for URL: https://catalog.example.com:443/api/v2/resources/ec2_instances/7130/"
Considerations
To change the status of a resource from Active to Historical or vice versa via API, create a Resource Action that would handle updating the status of the resource. Then, execute the resource action from https://[yourcbdomain]/api/v3/cmp/resourceActions/
Procedure
Step 1 Add A resource Action
As an admin, navigate to Admin -> Resource Actions → Add New action type CB Plug-in.
In the code add:
def run(job, *args, **kwargs): r = kwargs.get('resource') set_progress("Status of this resource is : {}".format(r.lifecycle)) r.lifecycle = 'Historical' r.save() return "SUCCESS", "Status Changed Successfully", ""
Step 2 Execute the Action:
Make a post call to https://[yourcbdomain]/api/v3/cmp/resourceActions/
Additional information
https://docs.cloudbolt.io/articles/#!cloudbolt-latest-docs/cloudbolt-api-v3
0 Comments