Skip to content

Commit

Permalink
Merge pull request #145 from firehydrant/wh/alrt-568-team-slug
Browse files Browse the repository at this point in the history
teams: support slug modification
  • Loading branch information
davidcelis committed Mar 11, 2024
2 parents 1a1aeb8 + a5fa6c1 commit f5591ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Next (Unreleased)
## 0.5.0

N/A
* `firehydrant_team` now supports `slug` attribute ([#145](https://github.com/firehydrant/terraform-provider-firehydrant/pull/145)).

## 0.4.2

Expand Down
7 changes: 4 additions & 3 deletions docs/resources/team.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ The following arguments are supported:

* `name` - (Required) The name of the team.
* `description` - (Optional) A description for the team.
* `slug` - (Optional) Team slug identifier. If not provided, it will be generated from the name.
* `memberships` - (Optional) A resource to tie a schedule or user to a team via a incident role.

The `memberships` block supports:

Either the user_id or schedule_id is required for this block.
Either the `user_id` or `schedule_id` is required for this block.

* `user_id` - (Required) Id of the user.
* `schedule_id` - (Required) Id of the schedule.
* `user_id` - (Required) ID of the user.
* `schedule_id` - (Required) ID of the schedule.
* `default_incident_role_id` - (Optional) Incident role to assign the user or schedule.

## Attributes Reference
Expand Down
2 changes: 2 additions & 0 deletions firehydrant/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ type TeamQuery struct {
type CreateTeamRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Slug string `json:"slug,omitempty"`
Memberships []Membership `json:"memberships,omitempty"`
}

Expand All @@ -246,6 +247,7 @@ type TeamService struct {
type UpdateTeamRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Slug string `json:"slug,omitempty"`
Memberships []Membership `json:"memberships,omitempty"`
}

Expand Down
12 changes: 12 additions & 0 deletions provider/team_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func resourceTeam() *schema.Resource {
},
},
},
"slug": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -82,6 +87,7 @@ func readResourceFireHydrantTeam(ctx context.Context, d *schema.ResourceData, m
attributes := map[string]interface{}{
"name": teamResponse.Name,
"description": teamResponse.Description,
"slug": teamResponse.Slug,
}

// Process any attributes that could be nil
Expand Down Expand Up @@ -113,6 +119,9 @@ func createResourceFireHydrantTeam(ctx context.Context, d *schema.ResourceData,
Name: d.Get("name").(string),
Description: d.Get("description").(string),
}
if slug, ok := d.GetOk("slug"); ok {
createRequest.Slug = slug.(string)
}

// Process any optional attributes and add to the create request if necessary
memberships := d.Get("memberships")
Expand Down Expand Up @@ -150,6 +159,9 @@ func updateResourceFireHydrantTeam(ctx context.Context, d *schema.ResourceData,
Name: d.Get("name").(string),
Description: d.Get("description").(string),
}
if slug, ok := d.GetOk("slug"); ok {
updateRequest.Slug = slug.(string)
}

// Process any optional attributes and add to the update request if necessary
memberships := d.Get("memberships")
Expand Down

0 comments on commit f5591ed

Please sign in to comment.