Files
threshold/api/hosts/host_set.go
T
Jeff Mitchell f36f25a23b Add json_name fields to proto for complex names (#27)
This was generating fine before but it makes it explicit in the proto
and it avoids weirdness where the protobuf tag will say a name is
something like requestId where the json tag says it's request_id. This
way they line up.

One thing not honoring this properly is TraceId. I don't know why the
JSON tag being generated doesn't match even when explicitly set here.
For now I'm just manually fixing it.
2020-05-05 14:08:13 -04:00

64 lines
1.7 KiB
Go

// Code generated by "make api"; DO NOT EDIT.
package hosts
import (
"encoding/json"
"time"
"github.com/fatih/structs"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/internal/strutil"
)
type HostSet struct {
Client *api.Client `json:"-"`
defaultFields []string
// The ID of the host
// Output only.
Id string `json:"id,omitempty"`
// The type of the resource, to help differentiate schemas
Type *string `json:"type,omitempty"`
// Optional name for identification purposes
Name *string `json:"name,omitempty"`
// Optional user-set description for identification purposes
Description *string `json:"description,omitempty"`
// The time this resource was created
// Output only.
CreatedTime time.Time `json:"created_time,omitempty"`
// The time this resource was last updated
// Output only.
UpdatedTime time.Time `json:"updated_time,omitempty"`
// Whether the host set is disabled
Disabled *bool `json:"disabled,omitempty"`
// The total count of hosts in this host set
// Output only.
Size *int64 `json:"size,omitempty"`
// A list of hosts in this host set
// TODO: Figure out if this should be in the basic HostSet view and what
// view to use on the Hosts.
// Output only.
Hosts []*Host `json:"hosts,omitempty"`
}
func (s *HostSet) SetDefault(key string) {
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, key)
}
func (s *HostSet) UnsetDefault(key string) {
s.defaultFields = strutil.StrListDelete(s.defaultFields, key)
}
func (s HostSet) MarshalJSON() ([]byte, error) {
m := structs.Map(s)
if m == nil {
m = make(map[string]interface{})
}
for _, k := range s.defaultFields {
m[k] = nil
}
return json.Marshal(m)
}