Collection resourcesΒΆ
For collection resources, you can convert an object name to an ID. This operation might be necessary because the REST API often specifies objects by using their IDs instead of names.
For example, the following POST request can be used to apply an SLA Gold policy to the IBM Spectrum Protect Plus server with object name 10.0.0.100:
POST https://10.0.0.100/api/endeavour/job/1000
In this POST request, you do not see the SLA policy name, Gold. Instead, you see its ID: 1000. Similarly, the SLA policy Silver usually has the ID of 1001 unless you delete and recreate the policy using the same name. Because you might not know the ID of an SLA policy, you need a function to convert object names into corresponding IDs.
The following Python snippet converts an SLA policy name into its ID. For more information about the convert_sla()
function, follow the instructions in Getting an {slapolicyId}.
spp_url = "https://10.0.0.100"
spp_sessionid = "43b3b1b2cc434f4eb1b9df8c99e7866f"
sla_name = "Gold"
sla_id = convert_sla(spp_url, spp_sessionid, sla_name)
As shown in the previous example, the following information was required to log in to IBM Spectrum Protect Plus and obtain the SLA policy ID: the IBM Spectrum Protect Plus URL, the session ID, and the target object name, Gold.
In this example, the convert_sla()
function will return the following ID for the Gold policy:
print(sla_id)
3001
Read the available information to learn how the converter functions can be used to convert a wide variety of object names into IDs.
Restriction: Within an object type, use unique object names. For example, all SLA policies should have unique names. Some third-party products support the use of identical names for multiple objects of the same type. For example, Hyper-V Server you can create two virtual machines having the same name in the same path. Avoid using duplicate names in an IBM Spectrum Protect Plus environment.