Files
developer.sailpoint.com/docs/tools/sdk/go/deleting-resources.md
darrell-thobe-sp 2cd5ccfc81 Prettified Code!
2024-04-18 10:31:05 +00:00

1.5 KiB

id, title, pagination_label, sidebar_label, sidebar_position, sidebar_class_name, keywords, description, slug, tags
id title pagination_label sidebar_label sidebar_position sidebar_class_name keywords description slug tags
go-sdk-delete Delete resources with the Go SDK Go SDK Delete a resource 4 gosdk
go
golang
sdk
delete
Learn how to delete resources with the Golang SDK in this guide. /tools/sdk/go/delete
SDK
Software Development Kit

Here is an example script that searches for the Workgroup created in Create a resource by name and calls the delete method to remove it from your environment.

package main

import (
 "context"
 "fmt"
 "os"

 sailpoint "github.com/sailpoint-oss/golang-sdk"
)

func main() {

 ctx := context.TODO()
 configuration := sailpoint.NewDefaultConfiguration()
 apiClient := sailpoint.NewAPIClient(configuration)

 workgroup, r, err := apiClient.Beta.GovernanceGroupsApi.ListWorkgroups(ctx).Filters(`name eq "DB Access Governance Group"`).Execute()

 if err != nil {
  fmt.Fprintf(os.Stderr, "Error when retrieving workgroup`: %v\n", err)
  fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
 }

 response, errorMessage := apiClient.Beta.GovernanceGroupsApi.DeleteWorkgroup(ctx, *workgroup[0].Id).Execute()

 if errorMessage != nil {
  fmt.Fprintf(os.Stderr, "Error when updating workgroup`: %v\n", errorMessage)
  fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", response)
 }

 fmt.Fprintf(os.Stdout, "Resource Deleted: %v\n", response.StatusCode)

}

To run the code, run this command:

go run sdk.go

The deletionStatus is returned by the SDK with a value of 204.