mirror of https://github.com/hashicorp/boundary
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.
302 lines
7.4 KiB
302 lines
7.4 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/roles"
|
|
"github.com/hashicorp/watchtower/api/users"
|
|
)
|
|
|
|
func (s Organization) UpdateProject(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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "projects", id), 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 UpdateProject call: %w", err)
|
|
}
|
|
|
|
target := new(Project)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateProject repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client.Clone()
|
|
target.Client.SetProject(target.Id)
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Organization) UpdateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateGroup 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "groups", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateGroup request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateGroup call: %w", err)
|
|
}
|
|
|
|
target := new(groups.Group)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateGroup repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Organization) UpdateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateRole 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "roles", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateRole request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateRole call: %w", err)
|
|
}
|
|
|
|
target := new(roles.Role)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateRole repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Organization) UpdateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateUser 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "users", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateUser request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateUser call: %w", err)
|
|
}
|
|
|
|
target := new(users.User)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateUser repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Project) UpdateHostCatalog(ctx context.Context, r *hosts.HostCatalog) (*hosts.HostCatalog, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateHostCatalog 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "host-catalogs", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateHostCatalog request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateHostCatalog call: %w", err)
|
|
}
|
|
|
|
target := new(hosts.HostCatalog)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateHostCatalog repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Project) UpdateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateGroup 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "groups", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateGroup request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateGroup call: %w", err)
|
|
}
|
|
|
|
target := new(groups.Group)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateGroup repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|
|
|
|
func (s Project) UpdateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
|
|
if s.Client == nil {
|
|
return nil, nil, fmt.Errorf("nil client in CreateRole 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)
|
|
|
|
}
|
|
|
|
id := r.Id
|
|
r.Id = ""
|
|
|
|
req, err := s.Client.NewRequest(ctx, "PATCH", fmt.Sprintf("%s/%s", "roles", id), r)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error creating CreateRole request: %w", err)
|
|
}
|
|
|
|
resp, err := s.Client.Do(req)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error performing client request during UpdateRole call: %w", err)
|
|
}
|
|
|
|
target := new(roles.Role)
|
|
apiErr, err := resp.Decode(target)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error decoding UpdateRole repsonse: %w", err)
|
|
}
|
|
|
|
target.Client = s.Client
|
|
|
|
return target, apiErr, nil
|
|
}
|