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 Operation - Poll -> url_locator #103

Closed a-chartier closed 4 months ago

a-chartier commented 4 months ago

It's possible that I am missing something obvious and if that's the case I apologize but currently the url_locator field under the poll section is somewhat limited compared to the read_path option under the restful_resource

This use case would be Gitlab where the api status url is not returned by the initial create and instead of a separate path

This would not work and instead body.id would need to start the url_locator path

resource "restful_operation" "test" {
  path = "/projects/12231/ref/main/trigger/pipeline"

  method = "POST"

  poll = {
    url_locator    = "/projects/12231/pipelines/$(body.id)"
    status_locator = "body.status"
    status = {
      success = "success"
      pending = ["running"]
    }
  }
}

However using the following under the restful_resource resource works as expected.

resource "restful_resource" "test" {
  path          = "/projects/12231/ref/main/trigger/pipeline"
  read_path     = "/projects/12231/pipelines/$(body.id)"
  create_method = "POST"
  body = {
  }
  poll_create = {
    status_locator = "body.status"
    status = {
      success = "success"
      pending = ["running", "created"],
    }
  }
}

Ideally restful_operation would support the same path style and flexibly as restful_resource