// Code generated by "make api"; DO NOT EDIT. package hosts import ( "context" "fmt" "github.com/hashicorp/watchtower/api" ) func (s HostCatalog) CreateHost(ctx context.Context, r *Host) (*Host, *api.Error, error) { if s.Client == nil { return nil, nil, fmt.Errorf("nil client in CreateHost 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, "POST", fmt.Sprintf("host-catalogs/%s/hosts", s.Id), r, opts...) if err != nil { return nil, nil, fmt.Errorf("error creating CreateHost request: %w", err) } resp, err := s.Client.Do(req) if err != nil { return nil, nil, fmt.Errorf("error performing client request during CreateHost call: %w", err) } target := new(Host) apiErr, err := resp.Decode(target) if err != nil { return nil, nil, fmt.Errorf("error decoding CreateHost repsonse: %w", err) } target.Client = s.Client return target, apiErr, nil } func (s HostCatalog) CreateHostSet(ctx context.Context, r *HostSet) (*HostSet, *api.Error, error) { if s.Client == nil { return nil, nil, fmt.Errorf("nil client in CreateHostSet 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, "POST", fmt.Sprintf("host-catalogs/%s/host-sets", s.Id), r, opts...) if err != nil { return nil, nil, fmt.Errorf("error creating CreateHostSet request: %w", err) } resp, err := s.Client.Do(req) if err != nil { return nil, nil, fmt.Errorf("error performing client request during CreateHostSet call: %w", err) } target := new(HostSet) apiErr, err := resp.Decode(target) if err != nil { return nil, nil, fmt.Errorf("error decoding CreateHostSet repsonse: %w", err) } target.Client = s.Client return target, apiErr, nil }