Commvault / cvpysdk

Developer SDK - Python
https://commvault.github.io/cvpysdk/
Apache License 2.0
54 stars 41 forks source link

Search entities by id #130

Closed kevin-menon-EDF closed 3 years ago

kevin-menon-EDF commented 3 years ago

In order to have a specific commvault object, you must navigate through the parent entities from the commcell object. It would be practical to access an object by its id.

For example:

client = commcell.clients.get("my_vcenter")
agents = client.agents.get("my_agent")
instance = agents.instances.get("my_instance")
subclient = instance.subclients.get("my_subclient")

could be:

subclient = commcell.get_subclient(1)

This issue could be linked to https://github.com/Commvault/cvpysdk/issues/85

spakhare commented 3 years ago

Currently, this is not supported by design. The only way to get entity-specific property is by calling API directly.

kevin-menon-EDF commented 3 years ago

Is there a way I can transform my API request to a cvpysdk object ?

For example:

subclient_id = 1
response = commcell.request(f'/Subclient/{subclient_id}')
subclient = Subclient(response.json())

The class signature for Subclient requires a Backupset object, so it seems there is no way to instanciate it without navigation unless I am mistaking?

Many thanks for your answer

spakhare commented 3 years ago

Hi @kevin-menon-EDF,

Yes, you are correct, we require a backupset object for creating a subclient class. As of now, we cannot create a Subclient class using the API response.

Thanks