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/create.gen.go

166 lines
4.2 KiB

// Code generated by "make api"; DO NOT EDIT.
package scopes
import (
"context"
"fmt"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/groups"
"github.com/hashicorp/watchtower/api/hosts"
"github.com/hashicorp/watchtower/api/users"
)
func (s Organization) CreateProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// move on
} else {
// If it's explicitly set here, override anything that might be in the
// client
ctx = context.WithValue(ctx, "org", s.Id)
}
req, err := s.Client.NewRequest(ctx, "POST", "projects", r)
if err != nil {
return nil, nil, fmt.Errorf("error creating CreateProject request: %w", err)
}
resp, err := s.Client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during CreateProject call: %w", err)
}
target := new(Project)
apiErr, err := resp.Decode(target)
if err != nil {
return nil, nil, fmt.Errorf("error decoding CreateProject repsonse: %w", err)
}
target.Client = s.Client.Clone()
target.Client.SetProject(target.Id)
return target, apiErr, nil
}
func (s Organization) CreateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Creategroups.Group request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// move on
} else {
// If it's explicitly set here, override anything that might be in the
// client
ctx = context.WithValue(ctx, "org", s.Id)
}
req, err := s.Client.NewRequest(ctx, "POST", "groups", r)
if err != nil {
return nil, nil, fmt.Errorf("error creating Creategroups.Group request: %w", err)
}
resp, err := s.Client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Creategroups.Group call: %w", err)
}
target := new(groups.Group)
apiErr, err := resp.Decode(target)
if err != nil {
return nil, nil, fmt.Errorf("error decoding Creategroups.Group repsonse: %w", err)
}
target.Client = s.Client
return target, apiErr, nil
}
func (s Organization) CreateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Createusers.User request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// move on
} else {
// If it's explicitly set here, override anything that might be in the
// client
ctx = context.WithValue(ctx, "org", s.Id)
}
req, err := s.Client.NewRequest(ctx, "POST", "users", r)
if err != nil {
return nil, nil, fmt.Errorf("error creating Createusers.User request: %w", err)
}
resp, err := s.Client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Createusers.User call: %w", err)
}
target := new(users.User)
apiErr, err := resp.Decode(target)
if err != nil {
return nil, nil, fmt.Errorf("error decoding Createusers.User repsonse: %w", err)
}
target.Client = s.Client
return target, apiErr, nil
}
func (s Project) CreateHostCatalog(ctx context.Context, r *hosts.HostCatalog) (*hosts.HostCatalog, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Createhosts.HostCatalog request")
}
if s.Id == "" {
// Assume the client has been configured with project already and move
// on
} else {
// If it's explicitly set here, override anything that might be in the
// client
ctx = context.WithValue(ctx, "project", s.Id)
}
req, err := s.Client.NewRequest(ctx, "POST", "host-catalogs", r)
if err != nil {
return nil, nil, fmt.Errorf("error creating Createhosts.HostCatalog request: %w", err)
}
resp, err := s.Client.Do(req)
if err != nil {
return nil, nil, fmt.Errorf("error performing client request during Createhosts.HostCatalog call: %w", err)
}
target := new(hosts.HostCatalog)
apiErr, err := resp.Decode(target)
if err != nil {
return nil, nil, fmt.Errorf("error decoding Createhosts.HostCatalog repsonse: %w", err)
}
target.Client = s.Client
return target, apiErr, nil
}