// 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") } if s.Id == "" { return nil, nil, fmt.Errorf("missing HostCatalog ID in CreateHost request") } else { // If it's explicitly set here, override anything that might be in the // client } req, err := s.Client.NewRequest(ctx, "POST", fmt.Sprintf("host-catalogs/%s/hosts", s.Id), r) 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") } if s.Id == "" { return nil, nil, fmt.Errorf("missing HostCatalog ID in CreateHostSet request") } else { // If it's explicitly set here, override anything that might be in the // client } req, err := s.Client.NewRequest(ctx, "POST", fmt.Sprintf("host-catalogs/%s/host-sets", s.Id), r) 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 }