73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
// Code generated by "make api"; DO NOT EDIT.
|
|
package hosts
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/fatih/structs"
|
|
|
|
"github.com/hashicorp/watchtower/api"
|
|
"github.com/hashicorp/watchtower/api/internal/strutil"
|
|
)
|
|
|
|
type Host 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 is disabled
|
|
Disabled *bool `json:"disabled,omitempty"`
|
|
// The address (DNS or IP name) used to reach the host
|
|
Address *string `json:"address,omitempty"`
|
|
}
|
|
|
|
func (s *Host) SetDefault(key string) {
|
|
lowerKey := strings.ToLower(key)
|
|
validMap := map[string]string{"address": "address", "createdtime": "created_time", "description": "description", "disabled": "disabled", "id": "id", "name": "name", "type": "type", "updatedtime": "updated_time"}
|
|
for k, v := range validMap {
|
|
if k == lowerKey || v == lowerKey {
|
|
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, v)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s *Host) UnsetDefault(key string) {
|
|
lowerKey := strings.ToLower(key)
|
|
validMap := map[string]string{"address": "address", "createdtime": "created_time", "description": "description", "disabled": "disabled", "id": "id", "name": "name", "type": "type", "updatedtime": "updated_time"}
|
|
for k, v := range validMap {
|
|
if k == lowerKey || v == lowerKey {
|
|
s.defaultFields = strutil.StrListDelete(s.defaultFields, v)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s Host) 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)
|
|
}
|