// Code generated by "make api"; DO NOT EDIT. package groups import ( "context" "fmt" "github.com/hashicorp/watchtower/api" ) // DeleteGroup returns true iff the Group existed when the delete attempt was made. func (s Group) DeleteGroup(ctx context.Context, id string) (bool, *api.Error, error) { if id == "" { return false, nil, fmt.Errorf("empty id provided to DeleteGroup request") } if s.Client == nil { return false, nil, fmt.Errorf("nil client in DeleteGroup request") } var opts []api.Option if s.Scope.Id != "" { // If it's explicitly set here, override anything that might be in the // client opts = append(opts, api.WithScopeId(s.Scope.Id)) } req, err := s.Client.NewRequest(ctx, "DELETE", fmt.Sprintf("%s/%s", "groups", id), nil, opts...) if err != nil { return false, nil, fmt.Errorf("error creating DeleteGroup request: %w", err) } resp, err := s.Client.Do(req) if err != nil { return false, nil, fmt.Errorf("error performing client request during DeleteGroup call: %w", err) } type deleteResponse struct { Existed bool } target := &deleteResponse{} apiErr, err := resp.Decode(target) if err != nil { return false, nil, fmt.Errorf("error decoding DeleteGroup repsonse: %w", err) } return target.Existed, apiErr, nil }