You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/api/scopes/read.gen.go

48 lines
1.2 KiB

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