Skip to content

Commit 1c77577

Browse files
authored
Support ephemeral resource restful_resource (#129)
* WIP * Ephemeral resource * xxx_path support expression * Migrate testing framework and improve ephemeral test
1 parent f41896c commit 1c77577

27 files changed

+1664
-430
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "restful_resource Ephemeral Resource - terraform-provider-restful"
4+
subcategory: ""
5+
description: |-
6+
restful_resource manages an ephemeral resource.
7+
---
8+
9+
# restful_resource (Ephemeral Resource)
10+
11+
`restful_resource` manages an ephemeral resource.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `expiry_locator` (String) Specifies how to discover the expiry time. The format is `scope.path`, where `scope` can be one of `exact`, `header` and `body`, and the `path` is using the [gjson syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md).
21+
- `method` (String) The HTTP method to open the ephemeral resource. Possible values are `GET`, `PUT`, `POST`, `PATCH`.
22+
- `path` (String) The path used to open the ephemeral resource, relative to the `base_url` of the provider.
23+
24+
### Optional
25+
26+
- `body` (Dynamic) The payload to open the ephemeral resource.
27+
- `close_body` (Dynamic) The payload to close the ephemeral resource.
28+
- `close_header` (Map of String) The header parameters that are applied to each close request. This overrides the `header` set in the resource block.
29+
- `close_method` (String) The HTTP method to close the ephemeral resource. Possible values are `PUT`, `POST`, `PATCH`, `DELETE`.
30+
- `close_path` (String) The path used to close the ephemeral resource, relative to the `base_url` of the provider.
31+
- `close_query` (Map of List of String) The query parameters that are applied to each close request. This overrides the `query` set in the resource block.
32+
- `expiry_ahead` (String) Advance the ephemeral resource expiry time by this duration. The format is same as Go's [ParseDuration](https://pkg.go.dev/time#ParseDuration).
33+
- `expiry_type` (String) The type of the ephemeral resource expiry time. Possible values are: "duration", "time" and "time.[layout]". "duration" means the expiry time is a [duration](https://pkg.go.dev/time#ParseDuration); "time" means the expiry time is a time, which defaults to RF3339 layout, unless the "layout" is explicitly specified (following Go's [convention](https://pkg.go.dev/time)).
34+
- `header` (Map of String) The header parameters that are applied to each request. This overrides the `header` set in the provider block.
35+
- `open_header` (Map of String) The header parameters that are applied to each open request. This overrides the `header` set in the resource block.
36+
- `open_query` (Map of List of String) The query parameters that are applied to each open request. This overrides the `query` set in the resource block.
37+
- `output_attrs` (Set of String) A set of `output` attribute paths (in [gjson syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)) that will be exported in the `output`. If this is not specified, all attributes will be exported by `output`.
38+
- `query` (Map of List of String) The query parameters that are applied to each request. This overrides the `query` set in the provider block.
39+
- `renew_body` (Dynamic) The payload to renew the ephemeral resource.
40+
- `renew_header` (Map of String) The header parameters that are applied to each renew request. This overrides the `header` set in the resource block.
41+
- `renew_method` (String) The HTTP method to renew the ephemeral resource. Possible values are `GET`, `PUT`, `POST`, `PATCH`.
42+
- `renew_path` (String) The path used to renew the ephemeral resource, relative to the `base_url` of the provider.
43+
- `renew_query` (Map of List of String) The query parameters that are applied to each renew request. This overrides the `query` set in the resource block.
44+
45+
### Read-Only
46+
47+
- `output` (Dynamic) The response body.

docs/resources/operation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "restful_operation" "register_rp" {
4848
- `delete_query` (Map of List of String) The query parameters that are applied to each delete request. This overrides the `query` set in the resource block.
4949
- `header` (Map of String) The header parameters that are applied to each request. This overrides the `header` set in the provider block.
5050
- `id_builder` (String) The pattern used to build the `id`. The `path` is used as the `id` instead if absent.This can be a string literal, or combined by following params: path param: `$(path)` expanded to `path`, body param: `$(body.x.y.z)` expands to the `x.y.z` property of the API body. Especially for the body param, it can add a chain of functions (applied from left to right), in the form of `$f1.f2(body)`. Supported functions include: `escape` (URL path escape, by default applied), `unescape` (URL path unescape), `base` (filepath base), `url_path` (path segment of a URL), `trim_path` (trim `path`).
51-
- `operation_header` (Map of String) The header parameters that are applied to each read request. This overrides the `header` set in the resource block.
51+
- `operation_header` (Map of String) The header parameters that are applied to each operation request. This overrides the `header` set in the resource block.
5252
- `operation_query` (Map of List of String) The query parameters that are applied to each operation request. This overrides the `query` set in the resource block.
5353
- `output_attrs` (Set of String) A set of `output` attribute paths (in [gjson syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)) that will be exported in the `output`. If this is not specified, all attributes will be exported by `output`.
5454
- `poll` (Attributes) The polling option for the "`Create`/`Update`" operation (see [below for nested schema](#nestedatt--poll))

go.mod

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ toolchain go1.23.3
77
require (
88
github.com/evanphx/json-patch v0.5.2
99
github.com/go-resty/resty/v2 v2.10.0
10+
github.com/hashicorp/go-multierror v1.1.1
1011
github.com/hashicorp/terraform-plugin-framework v1.13.0
11-
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
12+
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0
1213
github.com/hashicorp/terraform-plugin-go v0.25.0
13-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
14+
github.com/hashicorp/terraform-plugin-testing v1.11.0
1415
github.com/stretchr/testify v1.8.3
1516
github.com/tidwall/sjson v1.2.4
1617
golang.org/x/oauth2 v0.22.0
1718
)
1819

1920
require (
20-
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
21+
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
2122
github.com/agext/levenshtein v1.2.2 // indirect
2223
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
2324
github.com/cloudflare/circl v1.3.7 // indirect
@@ -26,13 +27,14 @@ require (
2627
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
2728
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
2829
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
29-
github.com/hashicorp/go-multierror v1.1.1 // indirect
30-
github.com/hashicorp/go-version v1.6.0 // indirect
31-
github.com/hashicorp/hc-install v0.6.3 // indirect
32-
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
30+
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
31+
github.com/hashicorp/go-version v1.7.0 // indirect
32+
github.com/hashicorp/hc-install v0.9.0 // indirect
33+
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
3334
github.com/hashicorp/logutils v1.0.0 // indirect
34-
github.com/hashicorp/terraform-exec v0.20.0 // indirect
35-
github.com/hashicorp/terraform-json v0.21.0 // indirect
35+
github.com/hashicorp/terraform-exec v0.21.0 // indirect
36+
github.com/hashicorp/terraform-json v0.23.0 // indirect
37+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 // indirect
3638
github.com/mitchellh/copystructure v1.2.0 // indirect
3739
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
3840
github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -42,9 +44,11 @@ require (
4244
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
4345
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
4446
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
45-
github.com/zclconf/go-cty v1.14.2 // indirect
46-
golang.org/x/crypto v0.26.0 // indirect
47-
golang.org/x/mod v0.17.0 // indirect
47+
github.com/zclconf/go-cty v1.15.0 // indirect
48+
golang.org/x/crypto v0.29.0 // indirect
49+
golang.org/x/mod v0.21.0 // indirect
50+
golang.org/x/sync v0.9.0 // indirect
51+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
4852
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
4953
gopkg.in/yaml.v3 v3.0.1 // indirect
5054
)
@@ -53,7 +57,7 @@ require (
5357
github.com/fatih/color v1.16.0 // indirect
5458
github.com/golang/protobuf v1.5.4 // indirect
5559
github.com/google/go-cmp v0.6.0 // indirect
56-
github.com/hashicorp/go-hclog v1.5.0 // indirect
60+
github.com/hashicorp/go-hclog v1.6.3 // indirect
5761
github.com/hashicorp/go-plugin v1.6.2 // indirect
5862
github.com/hashicorp/go-uuid v1.0.3 // indirect
5963
github.com/hashicorp/terraform-plugin-log v0.9.0
@@ -68,8 +72,8 @@ require (
6872
github.com/tidwall/match v1.1.1 // indirect
6973
github.com/tidwall/pretty v1.2.0 // indirect
7074
golang.org/x/net v0.28.0
71-
golang.org/x/sys v0.24.0 // indirect
72-
golang.org/x/text v0.17.0 // indirect
75+
golang.org/x/sys v0.27.0 // indirect
76+
golang.org/x/text v0.20.0 // indirect
7377
google.golang.org/appengine v1.6.8 // indirect
7478
google.golang.org/grpc v1.67.1 // indirect
7579
google.golang.org/protobuf v1.35.1 // indirect

0 commit comments

Comments
 (0)