github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/provider/requests.go (about)

     1  package provider
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk/openstack/networking/v2/networks"
     5  )
     6  
     7  // CreateOptsExt adds a Segments option to the base Network CreateOpts.
     8  type CreateOptsExt struct {
     9  	networks.CreateOptsBuilder
    10  	Segments []Segment `json:"segments,omitempty"`
    11  }
    12  
    13  // ToNetworkCreateMap adds segments to the base network creation options.
    14  func (opts CreateOptsExt) ToNetworkCreateMap() (map[string]interface{}, error) {
    15  	base, err := opts.CreateOptsBuilder.ToNetworkCreateMap()
    16  	if err != nil {
    17  		return nil, err
    18  	}
    19  
    20  	if opts.Segments == nil {
    21  		return base, nil
    22  	}
    23  
    24  	providerMap := base["network"].(map[string]interface{})
    25  	providerMap["segments"] = opts.Segments
    26  
    27  	return base, nil
    28  }