Skip to content

Commit

Permalink
Merge pull request #11 from cheelim1/feat/add-user-displayname
Browse files Browse the repository at this point in the history
Add display name for jumpcloud user
  • Loading branch information
cheelim1 authored Apr 16, 2024
2 parents 2f6791c + c543428 commit b49daed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ Provides a JumpCloud system user resource. For additional information refer also

```terraform
resource "jumpcloud_user" "john_doe" {
username = "john.doe"
email = "[email protected]"
firstname = "John Smith"
lastname = "Doe"
enable_mfa = true
username = "john.doe"
email = "[email protected]"
firstname = "John"
lastname = "Doe"
display_name = "John Doe"
enable_mfa = true
}
output "userid" {
Expand All @@ -39,6 +40,7 @@ output "userid" {
- `enable_mfa` (Boolean) Require Multi-factor Authentication on the User Portal.
- `firstname` (String) The user's first name. Example: `john`.
- `lastname` (String) The user's last name. Example: `doe`.
- `display_name` (String) The user's display name. Example: `john doe`.
- `ldap_binding_user` (Boolean)
- `password` (String)
- `password_never_expires` (Boolean)
Expand Down
10 changes: 10 additions & 0 deletions jumpcloud/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

jcapiv1 "github.com/TheJumpCloud/jcapi-go/v1"
Expand Down Expand Up @@ -34,6 +35,10 @@ func resourceUser() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"display_name": {
Type: schema.TypeString,
Optional: true,
},
"password": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -119,6 +124,7 @@ func resourceUserCreate(d *schema.ResourceData, m interface{}) error {
Email: d.Get("email").(string),
Firstname: d.Get("firstname").(string),
Lastname: d.Get("lastname").(string),
Displayname: d.Get("display_name").(string),
Password: d.Get("password").(string),
EnableUserPortalMultifactor: d.Get("enable_mfa").(bool),
LdapBindingUser: d.Get("ldap_binding_user").(bool),
Expand Down Expand Up @@ -170,6 +176,9 @@ func resourceUserRead(d *schema.ResourceData, m interface{}) error {
if err := d.Set("lastname", res.Lastname); err != nil {
return err
}
if err := d.Set("display_name", res.Displayname); err != nil {
return err
}
if err := d.Set("enable_mfa", res.EnableUserPortalMultifactor); err != nil {
return err
}
Expand Down Expand Up @@ -209,6 +218,7 @@ func resourceUserUpdate(d *schema.ResourceData, m interface{}) error {
Email: d.Get("email").(string),
Firstname: d.Get("firstname").(string),
Lastname: d.Get("lastname").(string),
Displayname: d.Get("display_name").(string),
Password: d.Get("password").(string),
EnableUserPortalMultifactor: d.Get("enable_mfa").(bool),
LdapBindingUser: d.Get("ldap_binding_user").(bool),
Expand Down

0 comments on commit b49daed

Please sign in to comment.