diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-17 17:22:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 17:22:37 +0000 |
commit | a17afa931d1aa73b8657cf26de3b49841837f66d (patch) | |
tree | 8b3e3408eea4fa15320f5c294d96b8e134bf49c4 /pkg/bindings/system/types_events_options.go | |
parent | 033336606f8aa9687cbdff5450c691b48d45e8e6 (diff) | |
parent | 86335aa4ae01dadecd36468409d742e68b76925d (diff) | |
download | podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.gz podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.bz2 podman-a17afa931d1aa73b8657cf26de3b49841837f66d.zip |
Merge pull request #8752 from baude/bindings3volumes
misc bindings to podman v3
Diffstat (limited to 'pkg/bindings/system/types_events_options.go')
-rw-r--r-- | pkg/bindings/system/types_events_options.go | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/pkg/bindings/system/types_events_options.go b/pkg/bindings/system/types_events_options.go new file mode 100644 index 000000000..cb4c5eb0e --- /dev/null +++ b/pkg/bindings/system/types_events_options.go @@ -0,0 +1,152 @@ +package system + +import ( + "net/url" + "reflect" + "strconv" + + jsoniter "github.com/json-iterator/go" + "github.com/pkg/errors" +) + +/* +This file is generated automatically by go generate. Do not edit. + +Created 2020-12-17 09:13:10.308724359 -0600 CST m=+0.000145204 +*/ + +// Changed +func (o *EventsOptions) Changed(fieldName string) bool { + r := reflect.ValueOf(o) + value := reflect.Indirect(r).FieldByName(fieldName) + return !value.IsNil() +} + +// ToParams +func (o *EventsOptions) ToParams() (url.Values, error) { + params := url.Values{} + if o == nil { + return params, nil + } + json := jsoniter.ConfigCompatibleWithStandardLibrary + s := reflect.ValueOf(o) + if reflect.Ptr == s.Kind() { + s = s.Elem() + } + sType := s.Type() + for i := 0; i < s.NumField(); i++ { + fieldName := sType.Field(i).Name + if !o.Changed(fieldName) { + continue + } + f := s.Field(i) + if reflect.Ptr == f.Kind() { + f = f.Elem() + } + switch f.Kind() { + case reflect.Bool: + params.Set(fieldName, strconv.FormatBool(f.Bool())) + case reflect.String: + params.Set(fieldName, f.String()) + case reflect.Int, reflect.Int64: + // f.Int() is always an int64 + params.Set(fieldName, strconv.FormatInt(f.Int(), 10)) + case reflect.Uint, reflect.Uint64: + // f.Uint() is always an uint64 + params.Set(fieldName, strconv.FormatUint(f.Uint(), 10)) + case reflect.Slice: + typ := reflect.TypeOf(f.Interface()).Elem() + slice := reflect.MakeSlice(reflect.SliceOf(typ), f.Len(), f.Cap()) + switch typ.Kind() { + case reflect.String: + s, ok := slice.Interface().([]string) + if !ok { + return nil, errors.New("failed to convert to string slice") + } + for _, val := range s { + params.Add(fieldName, val) + } + default: + return nil, errors.Errorf("unknown slice type %s", f.Kind().String()) + } + case reflect.Map: + lowerCaseKeys := make(map[string][]string) + iter := f.MapRange() + for iter.Next() { + lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) + + } + s, err := json.MarshalToString(lowerCaseKeys) + if err != nil { + return nil, err + } + + params.Set(fieldName, s) + } + } + return params, nil +} + +// WithFilters +func (o *EventsOptions) WithFilters(value map[string][]string) *EventsOptions { + v := value + o.Filters = v + return o +} + +// GetFilters +func (o *EventsOptions) GetFilters() map[string][]string { + var filters map[string][]string + if o.Filters == nil { + return filters + } + return o.Filters +} + +// WithSince +func (o *EventsOptions) WithSince(value string) *EventsOptions { + v := &value + o.Since = v + return o +} + +// GetSince +func (o *EventsOptions) GetSince() string { + var since string + if o.Since == nil { + return since + } + return *o.Since +} + +// WithStream +func (o *EventsOptions) WithStream(value bool) *EventsOptions { + v := &value + o.Stream = v + return o +} + +// GetStream +func (o *EventsOptions) GetStream() bool { + var stream bool + if o.Stream == nil { + return stream + } + return *o.Stream +} + +// WithUntil +func (o *EventsOptions) WithUntil(value string) *EventsOptions { + v := &value + o.Until = v + return o +} + +// GetUntil +func (o *EventsOptions) GetUntil() string { + var until string + if o.Until == nil { + return until + } + return *o.Until +} |