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 the SLA policy name into its corresponding ID. For more information about the convert_sla()
function, see Getting an {slapolicyId}.
spp_url = "https://10.0.0.100"
spp_sessionid = "00000000000000000000000000000000"
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.
In this example, the convert_sla()
function will return the following ID for the Gold policy:
print(sla_id)
3001
The converter function allows you to specify the object by name and it converts it into the sla_id
in your request command. This chapter discusses how you convert names of various IBM Spectrum Protect Plus objects into their corresponding IDs. The IDs are used in API commands.
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.