Skip to content

Commit

Permalink
Merge branch 'feat/v4-directory-services' into feat/v4-saml-idp
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimutant committed Mar 20, 2024
2 parents 37dcb74 + 037911c commit cea90c9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nutanix/services/v2/iam/resource_nutanix_directory_services_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/iam-go-client/v16/models/iam/v4/authn"
errResp "github.com/nutanix-core/ntnx-api-golang-sdk-internal/iam-go-client/v16/models/iam/v4/error"

conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix"
"github.com/terraform-providers/terraform-provider-nutanix/utils"
Expand Down Expand Up @@ -308,6 +309,26 @@ func ResourceNutanixDirectoryServicesV4Update(ctx context.Context, d *schema.Res
}

func ResourceNutanixDirectoryServicesV4Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.Client).IamAPI

resp, err := conn.DirectoryServiceAPIInstance.DeleteDirectoryServiceById(utils.StringPtr(d.Id()))
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
if e != nil {
return diag.FromErr(e)
}
data := errordata["data"].(map[string]interface{})
errorList := data["error"].([]interface{})
errorMessage := errorList[0].(map[string]interface{})
return diag.Errorf("error while deleting directory services : %v", errorMessage["message"])
}

getResp := resp.Data.GetValue().(errResp.ErrorResponse)

if getResp.Error != nil {
fmt.Println("Directory Services deleted successfully.")
}
return nil
}

Expand Down

0 comments on commit cea90c9

Please sign in to comment.