github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/networking/v1/routetables/Action.go (about)

     1  package routetables
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  // ActionSubnetsOpts contains the subnets list that associate or disassociate with a route table
    10  type ActionSubnetsOpts struct {
    11  	Associate    []string `json:"associate,omitempty"`
    12  	Disassociate []string `json:"disassociate,omitempty"`
    13  }
    14  
    15  // ActionOpts contains the values used when associating or disassociating subnets with a route table
    16  type ActionOpts struct {
    17  	Subnets ActionSubnetsOpts `json:"subnets" required:"true"`
    18  }
    19  
    20  // Action will associate or disassociate subnets with a particular route table based on its unique ID
    21  func Action(client *golangsdk.ServiceClient, id string, opts ActionOpts) (*RouteTable, error) {
    22  	b, err := build.RequestBody(opts, "routetable")
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  	raw, err := client.Post(client.ServiceURL(client.ProjectID, "routetables", id, "action"), b, nil, &golangsdk.RequestOpts{
    27  		OkCodes: []int{200},
    28  	})
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	var res RouteTable
    34  	err = extract.IntoStructPtr(raw.Body, &res, "routetable")
    35  	return &res, err
    36  }