Skip to content

Commit

Permalink
feat: workspace member resource and workspace member and workspace me…
Browse files Browse the repository at this point in the history
…mbers data source
  • Loading branch information
jianyuan committed Dec 8, 2024
1 parent 39b30f8 commit 78f8dd6
Show file tree
Hide file tree
Showing 28 changed files with 1,870 additions and 110 deletions.
6 changes: 6 additions & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ description: |-

Get a user in the Organization.

## Example Usage

```terraform
data "anthropic_user" "example" {
id = "user_xxxxx"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
32 changes: 32 additions & 0 deletions docs/data-sources/workspace_member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "anthropic_workspace_member Data Source - terraform-provider-anthropic"
subcategory: ""
description: |-
Get a member of a Workspace.
---

# anthropic_workspace_member (Data Source)

Get a member of a Workspace.

## Example Usage

```terraform
data "anthropic_workspace_member" "example" {
workspace_id = "wrkspc_xxxxx"
user_id = "user_xxxxx"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `user_id` (String) ID of the user who is a member of the Workspace.
- `workspace_id` (String) ID of the Workspace to which the member belongs.

### Read-Only

- `workspace_role` (String) Role of the new Workspace Member. Must be one of `workspace_user`, `workspace_developer`, or `workspace_admin`.
39 changes: 39 additions & 0 deletions docs/data-sources/workspace_members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "anthropic_workspace_members Data Source - terraform-provider-anthropic"
subcategory: ""
description: |-
List all members of the workspace.
---

# anthropic_workspace_members (Data Source)

List all members of the workspace.

## Example Usage

```terraform
data "anthropic_workspace_members" "example" {
id = "wrkspc_xxxxx"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) ID of the Workspace.

### Read-Only

- `members` (Attributes Set) List of members. (see [below for nested schema](#nestedatt--members))

<a id="nestedatt--members"></a>
### Nested Schema for `members`

Read-Only:

- `user_id` (String) ID of the user who is a member of the Workspace.
- `workspace_id` (String) ID of the Workspace to which the member belongs.
- `workspace_role` (String) Role of the new Workspace Member. Must be one of `workspace_user`, `workspace_developer`, or `workspace_admin`.
5 changes: 1 addition & 4 deletions docs/data-sources/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ List all workspaces in the organization.
<a id="nestedatt--workspaces"></a>
### Nested Schema for `workspaces`

Required:

- `id` (String) ID of the Workspace.

Read-Only:

- `archived_at` (String) RFC 3339 datetime string indicating when the Workspace was archived, or null if the Workspace is not archived.
- `created_at` (String) RFC 3339 datetime string indicating when the Workspace was created.
- `display_color` (String) Hex color code representing the Workspace in the Anthropic Console.
- `id` (String) ID of the Workspace.
- `name` (String) Name of the Workspace.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ description: |-
provider "anthropic" {
api_key = "sk-ant-adminxx-xxxxx-xxxxx-xxxxx-xxxxx"
}
# Create a new workspace
resource "anthropic_workspace" "example" {
name = "Workspace Name"
}
# Retrieve a user by ID
data "anthropic_user" "example" {
id = "user_xxxxx"
}
# Add a user to the workspace
resource "anthropic_workspace_member" "example" {
workspace_id = anthropic_workspace.example.id
user_id = data.anthropic_user.example.id
workspace_role = "workspace_developer"
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
6 changes: 6 additions & 0 deletions docs/resources/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ description: |-

Workspace resource.

## Example Usage

```terraform
resource "anthropic_workspace" "example" {
name = "Workspace Name"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
51 changes: 51 additions & 0 deletions docs/resources/workspace_member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "anthropic_workspace_member Resource - terraform-provider-anthropic"
subcategory: ""
description: |-
Workspace member resource.
---

# anthropic_workspace_member (Resource)

Workspace member resource.

## Example Usage

```terraform
resource "anthropic_workspace" "example" {
name = "Workspace Name"
}
data "anthropic_user" "example" {
id = "user_xxxxx"
}
# Create a workspace member
resource "anthropic_workspace_member" "example" {
workspace_id = anthropic_workspace.example.id
user_id = data.anthropic_user.example.id
workspace_role = "workspace_developer"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `user_id` (String) ID of the user who is a member of the Workspace.
- `workspace_id` (String) ID of the Workspace to which the member belongs.
- `workspace_role` (String) Role of the new Workspace Member. Must be one of `workspace_user`, `workspace_developer`, or `workspace_admin`.

## Import

Import is supported using the following syntax:

```shell
# Import an existing workspace member
terraform import anthropic_workspace_member.example workspace_id/user_id

# Example
terraform import anthropic_workspace_member.example wrkspc_xxxxx/user_xxxxx
```
3 changes: 3 additions & 0 deletions examples/data-sources/anthropic_user/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "anthropic_user" "example" {
id = "user_xxxxx"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "anthropic_workspace_member" "example" {
workspace_id = "wrkspc_xxxxx"
user_id = "user_xxxxx"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "anthropic_workspace_members" "example" {
id = "wrkspc_xxxxx"
}
17 changes: 17 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
provider "anthropic" {
api_key = "sk-ant-adminxx-xxxxx-xxxxx-xxxxx-xxxxx"
}

# Create a new workspace
resource "anthropic_workspace" "example" {
name = "Workspace Name"
}

# Retrieve a user by ID
data "anthropic_user" "example" {
id = "user_xxxxx"
}

# Add a user to the workspace
resource "anthropic_workspace_member" "example" {
workspace_id = anthropic_workspace.example.id
user_id = data.anthropic_user.example.id
workspace_role = "workspace_developer"
}
5 changes: 5 additions & 0 deletions examples/resources/anthropic_workspace_member/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Import an existing workspace member
terraform import anthropic_workspace_member.example workspace_id/user_id

# Example
terraform import anthropic_workspace_member.example wrkspc_xxxxx/user_xxxxx
14 changes: 14 additions & 0 deletions examples/resources/anthropic_workspace_member/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "anthropic_workspace" "example" {
name = "Workspace Name"
}

data "anthropic_user" "example" {
id = "user_xxxxx"
}

# Create a workspace member
resource "anthropic_workspace_member" "example" {
workspace_id = anthropic_workspace.example.id
user_id = data.anthropic_user.example.id
workspace_role = "workspace_developer"
}
12 changes: 4 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ go 1.23.4

require (
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/terraform-plugin-docs v0.20.1
github.com/hashicorp/terraform-plugin-framework v1.13.0
github.com/hashicorp/terraform-plugin-framework-validators v0.15.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hashicorp/terraform-plugin-testing v1.11.0
github.com/jianyuan/go-utils v0.0.0-20241124212807-9e88ec4ee96c
github.com/oapi-codegen/oapi-codegen/v2 v2.4.1
github.com/oapi-codegen/runtime v1.1.1
)

Expand All @@ -30,7 +34,6 @@ require (
github.com/getkin/kin-openapi v0.127.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-test/deep v1.0.8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -49,17 +52,14 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-docs v0.20.1 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/invopop/yaml v0.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -70,15 +70,12 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oapi-codegen/oapi-codegen/v2 v2.4.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/speakeasy-api/openapi-overlay v0.9.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand All @@ -99,7 +96,6 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 78f8dd6

Please sign in to comment.