Files
threshold/api/error_details.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

38 lines
831 B
Go

// Code generated by "make api"; DO NOT EDIT.
package api
import (
"encoding/json"
"github.com/fatih/structs"
"github.com/hashicorp/watchtower/api/internal/strutil"
)
type ErrorDetails struct {
defaultFields []string
TraceId *string `json:"TraceId,omitempty"`
RequestId *string `json:"request_id,omitempty"`
RequestFields []string `json:"request_fields,omitempty"`
}
func (s *ErrorDetails) SetDefault(key string) {
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, key)
}
func (s *ErrorDetails) UnsetDefault(key string) {
s.defaultFields = strutil.StrListDelete(s.defaultFields, key)
}
func (s ErrorDetails) 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)
}