From c2d70b9ebe8528c008b7dc001bcc482ebbbef661 Mon Sep 17 00:00:00 2001 From: dgomez04 Date: Thu, 24 Oct 2024 16:33:39 -0600 Subject: [PATCH] deleted sdkv2 'data_users' and removed it from sdkv2.go --- internal/providers/sdkv2/sdkv2.go | 1 - scim/data_users.go | 72 ------------------------------- 2 files changed, 73 deletions(-) delete mode 100755 scim/data_users.go diff --git a/internal/providers/sdkv2/sdkv2.go b/internal/providers/sdkv2/sdkv2.go index 40ba5d3d1a..8136901ddf 100644 --- a/internal/providers/sdkv2/sdkv2.go +++ b/internal/providers/sdkv2/sdkv2.go @@ -125,7 +125,6 @@ func DatabricksProvider() *schema.Provider { "databricks_volume": catalog.DataSourceVolume().ToResource(), "databricks_volumes": catalog.DataSourceVolumes().ToResource(), "databricks_user": scim.DataSourceUser().ToResource(), - "databricks_users": scim.DataSourceUsers().ToResource(), "databricks_zones": clusters.DataSourceClusterZones().ToResource(), }, ResourcesMap: map[string]*schema.Resource{ // must be in alphabetical order diff --git a/scim/data_users.go b/scim/data_users.go deleted file mode 100755 index b3fcd03782..0000000000 --- a/scim/data_users.go +++ /dev/null @@ -1,72 +0,0 @@ -package scim - -import ( - "context" - "fmt" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/terraform-provider-databricks/common" -) - -func DataSourceUsers() common.Resource { - - type UserInfo struct { - Id string `json:"id,omitempty" tf:"computed"` - UserName string `json:"user_name,omitempty" tf:"computed"` - DisplayName string `json:"display_name,omitempty" tf:"computed"` - } - - type DataUsers struct { - DisplayNameContains string `json:"display_name_contains,omitempty" tf:"computed"` - UserNameContains string `json:"user_name_contains,omitempty" tf:"computed"` - Users []UserInfo `json:"users,omitempty" tf:"computed"` - } - - return common.AccountData(func(ctx context.Context, data *DataUsers, acc *databricks.AccountClient) error { - listRequest := iam.ListAccountUsersRequest{ - Attributes: "id,userName,displayName", - } - - if data.DisplayNameContains != "" && data.UserNameContains != "" { - return fmt.Errorf("exactly one of display_name_contains or user_name_contains should be specified, not both") - } - - if data.UserNameContains != "" { - listRequest.Filter = fmt.Sprintf("userName co \"%s\"", data.UserNameContains) - } else if data.DisplayNameContains != "" { - listRequest.Filter = fmt.Sprintf("displayName co \"%s\"", data.DisplayNameContains) - } - - userList, err := acc.Users.ListAll(ctx, listRequest) - - if err != nil { - return err - } - - if len(userList) == 0 { - if data.DisplayNameContains != "" { - return fmt.Errorf("cannot find users with display name containing %s", data.DisplayNameContains) - } else if data.UserNameContains != "" { - return fmt.Errorf("cannot find users with username containing %s", data.UserNameContains) - } else { - return fmt.Errorf("no users found") - } - } - - var users []UserInfo - - for _, u := range userList { - user := UserInfo{ - Id: u.Id, - UserName: u.UserName, - DisplayName: u.DisplayName, - } - users = append(users, user) - } - - data.Users = users - - return nil - }) -}