Files
threshold/api/roles/role.gen.go
T
Todd KnightandJeff Mitchell 1ddc59f81e Adding principal custom methods to roles handler. (#180)
* Adding Add/Set/Remove principals API calls.

* Add SDK custom methods.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-10 11:21:11 -07:00

66 lines
1.7 KiB
Go

// Code generated by "make api"; DO NOT EDIT.
package roles
import (
"encoding/json"
"time"
"github.com/fatih/structs"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/internal/strutil"
)
type Role struct {
Client *api.Client `json:"-"`
defaultFields []string
// The ID of the Role
// Output only.
Id string `json:"id,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 resource is disabled
Disabled *bool `json:"disabled,omitempty"`
// The version can be used in subsiquent write requests to ensure this resource
// has not changed and to fail the write if it has.
// Output only.
Version *uint32 `json:"version,omitempty"`
// The principals that are assigned this role.
// Output only.
UserIds []string `json:"user_ids,omitempty"`
// Output only.
GroupIds []string `json:"group_ids,omitempty"`
// The grants that this role provides for it's principals.
// Output only.
Grants []string `json:"grants,omitempty"`
}
func (s *Role) SetDefault(key string) {
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, key)
}
func (s *Role) UnsetDefault(key string) {
s.defaultFields = strutil.StrListDelete(s.defaultFields, key)
}
func (s Role) 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)
}