Skip to content

Commit

Permalink
Merge pull request #128 from firehydrant/jz/v0.3.3
Browse files Browse the repository at this point in the history
prepare changelog for 0.3.3
  • Loading branch information
Jeff Zellner authored Jul 31, 2023
2 parents 2a5d38d + 0a7fe9a commit 1d3fefc
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 780 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
## 0.3.4 (Unreleased)

* New Data Source: `firehydrant_team` ([#121](https://github.com/firehydrant/terraform-provider-firehydrant/pull/121))
* New Data Source: `firehydrant_teams` ([#121](https://github.com/firehydrant/terraform-provider-firehydrant/pull/121))

## 0.3.3

* Bump golang from 1.16 to 1.18
* resource/service: Added `external_resources` attribute to service ([#123](https://github.com/firehydrant/terraform-provider-firehydrant/pull/123))

## 0.3.2

ENHANCEMENTS:

* Bump golang from 1.16 to 1.18
* **New Data Source:** `firehydrant_team` ([#121](https://github.com/firehydrant/terraform-provider-firehydrant/pull/121))
* **New Data Source:** `firehydrant_teams` ([#121](https://github.com/firehydrant/terraform-provider-firehydrant/pull/121))
* resource/service: Added `auto_add_responding_team` attribute to service ([#117](https://github.com/firehydrant/terraform-provider-firehydrant/pull/117))
* data_source/service: Added `auto_add_responding_team` attribute to service ([#117](https://github.com/firehydrant/terraform-provider-firehydrant/pull/117))
* data_source/services: Added `auto_add_responding_team` attribute to service ([#117](https://github.com/firehydrant/terraform-provider-firehydrant/pull/117))
* resource/service: Added `external_resources` attribute to service ([#123](https://github.com/firehydrant/terraform-provider-firehydrant/pull/123))
* resource/team: Add the ability to attach memberships to teams ([#116](https://github.com/firehydrant/terraform-provider-firehydrant/pull/116))

## 0.3.1
Expand Down
35 changes: 0 additions & 35 deletions docs/data-sources/team.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/data-sources/teams.md

This file was deleted.

11 changes: 0 additions & 11 deletions examples/teams.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
resource "firehydrant_team" "firefighters" {
name = "Firefighters"
}

data "firehydrant_team" "firefighters" {
id = "857a83c4-17d1-4362-a4e8-42d1a3d19ed1"
}

data "firehydrant_teams" "all_teams" {
}

data "firehydrant_teams" "test_teams" {
query = "Test"
}
75 changes: 71 additions & 4 deletions firehydrant/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ type Client interface {
Services() ServicesClient
Severities() SeveritiesClient
TaskLists() TaskListsClient
Teams() TeamsClient

// Teams
GetTeam(ctx context.Context, id string) (*TeamResponse, error)
CreateTeam(ctx context.Context, req CreateTeamRequest) (*TeamResponse, error)
UpdateTeam(ctx context.Context, id string, req UpdateTeamRequest) (*TeamResponse, error)
DeleteTeam(ctx context.Context, id string) error

// Users
GetUsers(ctx context.Context, params GetUserParams) (*UserResponse, error)
Expand Down Expand Up @@ -190,9 +195,21 @@ func (c *APIClient) TaskLists() TaskListsClient {
return &RESTTaskListsClient{client: c}
}

// Teams returns a TeamsClient interface for interacting with teams in FireHydrant
func (c *APIClient) Teams() TeamsClient {
return &RESTTeamsClient{client: c}
// GetTeam retrieves a team from FireHydrant
func (c *APIClient) GetTeam(ctx context.Context, id string) (*TeamResponse, error) {
teamResponse := &TeamResponse{}
apiError := &APIError{}
response, err := c.client().Get("teams/"+id).Receive(teamResponse, apiError)
if err != nil {
return nil, errors.Wrap(err, "could not get team")
}

err = checkResponseStatusCode(response, apiError)
if err != nil {
return nil, err
}

return teamResponse, nil
}

// GetUsers gets matching users in FireHydrant
Expand Down Expand Up @@ -228,3 +245,53 @@ func (c *APIClient) GetSchedules(ctx context.Context, params GetScheduleParams)

return scheduleResponse, nil
}

// CreateTeam creates a team in FireHydrant
func (c *APIClient) CreateTeam(ctx context.Context, req CreateTeamRequest) (*TeamResponse, error) {
teamResponse := &TeamResponse{}
apiError := &APIError{}
response, err := c.client().Post("teams").BodyJSON(&req).Receive(teamResponse, apiError)
if err != nil {
return nil, errors.Wrap(err, "could not create team")
}

err = checkResponseStatusCode(response, apiError)
if err != nil {
return nil, err
}

return teamResponse, nil
}

// UpdateTeam updates a team in FireHydrant
func (c *APIClient) UpdateTeam(ctx context.Context, id string, req UpdateTeamRequest) (*TeamResponse, error) {
teamResponse := &TeamResponse{}
apiError := &APIError{}
response, err := c.client().Patch("teams/"+id).BodyJSON(&req).Receive(teamResponse, apiError)
if err != nil {
return nil, errors.Wrap(err, "could not update team")
}

err = checkResponseStatusCode(response, apiError)
if err != nil {
return nil, err
}

return teamResponse, nil
}

// DeleteTeam deletes a team from FireHydrant
func (c *APIClient) DeleteTeam(ctx context.Context, id string) error {
apiError := &APIError{}
response, err := c.client().Delete("teams/"+id).Receive(nil, apiError)
if err != nil {
return errors.Wrap(err, "could not delete team")
}

err = checkResponseStatusCode(response, apiError)
if err != nil {
return err
}

return nil
}
121 changes: 0 additions & 121 deletions firehydrant/teams.go

This file was deleted.

Loading

0 comments on commit 1d3fefc

Please sign in to comment.