summaryrefslogtreecommitdiff
path: root/pkg/bindings/network
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings/network')
-rw-r--r--pkg/bindings/network/network.go80
-rw-r--r--pkg/bindings/network/types.go70
-rw-r--r--pkg/bindings/network/types_connect_options.go104
-rw-r--r--pkg/bindings/network/types_create_options.go265
-rw-r--r--pkg/bindings/network/types_disconnect_options.go104
-rw-r--r--pkg/bindings/network/types_inspect_options.go88
-rw-r--r--pkg/bindings/network/types_list_options.go104
-rw-r--r--pkg/bindings/network/types_remove_options.go104
8 files changed, 897 insertions, 22 deletions
diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go
index 347f97703..7cd251b0e 100644
--- a/pkg/bindings/network/network.go
+++ b/pkg/bindings/network/network.go
@@ -2,10 +2,8 @@ package network
import (
"context"
- "encoding/json"
"net/http"
"net/url"
- "strconv"
"strings"
"github.com/containers/podman/v2/pkg/bindings"
@@ -14,15 +12,18 @@ import (
)
// Create makes a new CNI network configuration
-func Create(ctx context.Context, options entities.NetworkCreateOptions, name *string) (*entities.NetworkCreateReport, error) {
+func Create(ctx context.Context, options *CreateOptions) (*entities.NetworkCreateReport, error) {
var report entities.NetworkCreateReport
+ if options == nil {
+ options = new(CreateOptions)
+ }
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
params := url.Values{}
- if name != nil {
- params.Set("name", *name)
+ if options.Name != nil {
+ params.Set("name", options.GetName())
}
networkConfig, err := jsoniter.MarshalToString(options)
if err != nil {
@@ -37,8 +38,12 @@ func Create(ctx context.Context, options entities.NetworkCreateOptions, name *st
}
// Inspect returns low level information about a CNI network configuration
-func Inspect(ctx context.Context, nameOrID string) ([]entities.NetworkInspectReport, error) {
+func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) ([]entities.NetworkInspectReport, error) {
var reports []entities.NetworkInspectReport
+ if options == nil {
+ options = new(InspectOptions)
+ }
+ _ = options
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
@@ -53,15 +58,18 @@ func Inspect(ctx context.Context, nameOrID string) ([]entities.NetworkInspectRep
// Remove deletes a defined CNI network configuration by name. The optional force boolean
// will remove all containers associated with the network when set to true. A slice
// of NetworkRemoveReports are returned.
-func Remove(ctx context.Context, nameOrID string, force *bool) ([]*entities.NetworkRmReport, error) {
+func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) ([]*entities.NetworkRmReport, error) {
var reports []*entities.NetworkRmReport
+ if options == nil {
+ options = new(RemoveOptions)
+ }
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
- params := url.Values{}
- if force != nil {
- params.Set("force", strconv.FormatBool(*force))
+ params, err := options.ToParams()
+ if err != nil {
+ return nil, err
}
response, err := conn.DoRequest(nil, http.MethodDelete, "/networks/%s", params, nil, nameOrID)
if err != nil {
@@ -71,21 +79,20 @@ func Remove(ctx context.Context, nameOrID string, force *bool) ([]*entities.Netw
}
// List returns a summary of all CNI network configurations
-func List(ctx context.Context, options entities.NetworkListOptions) ([]*entities.NetworkListReport, error) {
+func List(ctx context.Context, options *ListOptions) ([]*entities.NetworkListReport, error) {
var (
netList []*entities.NetworkListReport
)
+ if options == nil {
+ options = new(ListOptions)
+ }
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
- params := url.Values{}
- if options.Filters != nil {
- b, err := json.Marshal(options.Filters)
- if err != nil {
- return nil, err
- }
- params.Set("filters", string(b))
+ params, err := options.ToParams()
+ if err != nil {
+ return nil, err
}
response, err := conn.DoRequest(nil, http.MethodGet, "/networks/json", params, nil)
if err != nil {
@@ -95,13 +102,28 @@ func List(ctx context.Context, options entities.NetworkListOptions) ([]*entities
}
// Disconnect removes a container from a given network
-func Disconnect(ctx context.Context, networkName string, options entities.NetworkDisconnectOptions) error {
+func Disconnect(ctx context.Context, networkName string, ContainerNameOrId string, options *DisconnectOptions) error {
+ if options == nil {
+ options = new(DisconnectOptions)
+ }
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
}
+ // No params are used for disconnect
params := url.Values{}
- body, err := jsoniter.MarshalToString(options)
+ // Disconnect sends everything in body
+ disconnect := struct {
+ Container string
+ Force bool
+ }{
+ Container: ContainerNameOrId,
+ }
+ if force := options.GetForce(); options.Changed("Force") {
+ disconnect.Force = force
+ }
+
+ body, err := jsoniter.MarshalToString(disconnect)
if err != nil {
return err
}
@@ -114,13 +136,27 @@ func Disconnect(ctx context.Context, networkName string, options entities.Networ
}
// Connect adds a container to a network
-func Connect(ctx context.Context, networkName string, options entities.NetworkConnectOptions) error {
+func Connect(ctx context.Context, networkName string, ContainerNameOrId string, options *ConnectOptions) error {
+ if options == nil {
+ options = new(ConnectOptions)
+ }
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
}
+ // No params are used in connect
params := url.Values{}
- body, err := jsoniter.MarshalToString(options)
+ // Connect sends everything in body
+ connect := struct {
+ Container string
+ Aliases []string
+ }{
+ Container: ContainerNameOrId,
+ }
+ if aliases := options.GetAliases(); options.Changed("Aliases") {
+ connect.Aliases = aliases
+ }
+ body, err := jsoniter.MarshalToString(connect)
if err != nil {
return err
}
diff --git a/pkg/bindings/network/types.go b/pkg/bindings/network/types.go
new file mode 100644
index 000000000..2a7e500dd
--- /dev/null
+++ b/pkg/bindings/network/types.go
@@ -0,0 +1,70 @@
+package network
+
+import "net"
+
+//go:generate go run ../generator/generator.go CreateOptions
+// CreateOptions are optional options for creating networks
+type CreateOptions struct {
+ // DisableDNS turns off use of DNSMasq for name resolution
+ // on the network
+ DisableDNS *bool
+ // Driver is the name of network driver
+ Driver *string
+ // Gateway of the network
+ Gateway *net.IP
+ // Internal turns off communication outside the networking
+ // being created
+ Internal *bool
+ // Labels are metadata that can be associated with the network
+ Labels map[string]string
+ // MacVLAN is the name of the macvlan network to associate with
+ MacVLAN *string
+ // Range is the CIDR description of leasable IP addresses
+ IPRange *net.IPNet `scheme:"range"`
+ // Subnet to use
+ Subnet *net.IPNet
+ // IPv6 means the network is ipv6 capable
+ IPv6 *bool
+ // Options are a mapping of driver options and values.
+ Options map[string]string
+ // Name of the network
+ Name *string
+}
+
+//go:generate go run ../generator/generator.go InspectOptions
+// InspectOptions are optional options for inspecting networks
+type InspectOptions struct {
+}
+
+//go:generate go run ../generator/generator.go RemoveOptions
+// RemoveOptions are optional options for inspecting networks
+type RemoveOptions struct {
+ // Force removes the network even if it is being used
+ Force *bool
+}
+
+//go:generate go run ../generator/generator.go ListOptions
+// ListOptions are optional options for listing networks
+type ListOptions struct {
+ // Filters are applied to the list of networks to be more
+ // specific on the output
+ Filters map[string][]string
+}
+
+//go:generate go run ../generator/generator.go DisconnectOptions
+// DisconnectOptions are optional options for disconnecting
+// containers from a network
+type DisconnectOptions struct {
+ // Force indicates to remove the container from
+ // the network forcibly
+ Force *bool
+}
+
+//go:generate go run ../generator/generator.go ConnectOptions
+// ConnectOptions are optional options for connecting
+// containers from a network
+type ConnectOptions struct {
+ // Aliases are names the container will be known as
+ // when using the dns plugin
+ Aliases *[]string
+}
diff --git a/pkg/bindings/network/types_connect_options.go b/pkg/bindings/network/types_connect_options.go
new file mode 100644
index 000000000..22d1905e4
--- /dev/null
+++ b/pkg/bindings/network/types_connect_options.go
@@ -0,0 +1,104 @@
+package network
+
+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-16 11:59:06.213411549 -0600 CST m=+0.000201795
+*/
+
+// Changed
+func (o *ConnectOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *ConnectOptions) 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
+}
+
+// WithAliases
+func (o *ConnectOptions) WithAliases(value []string) *ConnectOptions {
+ v := &value
+ o.Aliases = v
+ return o
+}
+
+// GetAliases
+func (o *ConnectOptions) GetAliases() []string {
+ var aliases []string
+ if o.Aliases == nil {
+ return aliases
+ }
+ return *o.Aliases
+}
diff --git a/pkg/bindings/network/types_create_options.go b/pkg/bindings/network/types_create_options.go
new file mode 100644
index 000000000..6af7929c4
--- /dev/null
+++ b/pkg/bindings/network/types_create_options.go
@@ -0,0 +1,265 @@
+package network
+
+import (
+ "net"
+ "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-16 11:59:05.523424301 -0600 CST m=+0.000180953
+*/
+
+// Changed
+func (o *CreateOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *CreateOptions) 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
+}
+
+// WithDisableDNS
+func (o *CreateOptions) WithDisableDNS(value bool) *CreateOptions {
+ v := &value
+ o.DisableDNS = v
+ return o
+}
+
+// GetDisableDNS
+func (o *CreateOptions) GetDisableDNS() bool {
+ var disableDNS bool
+ if o.DisableDNS == nil {
+ return disableDNS
+ }
+ return *o.DisableDNS
+}
+
+// WithDriver
+func (o *CreateOptions) WithDriver(value string) *CreateOptions {
+ v := &value
+ o.Driver = v
+ return o
+}
+
+// GetDriver
+func (o *CreateOptions) GetDriver() string {
+ var driver string
+ if o.Driver == nil {
+ return driver
+ }
+ return *o.Driver
+}
+
+// WithGateway
+func (o *CreateOptions) WithGateway(value net.IP) *CreateOptions {
+ v := &value
+ o.Gateway = v
+ return o
+}
+
+// GetGateway
+func (o *CreateOptions) GetGateway() net.IP {
+ var gateway net.IP
+ if o.Gateway == nil {
+ return gateway
+ }
+ return *o.Gateway
+}
+
+// WithInternal
+func (o *CreateOptions) WithInternal(value bool) *CreateOptions {
+ v := &value
+ o.Internal = v
+ return o
+}
+
+// GetInternal
+func (o *CreateOptions) GetInternal() bool {
+ var internal bool
+ if o.Internal == nil {
+ return internal
+ }
+ return *o.Internal
+}
+
+// WithLabels
+func (o *CreateOptions) WithLabels(value map[string]string) *CreateOptions {
+ v := value
+ o.Labels = v
+ return o
+}
+
+// GetLabels
+func (o *CreateOptions) GetLabels() map[string]string {
+ var labels map[string]string
+ if o.Labels == nil {
+ return labels
+ }
+ return o.Labels
+}
+
+// WithMacVLAN
+func (o *CreateOptions) WithMacVLAN(value string) *CreateOptions {
+ v := &value
+ o.MacVLAN = v
+ return o
+}
+
+// GetMacVLAN
+func (o *CreateOptions) GetMacVLAN() string {
+ var macVLAN string
+ if o.MacVLAN == nil {
+ return macVLAN
+ }
+ return *o.MacVLAN
+}
+
+// WithIPRange
+func (o *CreateOptions) WithIPRange(value net.IPNet) *CreateOptions {
+ v := &value
+ o.IPRange = v
+ return o
+}
+
+// GetIPRange
+func (o *CreateOptions) GetIPRange() net.IPNet {
+ var iPRange net.IPNet
+ if o.IPRange == nil {
+ return iPRange
+ }
+ return *o.IPRange
+}
+
+// WithSubnet
+func (o *CreateOptions) WithSubnet(value net.IPNet) *CreateOptions {
+ v := &value
+ o.Subnet = v
+ return o
+}
+
+// GetSubnet
+func (o *CreateOptions) GetSubnet() net.IPNet {
+ var subnet net.IPNet
+ if o.Subnet == nil {
+ return subnet
+ }
+ return *o.Subnet
+}
+
+// WithIPv6
+func (o *CreateOptions) WithIPv6(value bool) *CreateOptions {
+ v := &value
+ o.IPv6 = v
+ return o
+}
+
+// GetIPv6
+func (o *CreateOptions) GetIPv6() bool {
+ var iPv6 bool
+ if o.IPv6 == nil {
+ return iPv6
+ }
+ return *o.IPv6
+}
+
+// WithOptions
+func (o *CreateOptions) WithOptions(value map[string]string) *CreateOptions {
+ v := value
+ o.Options = v
+ return o
+}
+
+// GetOptions
+func (o *CreateOptions) GetOptions() map[string]string {
+ var options map[string]string
+ if o.Options == nil {
+ return options
+ }
+ return o.Options
+}
+
+// WithName
+func (o *CreateOptions) WithName(value string) *CreateOptions {
+ v := &value
+ o.Name = v
+ return o
+}
+
+// GetName
+func (o *CreateOptions) GetName() string {
+ var name string
+ if o.Name == nil {
+ return name
+ }
+ return *o.Name
+}
diff --git a/pkg/bindings/network/types_disconnect_options.go b/pkg/bindings/network/types_disconnect_options.go
new file mode 100644
index 000000000..183032998
--- /dev/null
+++ b/pkg/bindings/network/types_disconnect_options.go
@@ -0,0 +1,104 @@
+package network
+
+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-16 11:59:06.07634068 -0600 CST m=+0.000179587
+*/
+
+// Changed
+func (o *DisconnectOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *DisconnectOptions) 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
+}
+
+// WithForce
+func (o *DisconnectOptions) WithForce(value bool) *DisconnectOptions {
+ v := &value
+ o.Force = v
+ return o
+}
+
+// GetForce
+func (o *DisconnectOptions) GetForce() bool {
+ var force bool
+ if o.Force == nil {
+ return force
+ }
+ return *o.Force
+}
diff --git a/pkg/bindings/network/types_inspect_options.go b/pkg/bindings/network/types_inspect_options.go
new file mode 100644
index 000000000..91adac8f4
--- /dev/null
+++ b/pkg/bindings/network/types_inspect_options.go
@@ -0,0 +1,88 @@
+package network
+
+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-16 11:59:05.661597872 -0600 CST m=+0.000168252
+*/
+
+// Changed
+func (o *InspectOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *InspectOptions) 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
+}
diff --git a/pkg/bindings/network/types_list_options.go b/pkg/bindings/network/types_list_options.go
new file mode 100644
index 000000000..3f1909ee1
--- /dev/null
+++ b/pkg/bindings/network/types_list_options.go
@@ -0,0 +1,104 @@
+package network
+
+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-16 11:59:05.936262707 -0600 CST m=+0.000172058
+*/
+
+// Changed
+func (o *ListOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *ListOptions) 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 *ListOptions) WithFilters(value map[string][]string) *ListOptions {
+ v := value
+ o.Filters = v
+ return o
+}
+
+// GetFilters
+func (o *ListOptions) GetFilters() map[string][]string {
+ var filters map[string][]string
+ if o.Filters == nil {
+ return filters
+ }
+ return o.Filters
+}
diff --git a/pkg/bindings/network/types_remove_options.go b/pkg/bindings/network/types_remove_options.go
new file mode 100644
index 000000000..5f3dc70ec
--- /dev/null
+++ b/pkg/bindings/network/types_remove_options.go
@@ -0,0 +1,104 @@
+package network
+
+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-16 11:59:05.798818224 -0600 CST m=+0.000173420
+*/
+
+// Changed
+func (o *RemoveOptions) Changed(fieldName string) bool {
+ r := reflect.ValueOf(o)
+ value := reflect.Indirect(r).FieldByName(fieldName)
+ return !value.IsNil()
+}
+
+// ToParams
+func (o *RemoveOptions) 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
+}
+
+// WithForce
+func (o *RemoveOptions) WithForce(value bool) *RemoveOptions {
+ v := &value
+ o.Force = v
+ return o
+}
+
+// GetForce
+func (o *RemoveOptions) GetForce() bool {
+ var force bool
+ if o.Force == nil {
+ return force
+ }
+ return *o.Force
+}