// Code generated by "make api"; DO NOT EDIT. package scopes import ( "context" "fmt" "github.com/hashicorp/watchtower/api" ) func (s Scope) UpdateScope(ctx context.Context, r *Scope) (*Scope, *api.Error, error) { if r == nil { } if r.Id == "" { return nil, nil, fmt.Errorf("empty Scope ID field in CreateScope request") } if s.Client == nil { return nil, nil, fmt.Errorf("nil client in CreateScope 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)) } id := r.Id r.Id = "" req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "scopes", id), r, opts...) if err != nil { return nil, nil, fmt.Errorf("error creating CreateScope request: %w", err) } resp, err := s.Client.Do(req) if err != nil { return nil, nil, fmt.Errorf("error performing client request during UpdateScope call: %w", err) } target := new(Scope) apiErr, err := resp.Decode(target) if err != nil { return nil, nil, fmt.Errorf("error decoding UpdateScope repsonse: %w", err) } target.Client = s.Client.Clone() target.Client.SetScopeId(target.Id) return target, apiErr, nil }