Skip to content

Commit

Permalink
Initial tests and updates based on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolack committed Sep 14, 2020
1 parent de0ff28 commit b62ce28
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 35 deletions.
3 changes: 3 additions & 0 deletions examples/system-groups/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "jumpcloud" {
api_key = "MY_API_KEY"
}
3 changes: 3 additions & 0 deletions examples/system-groups/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "jumpcloud_system_group" "test_group" {
name = "Jumpcloud Provider Group"
}
33 changes: 0 additions & 33 deletions jumpcloud/resource_system_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ func resourceGroupsSystem() *schema.Resource {
Update: resourceGroupsSystemUpdate,
Delete: resourceGroupsSystemDelete,
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -51,26 +47,6 @@ func resourceGroupsSystemCreate(d *schema.ResourceData, m interface{}) error {
return resourceGroupsSystemRead(d, m)
}

// Helper to look up a system group by name
func resourceGroupsSystemList_match(d *schema.ResourceData, m interface{}) (jcapiv2.SystemGroup, error) {
config := m.(*jcapiv2.Configuration)
client := jcapiv2.NewAPIClient(config)

filter := "[name:eq:" + d.Get("name").(string) + "]"

req := map[string]interface{}{
"filter": filter,
}

result, _, err := client.SystemGroupsApi.GroupsSystemList(context.TODO(),
"", headerAccept, req)
if err == nil {
return result[0], nil
} else {
return jcapiv2.SystemGroup{}, err
}
}

func resourceGroupsSystemRead(d *schema.ResourceData, m interface{}) error {
config := m.(*jcapiv2.Configuration)
client := jcapiv2.NewAPIClient(config)
Expand All @@ -79,15 +55,6 @@ func resourceGroupsSystemRead(d *schema.ResourceData, m interface{}) error {

id = d.Id()

if d.Id() != "" {
id_lookup, err := resourceGroupsSystemList_match(d, m)
if err != nil {
return fmt.Errorf("unable to locate ID for group %s",
d.Get("name"))
}
d.SetId(id_lookup.Id)
}

group, res, err := client.SystemGroupsApi.GroupsSystemGet(context.TODO(),
id, "", headerAccept, nil)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions jumpcloud/resource_user_group_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func resourceUserGroupMembership() *schema.Resource {
},
},
Importer: &schema.ResourceImporter{
State: userGroupMembershipImporter,
schema.ImportStatePassthrough,
},
}
}
Expand All @@ -55,7 +55,7 @@ func modifyUserGroupMembership(client *jcapiv2.APIClient,
}

req := map[string]interface{}{
"body": payload,
"body": payload,
}

_, err := client.UserGroupMembersMembershipApi.GraphUserGroupMembersPost(
Expand Down

0 comments on commit b62ce28

Please sign in to comment.