Skip to content

Commit c2dfafb

Browse files
committed
added examples in docs
1 parent d74d37c commit c2dfafb

File tree

4 files changed

+96
-6
lines changed

4 files changed

+96
-6
lines changed

docs/data-sources/curl2.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,48 @@ description: |-
1010

1111
Fetches the response for the api
1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
curl2 = {
19+
source = "mehulgohil/curl2"
20+
version = "1.0.0"
21+
}
22+
}
23+
}
24+
25+
provider "curl2" {}
26+
27+
data "curl2" "getPosts" {
28+
http_method = "GET"
29+
uri = "https://jsonplaceholder.typicode.com/posts"
30+
# auth_type = "Basic"
31+
# basic_auth_username = "<UserName>"
32+
# basic_auth_password = "<Password>"
33+
}
34+
35+
output "all_posts_response" {
36+
value = jsondecode(data.curl2.getPosts.response.body)
37+
}
38+
39+
output "all_posts_status" {
40+
value = data.curl2.getPosts.response.status_code
41+
}
42+
43+
data "curl2" "postPosts" {
44+
http_method = "POST"
45+
uri = "https://jsonplaceholder.typicode.com/posts"
46+
json = "{\"title\":\"foo\",\"body\":\"bar\",\"userId\":\"1\"}" //need the json in string format
47+
# auth_type = "Bearer"
48+
# bearer_token = "<Any Bearer Token>"
49+
}
50+
51+
output "post_posts_output" {
52+
value = data.curl2.postPosts.response
53+
}
54+
```
1455

1556
<!-- schema generated by tfplugindocs -->
1657
## Schema

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@ description: |-
1010

1111
Triggers HTTP(s) requests along with JSON body and authentication
1212

13+
## Example Usage
1314

15+
```terraform
16+
terraform {
17+
required_providers {
18+
curl2 = {
19+
source = "mehulgohil/curl2"
20+
version = "1.0.0"
21+
}
22+
}
23+
}
24+
25+
provider "curl2" {}
26+
27+
data "curl2" "getPosts" {
28+
http_method = "GET"
29+
uri = "https://jsonplaceholder.typicode.com/posts"
30+
}
31+
32+
output "all_posts_response" {
33+
value = jsondecode(data.curl2.getPosts.response.body)
34+
}
35+
36+
output "all_posts_status" {
37+
value = data.curl2.getPosts.response.status_code
38+
}
39+
```
1440

1541
<!-- schema generated by tfplugindocs -->
1642
## Schema

examples/main.tf renamed to examples/data-sources/curl2/data-source.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ provider "curl2" {}
1212
data "curl2" "getPosts" {
1313
http_method = "GET"
1414
uri = "https://jsonplaceholder.typicode.com/posts"
15-
# auth_type = "Basic"
16-
# basic_auth_username = "<UserName>"
17-
# basic_auth_password = "<Password>"
15+
# auth_type = "Basic"
16+
# basic_auth_username = "<UserName>"
17+
# basic_auth_password = "<Password>"
1818
}
1919

2020
output "all_posts_response" {
@@ -29,8 +29,8 @@ data "curl2" "postPosts" {
2929
http_method = "POST"
3030
uri = "https://jsonplaceholder.typicode.com/posts"
3131
json = "{\"title\":\"foo\",\"body\":\"bar\",\"userId\":\"1\"}" //need the json in string format
32-
# auth_type = "Bearer"
33-
# bearer_token = "<Any Bearer Token>"
32+
# auth_type = "Bearer"
33+
# bearer_token = "<Any Bearer Token>"
3434
}
3535

3636
output "post_posts_output" {

examples/provider/provider.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
terraform {
2+
required_providers {
3+
curl2 = {
4+
source = "mehulgohil/curl2"
5+
version = "1.0.0"
6+
}
7+
}
8+
}
9+
10+
provider "curl2" {}
11+
12+
data "curl2" "getPosts" {
13+
http_method = "GET"
14+
uri = "https://jsonplaceholder.typicode.com/posts"
15+
}
16+
17+
output "all_posts_response" {
18+
value = jsondecode(data.curl2.getPosts.response.body)
19+
}
20+
21+
output "all_posts_status" {
22+
value = data.curl2.getPosts.response.status_code
23+
}

0 commit comments

Comments
 (0)