Skip to content

How to handle APIs with nested response result object #314

@joraff

Description

@joraff

When working with a CRUD API that embeds the successful response from an API call into another data object in the JSON response, how can this provider be used to manage that object?

Cloudflare's API is a good example. To create a resource_group, one can:

POST /accounts/{account_id}/iam/resource_groups
{
  ...resource_group_data
}

And receive a response of

{
  "result": { ...resource_group_data },
  "success": true,
  "errors": [],
  "messages": []
}

When refreshing, a GET /accounts/{account_id}/iam/resource_groups/{id} has the exact response. However, the provider is comparing this object to what's in its internal data value, which is just resource_group_data, and it wants to update the object.

results_key isn't used unless there's a search, so what other techniques can be used to massage this update comparison?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions