Skip to content

Commit 5280631

Browse files
jorgenspangefbreckle
authored andcommitted
ca_file_path attribute added to webhook resource
1 parent 02c9631 commit 5280631

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/resources/webhook.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ resource "netbox_webhook" "test" {
3535

3636
- `additional_headers` (String)
3737
- `body_template` (String)
38+
- `ca_file_path` (String)
3839
- `http_content_type` (String) The complete list of official content types is available [here](https://www.iana.org/assignments/media-types/media-types.xhtml). Defaults to `application/json`.
3940
- `http_method` (String) Valid values are `GET`, `POST`, `PUT`, `PATCH` and `DELETE`. Defaults to `POST`.
4041

netbox/resource_netbox_webhook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func resourceNetboxWebhook() *schema.Resource {
5757
Type: schema.TypeString,
5858
Optional: true,
5959
},
60+
"ca_file_path": {
61+
Type: schema.TypeString,
62+
Optional: true,
63+
},
6064
},
6165
Importer: &schema.ResourceImporter{
6266
StateContext: schema.ImportStatePassthroughContext,
@@ -77,6 +81,7 @@ func resourceNetboxWebhookCreate(d *schema.ResourceData, m interface{}) error {
7781
data.HTTPMethod = getOptionalStr(d, "http_method", false)
7882
data.HTTPContentType = getOptionalStr(d, "http_content_type", false)
7983
data.AdditionalHeaders = getOptionalStr(d, "additional_headers", false)
84+
data.CaFilePath = strToPtr(getOptionalStr(d, "ca_file_path", false))
8085

8186
params := extras.NewExtrasWebhooksCreateParams().WithData(data)
8287

@@ -114,6 +119,7 @@ func resourceNetboxWebhookRead(d *schema.ResourceData, m interface{}) error {
114119
d.Set("http_method", webhook.HTTPMethod)
115120
d.Set("http_content_type", webhook.HTTPContentType)
116121
d.Set("additional_headers", webhook.AdditionalHeaders)
122+
d.Set("ca_file_path", webhook.CaFilePath)
117123

118124
return nil
119125
}
@@ -134,6 +140,7 @@ func resourceNetboxWebhookUpdate(d *schema.ResourceData, m interface{}) error {
134140
data.HTTPMethod = getOptionalStr(d, "http_method", false)
135141
data.HTTPContentType = getOptionalStr(d, "http_content_type", false)
136142
data.AdditionalHeaders = getOptionalStr(d, "additional_headers", false)
143+
data.CaFilePath = strToPtr(getOptionalStr(d, "ca_file_path", false))
137144

138145
params := extras.NewExtrasWebhooksUpdateParams().WithID(id).WithData(&data)
139146

netbox/resource_netbox_webhook_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func TestAccNetboxWebhook_basic(t *testing.T) {
1717
testPayloadURL := "https://example.com/webhook"
1818
testBodyTemplate := "Sample Body"
1919
testAdditionalHeaders := "Authentication: Bearer abcdef123456"
20+
testCaFilePath := "/etc/ssl/certs"
2021
resource.ParallelTest(t, resource.TestCase{
2122
Providers: testAccProviders,
2223
CheckDestroy: testAccCheckNetBoxWebhookDestroy,
@@ -28,12 +29,14 @@ resource "netbox_webhook" "test" {
2829
payload_url = "%s"
2930
body_template = "%s"
3031
additional_headers = "%s"
31-
}`, testName, testPayloadURL, testBodyTemplate, testAdditionalHeaders),
32+
ca_file_path = "%s"
33+
}`, testName, testPayloadURL, testBodyTemplate, testAdditionalHeaders, testCaFilePath),
3234
Check: resource.ComposeTestCheckFunc(
3335
resource.TestCheckResourceAttr("netbox_webhook.test", "name", testName),
3436
resource.TestCheckResourceAttr("netbox_webhook.test", "payload_url", testPayloadURL),
3537
resource.TestCheckResourceAttr("netbox_webhook.test", "body_template", testBodyTemplate),
3638
resource.TestCheckResourceAttr("netbox_webhook.test", "additional_headers", testAdditionalHeaders),
39+
resource.TestCheckResourceAttr("netbox_webhook.test", "ca_file_path", testCaFilePath),
3740
),
3841
},
3942
{

0 commit comments

Comments
 (0)