magodo / terraform-provider-restful

Terraform provider to manage RESTful resources
https://registry.terraform.io/providers/magodo/restful
Mozilla Public License 2.0
16 stars 5 forks source link

`restful_resource` - Supports `update_body_patches` #127

Closed magodo closed 2 weeks ago

magodo commented 2 weeks ago

This PR adds support for update_body_patches to the restful_resource resource. This attribute is not supposed to be used for most API providers. The only use case can be found at https://github.com/magodo/terraform-provider-restful/issues/125, where the API requires the resource ID for an update, which is only available after the creation.

The reason this schema is designed as such, especially using the raw_json here is to support different data types. Note that the dynamic type can't be used here, see https://github.com/hashicorp/terraform-plugin-framework/issues/973.

Another attempt is to turn the patches into one single dynamic attribute named update_body_patch, similar to the json merge patch. While this will restrict the use of expression parameters, in that there is no trivial way to convert them into types other than string.

Also, note that any change to this attribute won't cause a real update, unless the body has changes.

Lastly, the name of update_body_patches is picked for the potential attributes ephemeral_body_patches (or write_only_body_patches), for both create and update.

Fix https://github.com/magodo/terraform-provider-restful/issues/125.

mdepedrof commented 1 week ago

Its perfect! thanks!!!