github.com/IBM-Cloud/bluemix-go@v0.0.0-20240314082800-4e02a69b84b2/api/cis/cisv1/ips.go (about)

     1  package cisv1
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/IBM-Cloud/bluemix-go/client"
     6  )
     7  
     8  type IpsList struct {
     9  	Ipv4 []string `json:"ipv4_cidrs"`
    10  	Ipv6 []string `json:"ipv6_cidrs"`
    11  }
    12  
    13  type IpsResults struct {
    14  	IpList      IpsList      `json:"result"`
    15  	ResultsInfo ResultsCount `json:"result_info"`
    16  	Success     bool         `json:"success"`
    17  	Errors      []Error      `json:"errors"`
    18  }
    19  
    20  type Ips interface {
    21  	ListIps() (*IpsList, error)
    22  }
    23  
    24  type ips struct {
    25  	client *client.Client
    26  }
    27  
    28  func newIpsAPI(c *client.Client) Ips {
    29  	return &ips{
    30  		client: c,
    31  	}
    32  }
    33  
    34  func (r *ips) ListIps() (*IpsList, error) {
    35  	ipsResults := IpsResults{}
    36  	rawURL := fmt.Sprintf("/v1/ips")
    37  	_, err := r.client.Get(rawURL, &ipsResults)
    38  	if err != nil {
    39  		return nil, err
    40  	}
    41  	return &ipsResults.IpList, err
    42  }