diff --git a/CHANGELOG.md b/CHANGELOG.md index d355d652d..a8944b6a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # UNRELEASED +* Adds `ManageAgentPools` permission to team `OrganizationAccess` by @emlanctot [#901](https://github.com/hashicorp/go-tfe/pull/901) ## Enhancements diff --git a/team.go b/team.go index dcee1d7b7..4bc33a05a 100644 --- a/team.go +++ b/team.go @@ -75,6 +75,7 @@ type OrganizationAccess struct { ManageTeams bool `jsonapi:"attr,manage-teams"` ManageOrganizationAccess bool `jsonapi:"attr,manage-organization-access"` AccessSecretTeams bool `jsonapi:"attr,access-secret-teams"` + ManageAgentPools bool `jsonapi:"attr,manage-agent-pools"` } // TeamPermissions represents the current user's permissions on the team. @@ -164,6 +165,7 @@ type OrganizationAccessOptions struct { ManageTeams *bool `json:"manage-teams,omitempty"` ManageOrganizationAccess *bool `json:"manage-organization-access,omitempty"` AccessSecretTeams *bool `json:"access-secret-teams,omitempty"` + ManageAgentPools *bool `json:"manage-agent-pools,omitempty"` } // List all the teams of the given organization. diff --git a/team_integration_test.go b/team_integration_test.go index 04a1306be..0c0d3652a 100644 --- a/team_integration_test.go +++ b/team_integration_test.go @@ -611,3 +611,38 @@ func TestTeamsUpdateAccessSecretTeams(t *testing.T) { originalTeamAccess.AccessSecretTeams = true assert.Equal(t, originalTeamAccess, refreshed.OrganizationAccess) } + +func TestTeamsUpdateManageAgentPools(t *testing.T) { + client := testClient(t) + ctx := context.Background() + + orgTest, orgTestCleanup := createOrganization(t, client) + defer orgTestCleanup() + + tmTest, tmTestCleanup := createTeam(t, client, orgTest) + defer tmTestCleanup() + + teamRead, err := client.Teams.Read(ctx, tmTest.ID) + require.NoError(t, err) + assert.False(t, teamRead.OrganizationAccess.ManageAgentPools, "manage agent pools is false by default") + + originalTeamAccess := teamRead.OrganizationAccess + + options := TeamUpdateOptions{ + OrganizationAccess: &OrganizationAccessOptions{ + ManageAgentPools: Bool(true), + }, + } + + tm, err := client.Teams.Update(ctx, tmTest.ID, options) + require.NoError(t, err) + assert.True(t, tm.OrganizationAccess.ManageAgentPools) + + refreshed, err := client.Teams.Read(ctx, tmTest.ID) + require.NoError(t, err) + assert.True(t, refreshed.OrganizationAccess.ManageAgentPools) + + // Check that other org access fields are not updated + originalTeamAccess.ManageAgentPools = true + assert.Equal(t, originalTeamAccess, refreshed.OrganizationAccess) +}