From 3018d84f832a121c3f38fa57bba18bc31bfd1368 Mon Sep 17 00:00:00 2001 From: "Wilson E. Husin" Date: Fri, 8 Mar 2024 15:29:14 -0800 Subject: [PATCH 1/4] teams: support slug modification --- firehydrant/types.go | 2 ++ provider/team_resource.go | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/firehydrant/types.go b/firehydrant/types.go index e7e0aa1..e0852ae 100644 --- a/firehydrant/types.go +++ b/firehydrant/types.go @@ -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"` } @@ -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"` } diff --git a/provider/team_resource.go b/provider/team_resource.go index 9b969af..c10eecb 100644 --- a/provider/team_resource.go +++ b/provider/team_resource.go @@ -53,6 +53,11 @@ func resourceTeam() *schema.Resource { }, }, }, + "slug": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, }, } } @@ -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 @@ -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") @@ -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") From 551d02ffeb0fc810a15dcbaecac026e1f68359b8 Mon Sep 17 00:00:00 2001 From: "Wilson E. Husin" Date: Fri, 8 Mar 2024 15:32:46 -0800 Subject: [PATCH 2/4] changelog: update --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e8a30..8357f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ -## Next (Unreleased) +## 0.5.0 (Unreleased) -N/A +* `firehydrant_team` now supports `slug` attribute ([#145](https://github.com/firehydrant/terraform-provider-firehydrant/pull/145)). ## 0.4.2 From e92f4c91573d8f0cdb9c7f73d804e38f60e8d476 Mon Sep 17 00:00:00 2001 From: "Wilson E. Husin" Date: Fri, 8 Mar 2024 15:35:07 -0800 Subject: [PATCH 3/4] docs: add slug to firehydrant_team resource --- docs/resources/team.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/resources/team.md b/docs/resources/team.md index 619590f..73f631d 100644 --- a/docs/resources/team.md +++ b/docs/resources/team.md @@ -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 From a5fa6c1e900b844abf76ffbaedae10f37cef6b7d Mon Sep 17 00:00:00 2001 From: "Wilson E. Husin" Date: Fri, 8 Mar 2024 15:45:20 -0800 Subject: [PATCH 4/4] changelog: cleanup --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8357f81..8b9d5ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.5.0 (Unreleased) +## 0.5.0 * `firehydrant_team` now supports `slug` attribute ([#145](https://github.com/firehydrant/terraform-provider-firehydrant/pull/145)).