Skip to content

Commit

Permalink
runbooks: add restricted field (#149)
Browse files Browse the repository at this point in the history

Co-authored-by: nema darban <nema.darban@stash.com>
  • Loading branch information
wilsonehusin and kneemaa committed Mar 27, 2024
1 parent cdf3357 commit a8d0581
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Unreleased
## 0.7.0

ENHANCEMENTS:
* **Added to Data Source**: `firehydrant_slack_channel`. Now you can pass either the channel id or the channel name to the data source.
* `firehydrant_runbook` now supports `restricted` field for private incidents runbook ([#149](https://github.com/firehydrant/terraform-provider-firehydrant/pull/149))

## 0.6.0

Expand Down
1 change: 1 addition & 0 deletions docs/resources/runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The following arguments are supported:
```
* `description` - (Optional) A description of the runbook.
* `owner_id` - (Optional) The ID of the team that owns this runbook.
* `restricted` - (Optional) Only apply this runbook to private incidents.

The `steps` block supports:

Expand Down
3 changes: 3 additions & 0 deletions firehydrant/runbooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const RunbookAttachmentRuleDefaultJSON = `
type CreateRunbookRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Restricted bool `json:"auto_attach_to_restricted_incidents,omitempty"`
Description string `json:"description"`
Owner *RunbookTeam `json:"owner,omitempty"`

Expand Down Expand Up @@ -69,6 +70,7 @@ type RunbookStep struct {
// URL: PATCH https://api.firehydrant.io/v1/runbooks/{id}
type UpdateRunbookRequest struct {
Name string `json:"name,omitempty"`
Restricted bool `json:"auto_attach_to_restricted_incidents"`
Description string `json:"description"`
Owner *RunbookTeam `json:"owner,omitempty"`
Steps []RunbookStep `json:"steps,omitempty"`
Expand All @@ -80,6 +82,7 @@ type UpdateRunbookRequest struct {
type RunbookResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Restricted bool `json:"auto_attach_to_restricted_incidents"`
Description string `json:"description"`
Owner *RunbookTeam `json:"owner"`
Steps []RunbookStep `json:"steps"`
Expand Down
8 changes: 8 additions & 0 deletions provider/runbook_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"

"github.com/firehydrant/terraform-provider-firehydrant/firehydrant"

"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -111,6 +112,10 @@ func resourceRunbook() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"restricted": {
Type: schema.TypeBool,
Optional: true,
},
"owner_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -144,6 +149,7 @@ func readResourceFireHydrantRunbook(ctx context.Context, d *schema.ResourceData,
attributes := map[string]interface{}{
"name": runbookResponse.Name,
"description": runbookResponse.Description,
"restricted": runbookResponse.Restricted,
}

if len(runbookResponse.AttachmentRule) > 0 {
Expand Down Expand Up @@ -211,6 +217,7 @@ func createResourceFireHydrantRunbook(ctx context.Context, d *schema.ResourceDat
createRequest := firehydrant.CreateRunbookRequest{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Restricted: d.Get("restricted").(bool),
}

// Process any optional attributes and add to the create request if necessary
Expand Down Expand Up @@ -292,6 +299,7 @@ func updateResourceFireHydrantRunbook(ctx context.Context, d *schema.ResourceDat
updateRequest := firehydrant.UpdateRunbookRequest{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Restricted: d.Get("restricted").(bool),
}

// Process any optional attributes and add to the update request if necessary
Expand Down

0 comments on commit a8d0581

Please sign in to comment.