github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcs/v2/whitelists/Get.go (about)

     1  package whitelists
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/opentelekomcloud/gophertelekomcloud"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     8  )
     9  
    10  // Get the instance whitelist groups by instance id
    11  func Get(client *golangsdk.ServiceClient, id string) (*Whitelist, error) {
    12  	url := client.ServiceURL("instance", id, "whitelist")
    13  	raw, err := client.Get(strings.Replace(url, "v1.0", "v2", 1), nil, nil)
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  
    18  	var res Whitelist
    19  	err = extract.Into(raw.Body, &res)
    20  	return &res, err
    21  }
    22  
    23  // Whitelist is a struct that contains all the whitelist parameters.
    24  type Whitelist struct {
    25  	// instance id
    26  	InstanceID string `json:"instance_id"`
    27  	// enable or disable the whitelists
    28  	Enable bool `json:"enable_whitelist"`
    29  	// list of whitelist groups
    30  	Groups []WhitelistGroup `json:"whitelist"`
    31  }
    32  
    33  // WhitelistGroup is a struct that contains the whitelist parameters.
    34  type WhitelistGroup struct {
    35  	// the group name
    36  	GroupName string `json:"group_name"`
    37  	// list of IP address or range
    38  	IPList []string `json:"ip_list"`
    39  }