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

Allow multiple success or failure values in _poll (consistent with pending) #109

Closed hongkongkiwi closed 3 months ago

hongkongkiwi commented 3 months ago

Is it possible to change the "success" & "failure" in the *_poll params to an array? e.g.

  poll_delete = {
    status_locator = "code"
    status = {
      success = ["204", "404"]
    }
  }

and it could work well for body also (this is a bad example but imagine another case where it could be a couple of different strings to indicate success):

  poll_update = {
    status_locator = "body.status"
    status = {
      success = ["Succeeded", "Updated"]
      failure = ["Failed"]
      pending = ["Pending"]
    }
  }

The only downside is that this is a breaking change as single values now need to be a single value array, but it keeps it consistent across success, pending, failure values and allows a bit more flexibility.

hongkongkiwi commented 3 months ago

Oh I just realised also that "failure" is currently undocumented for resource :)

magodo commented 3 months ago

As is said in https://github.com/magodo/terraform-provider-restful/issues/108#issuecomment-2275868342, I'm refrained to introduce the multiple success statuses. Also, failure is omit by design, which represents all statuses other than success + pending.

With this, I'm gonna close this issue.

hongkongkiwi commented 3 months ago

What I mean is that "failure" option of poll is not in the docs, but it is in your examples here:

It might be good add it to the documentation if it's a valid option that can be used or remove it if it shouldn't be used.

magodo commented 3 months ago

@hongkongkiwi Thank you for pointing this out! Will update the example then.

Updated in https://github.com/magodo/terraform-provider-restful/commit/83a751b4c1790325bbff20539c54c2c23f008f9b