Direkt zum Inhalt

Acronis Resource Management API - filter resources by policy_id not working

Thread needs solution
Beginner
Beiträge: 1
Kommentare: 1

I am trying to utilize the Resource Management API (as well as Policy Management) to develop several custom reports that my organization wants.  One of the reports is simply to export resource data aggregated by protection plan and resource type.  Based on the API reference documentation (List all resources), I should be able to pull a list of resources that are assigned to a policy ID using the query parameter applied_to_policy_id.  However, when I send a REST request to /resource_management/v4/resources with that filter, the response contains every resource we have in Acronis.  I confirmed that some filters listed in the documentation seem functional (resource_id, applied_only), while others are not (applied_to_policy_id, applicable_to_policy_id, applied_to_policy_selection_id).  Please provide necessary detail on what is necessary to fix the issues I am experiencing, as it appears that the API is expecting a different named parameter than provided in the documentation for this functionality.

As a follow-up question, the API documentation does not seem to provide a full list of accepted values for resource type.  It is listed as string data type instead of an enumerated type, so I expect there is a link to a set of string values somewhere in the docs.  Please provide this as well.

Thank you. 

0 Users found this helpful
Acronis engineer
Beiträge: 0
Kommentare: 77

Hello Brent,

My name is Ivaylo, API Platfrom Support Professional.

I confirm there are issues with the "policy" like filters you listed in your query, I only tested this now (nothing is filtered by policy UUID) but I cannot provide a root cause what's the issue with them. Please, submit a Support ticket for the non-working filters as we need to follow the correct flow reporting the issue to the respective RnD team. It is good that we have tickets for each single filter but as they are all related with the policy_id it should be fine with a single ticket, however if you have found other filters as well from this or other endpoint that requires a value or UUID of a different entity please submit a separate ticket for it.

On the follow-up question, it looks like our Resource Management API documentation lacks of enumeration list with all supported resource types for the correspondent filter. I have pulled this info from our internal notes with the supported public types that can be filtered:

"resource.machine"
"resource.group.all"
"resource.group.computers"
"resource.group.hosts_and_clusters"
"resource.group.vms_and_templates"
"resource.group.mssql_server"
"resource.group.msexchange_server"
"resource.group.msexchange_mailboxes"
"resource.group.msexchange_database"
"resource.group.msexchange_online_server"
"resource.group.nas_devices"
"resource.group.ovirt_vengine"

Thank you.

Beginner
Beiträge: 1
Kommentare: 1

Thank you for confirming the API issue.  However, can you please provide feedback on a workaround to achieve the results I am looking for?  I have reviewed the API documentation and did not see any documented way, but hopefully I am just missing it as I have to believe there is a way to perform this basic relation.  Again, the desired results are to be able to export a list of plans with an aggregation of resource type counts.

For example:
"55555555-5555-5555-5555-555555555555","Plan ABC","resource.machine",120
"88888888-8888-8888-8888-888888888888","Plan XYZ","resource.machine",89

I also tried first querying plans with include_applied_context=true and then utilizing the resulting context list to query the resource api, however there are a few issues with this approach as well...  First, the context is limited to 100 results so it fails my requirements for any plan containing over 100 resources since there is not a paging mechanism that I could see within the context.  Second, for some plans the context contains dynamic group ids that when added as a resource_id filter in resource management api return no results even though putting filter of parent_id with this same group guid does return records (another very odd behavior).

Any feedback to assist obtaining the above results is greatly appreciated.

 

Acronis engineer
Beiträge: 0
Kommentare: 77

Hello Brent,

The described goal can be achieved with the Policy Management API which appears to be working unlike the Resource Management API. And to me it looks way easier to count the number of resources where a plan is applied. I see that you have already tested it, I don't see another available workaround that works better than this.

Both endpoints:
https://developer.acronis.com/doc/resource-policy-management/v4/referen…
https://developer.acronis.com/doc/resource-policy-management/v4/referen…

As you saw, have the include_applied_context parameter, which when set to true will include the context object with sub-item items which includes in the response a list of resources' UUIDs of the devices/machines where this plan is applied. You count the UUIDs and you have the needed number assigned to the protection plan's item in the response.

Difference:

GET /api/policy_management/v4/policies?include_applied_context=true will pull all the existing plans in the customer tenant with some default system ones which you need to filter out by plan's name or by its composite plan's UUID (the UUID where "type": "policy.protection.total"), or by the UUID where "type": "policy.backup.machine" if you only have the Backup policy type applied, technically depending of the policy type but I would suggest using the composite plan's UUID.

GET /api/policy_management/v4/policies/{policy_id}?include_applied_context=true by specifying the policy UUID of a specific plan if you know which one you are targeting. All plans and policy UUIDs can be pulled with the above request first. In this call you only have 1 protection plan item with all its sub-policies and 1 context object with the resource items.

Examples in public Postman collections:
https://www.postman.com/grey-rocket-585331/workspace/acronis-cyber-plat…
https://www.postman.com/grey-rocket-585331/workspace/acronis-cyber-plat…

Only the endpoint for pulling all policies has the limit filter parameter but it controls the results of the policy items, not the items under the context object.

If this doesn't work for you I would advise submitting your described scenario via Support by requesting a feature request for both APIs.

Thank you.