Skip to content

Commit 84dc580

Browse files
PLAT-7450 Add singlestoredb_team resource and datasource (#61)
* PLAT-7450 Add singlestoredb_team resource and datasource * Change API call to user emails
1 parent f19b84f commit 84dc580

File tree

19 files changed

+1443
-3
lines changed

19 files changed

+1443
-3
lines changed

docs/data-sources/team.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "singlestoredb_team Data Source - terraform-provider-singlestoredb"
4+
subcategory: ""
5+
description: |-
6+
Retrieve a specific team using its ID with this data source.
7+
---
8+
9+
# singlestoredb_team (Data Source)
10+
11+
Retrieve a specific team using its ID with this data source.
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "singlestoredb" {
17+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
18+
// Please set this environment variable with your SingleStore Management API key.
19+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
20+
}
21+
22+
data "singlestoredb_team" "this" {
23+
id = "24f31e2d-847f-4a62-9a93-a10e9bcd0dae" # Replace with the actual ID of the team.
24+
}
25+
26+
output "this_team" {
27+
value = data.singlestoredb_team.this
28+
}
29+
```
30+
31+
<!-- schema generated by tfplugindocs -->
32+
## Schema
33+
34+
### Required
35+
36+
- `id` (String) The unique identifier of the team.
37+
38+
### Read-Only
39+
40+
- `created_at` (String) The timestamp of when the team was created.
41+
- `description` (String) The description of the team.
42+
- `member_teams` (Attributes List) List of teams that are members of this team. (see [below for nested schema](#nestedatt--member_teams))
43+
- `member_users` (Attributes List) List of users that are members of this team. (see [below for nested schema](#nestedatt--member_users))
44+
- `name` (String) The name of the team.
45+
46+
<a id="nestedatt--member_teams"></a>
47+
### Nested Schema for `member_teams`
48+
49+
Read-Only:
50+
51+
- `description` (String) The description of the team.
52+
- `name` (String) The name of the team.
53+
- `team_id` (String) The unique identifier of the team.
54+
55+
56+
<a id="nestedatt--member_users"></a>
57+
### Nested Schema for `member_users`
58+
59+
Read-Only:
60+
61+
- `email` (String) The email of the user.
62+
- `first_name` (String) The first name of the user.
63+
- `last_name` (String) The last name of the user.
64+
- `user_id` (String) The unique identifier of the user.
65+
66+

docs/data-sources/teams.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "singlestoredb_teams Data Source - terraform-provider-singlestoredb"
4+
subcategory: ""
5+
description: |-
6+
This data source provides a list of teams that the user has access to.
7+
---
8+
9+
# singlestoredb_teams (Data Source)
10+
11+
This data source provides a list of teams that the user has access to.
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "singlestoredb" {
17+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
18+
// Please set this environment variable with your SingleStore Management API key.
19+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
20+
}
21+
22+
data "singlestoredb_teams" "all" {}
23+
24+
output "all_teams" {
25+
value = data.singlestoredb_teams.all
26+
}
27+
```
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Read-Only
33+
34+
- `id` (String) The ID of this resource.
35+
- `teams` (Attributes List) (see [below for nested schema](#nestedatt--teams))
36+
37+
<a id="nestedatt--teams"></a>
38+
### Nested Schema for `teams`
39+
40+
Required:
41+
42+
- `id` (String) The unique identifier of the team.
43+
44+
Read-Only:
45+
46+
- `created_at` (String) The timestamp of when the team was created.
47+
- `description` (String) The description of the team.
48+
- `member_teams` (Attributes List) List of teams that are members of this team. (see [below for nested schema](#nestedatt--teams--member_teams))
49+
- `member_users` (Attributes List) List of users that are members of this team. (see [below for nested schema](#nestedatt--teams--member_users))
50+
- `name` (String) The name of the team.
51+
52+
<a id="nestedatt--teams--member_teams"></a>
53+
### Nested Schema for `teams.member_teams`
54+
55+
Read-Only:
56+
57+
- `description` (String) The description of the team.
58+
- `name` (String) The name of the team.
59+
- `team_id` (String) The unique identifier of the team.
60+
61+
62+
<a id="nestedatt--teams--member_users"></a>
63+
### Nested Schema for `teams.member_users`
64+
65+
Read-Only:
66+
67+
- `email` (String) The email of the user.
68+
- `first_name` (String) The first name of the user.
69+
- `last_name` (String) The last name of the user.
70+
- `user_id` (String) The unique identifier of the user.
71+
72+

docs/resources/team.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "singlestoredb_team Resource - terraform-provider-singlestoredb"
4+
subcategory: ""
5+
description: |-
6+
Manage SingleStoreDB teams with this resource.
7+
---
8+
9+
# singlestoredb_team (Resource)
10+
11+
Manage SingleStoreDB teams with this resource.
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "singlestoredb" {
17+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
18+
// Please set this environment variable with your SingleStore Management API key.
19+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
20+
}
21+
22+
resource "singlestoredb_team" "this" {
23+
name = "terrafrom-test-team"
24+
description = "Terrafrom test team"
25+
member_users = []
26+
member_teams = []
27+
}
28+
29+
output "singlestoredb_team_id" {
30+
value = singlestoredb_team.this.id
31+
}
32+
```
33+
34+
<!-- schema generated by tfplugindocs -->
35+
## Schema
36+
37+
### Required
38+
39+
- `name` (String) The name of the team.
40+
41+
### Optional
42+
43+
- `description` (String) The description of the team.
44+
- `member_teams` (List of String) List of team UUIDs that are members of this team.
45+
- `member_users` (List of String) List of user emails that are members of this team.
46+
47+
### Read-Only
48+
49+
- `created_at` (String) The timestamp of when the team was created.
50+
- `id` (String) The unique identifier of the team.
51+
52+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider "singlestoredb" {
2+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
3+
// Please set this environment variable with your SingleStore Management API key.
4+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
5+
}
6+
7+
data "singlestoredb_team" "this" {
8+
id = "24f31e2d-847f-4a62-9a93-a10e9bcd0dae" # Replace with the actual ID of the team.
9+
}
10+
11+
output "this_team" {
12+
value = data.singlestoredb_team.this
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider "singlestoredb" {
2+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
3+
// Please set this environment variable with your SingleStore Management API key.
4+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
5+
}
6+
7+
data "singlestoredb_teams" "all" {}
8+
9+
output "all_teams" {
10+
value = data.singlestoredb_teams.all
11+
}

examples/embed.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var (
2525
UserListDataSource = mustRead("data-sources/singlestoredb_users/data-source.tf")
2626
InvitationsGetDataSource = mustRead("data-sources/singlestoredb_invitation/data-source.tf")
2727
InvitationsListDataSource = mustRead("data-sources/singlestoredb_invitations/data-source.tf")
28+
TeamsGetDataSource = mustRead("data-sources/singlestoredb_team/data-source.tf")
29+
TeamsResource = mustRead("resources/singlestoredb_team/resource.tf")
30+
TeamsListDataSource = mustRead("data-sources/singlestoredb_teams/data-source.tf")
2831
)
2932

3033
func mustRead(path string) string {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
provider "singlestoredb" {
2+
// The SingleStoreDB Terraform provider uses the SINGLESTOREDB_API_KEY environment variable for authentication.
3+
// Please set this environment variable with your SingleStore Management API key.
4+
// You can generate this key from the SingleStore Portal at https://portal.singlestore.com/organizations/org-id/api-keys.
5+
}
6+
7+
resource "singlestoredb_team" "this" {
8+
name = "terrafrom-test-team"
9+
description = "Terrafrom test team"
10+
member_users = []
11+
member_teams = []
12+
}
13+
14+
output "singlestoredb_team_id" {
15+
value = singlestoredb_team.this.id
16+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0
1212
github.com/hashicorp/terraform-plugin-go v0.25.0
1313
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
14-
github.com/singlestore-labs/singlestore-go/management v1.1.109
14+
github.com/singlestore-labs/singlestore-go/management v1.1.118
1515
github.com/stretchr/testify v1.8.4
1616
)
1717

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
184184
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
185185
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
186186
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
187-
github.com/singlestore-labs/singlestore-go/management v1.1.109 h1:EAIZLD3Fj1WetuL2xd0+CdcJbC8mpGhFOJz/KRpntdA=
188-
github.com/singlestore-labs/singlestore-go/management v1.1.109/go.mod h1:pfeKQbKr6ml61j823Pi4RUnBTug1buSxLJDmGINAoKc=
187+
github.com/singlestore-labs/singlestore-go/management v1.1.118 h1:RF60/0X9l+EIGuAoJZaLuokMKfc9gTTzrGnKrigtI90=
188+
github.com/singlestore-labs/singlestore-go/management v1.1.118/go.mod h1:pfeKQbKr6ml61j823Pi4RUnBTug1buSxLJDmGINAoKc=
189189
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
190190
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
191191
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=

internal/provider/provider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/privateconnections"
1919
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/regions"
2020
regions_v2 "github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/regionsv2"
21+
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/teams"
2122
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/users"
2223
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/util"
2324
"github.com/singlestore-labs/terraform-provider-singlestoredb/internal/provider/workspacegroups"
@@ -168,6 +169,8 @@ func (p *singlestoreProvider) DataSources(_ context.Context) []func() datasource
168169
users.NewDataSourceList,
169170
invitations.NewDataSourceList,
170171
invitations.NewDataSourceGet,
172+
teams.NewDataSourceList,
173+
teams.NewDataSourceGet,
171174
}
172175
}
173176

@@ -178,6 +181,7 @@ func (p *singlestoreProvider) Resources(_ context.Context) []func() resource.Res
178181
workspaces.NewResource,
179182
privateconnections.NewResource,
180183
users.NewResource,
184+
teams.NewResource,
181185
}
182186
}
183187

0 commit comments

Comments
 (0)