Skip to content

Commit

Permalink
Add user resource and data source
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Jan 9, 2024
1 parent 8378990 commit c09a655
Show file tree
Hide file tree
Showing 17 changed files with 851 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- BREAKING CHANGE: Rename `catalystcenter_device_claim_site` resource and data source to `catalystcenter_pnp_device_claim_site`
- Add `catalystcenter_device` resource
- Add `catalystcenter_role` resource and data source
- Add `catalystcenter_user` resource and data source

## 0.1.2

Expand Down
35 changes: 35 additions & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_user Data Source - terraform-provider-catalystcenter"
subcategory: "System"
description: |-
This data source can read the User.
---

# catalystcenter_user (Data Source)

This data source can read the User.

## Example Usage

```terraform
data "catalystcenter_user" "example" {
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
}
```

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

### Required

- `id` (String) The id of the object

### Read-Only

- `email` (String) Email address
- `first_name` (String) The first name
- `last_name` (String) The last name
- `password` (String) The password
- `role_ids` (List of String) List of role IDs
- `username` (String) The username
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description: |-
- BREAKING CHANGE: Rename `catalystcenter_device_claim_site` resource and data source to `catalystcenter_pnp_device_claim_site`
- Add `catalystcenter_device` resource
- Add `catalystcenter_role` resource and data source
- Add `catalystcenter_user` resource and data source

## 0.1.2

Expand Down
51 changes: 51 additions & 0 deletions docs/resources/user.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: "catalystcenter_user Resource - terraform-provider-catalystcenter"
subcategory: "System"
description: |-
This resource can manage an User.
---

# catalystcenter_user (Resource)

This resource can manage an User.

## Example Usage

```terraform
resource "catalystcenter_user" "example" {
first_name = "john"
last_name = "doe"
username = "johndoe"
password = "Cisco123"
email = "[email protected]"
role_ids = ["5f8d9a3a-3c6a-4a1c-9a1b-1a4f5a4a4a4a"]
}
```

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

### Required

- `password` (String) The password
- `role_ids` (List of String) List of role IDs
- `username` (String) The username

### Optional

- `email` (String) Email address
- `first_name` (String) The first name
- `last_name` (String) The last name

### Read-Only

- `id` (String) The id of the object

## Import

Import is supported using the following syntax:

```shell
terraform import catalystcenter_user.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"
```
3 changes: 3 additions & 0 deletions examples/data-sources/catalystcenter_user/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "catalystcenter_user" "example" {
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
}
1 change: 1 addition & 0 deletions examples/resources/catalystcenter_user/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import catalystcenter_user.example "4b0b7a80-44c0-4bf2-bab5-fc24b4e0a17e"
8 changes: 8 additions & 0 deletions examples/resources/catalystcenter_user/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "catalystcenter_user" "example" {
first_name = "john"
last_name = "doe"
username = "johndoe"
password = "Cisco123"
email = "[email protected]"
role_ids = ["5f8d9a3a-3c6a-4a1c-9a1b-1a4f5a4a4a4a"]
}
46 changes: 46 additions & 0 deletions gen/definitions/user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: User
rest_endpoint: /dna/system/api/v1/user
put_no_id: true
put_id_include_path: userId
id_path: response.userId
id_from_query_path: response.users
id_from_query_path_attribute: userId
get_from_all: true
doc_category: System
attributes:
- model_name: firstName
type: String
description: The first name
example: john
- model_name: lastName
type: String
description: The last name
example: doe
- model_name: username
type: String
mandatory: true
description: The username
example: johndoe
- model_name: password
type: String
mandatory: true
write_only: true
description: The password
example: Cisco123
- model_name: email
type: String
description: Email address
example: [email protected]
- model_name: roleList
tf_name: role_ids
type: StringList
mandatory: true
description: List of role IDs
example: 5f8d9a3a-3c6a-4a1c-9a1b-1a4f5a4a4a4a
test_value: "[data.catalystcenter_role.test.id]"

test_prerequisites: |
data "catalystcenter_role" "test" {
name = "OBSERVER-ROLE"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
github.com/netascode/go-catalystcenter v0.1.1
github.com/netascode/go-catalystcenter v0.1.3
github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5
golang.org/x/tools v0.16.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/netascode/go-catalystcenter v0.1.1 h1:uM1oHQPPzgNQkpF2BPKrCE9WIjx5ignpGwezGae4NtE=
github.com/netascode/go-catalystcenter v0.1.1/go.mod h1:TbQE/MnDhCaFsj0mIjzQDN+6g810pP4PERbxaJOFs0E=
github.com/netascode/go-catalystcenter v0.1.3 h1:XLpQJoOKzU4PpePTb/8wvelqdIc5SlmYtkgre4SmY2I=
github.com/netascode/go-catalystcenter v0.1.3/go.mod h1:TbQE/MnDhCaFsj0mIjzQDN+6g810pP4PERbxaJOFs0E=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
Expand Down
134 changes: 134 additions & 0 deletions internal/provider/data_source_catalystcenter_user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c09a655

Please sign in to comment.