mirror of
https://github.com/LukeHagar/developer.sailpoint.com.git
synced 2025-12-07 12:27:47 +00:00
1.5 KiB
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 |
|
Learn how to delete resources with the Golang SDK in this guide. | /tools/sdk/go/delete |
|
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.