github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/networking/v3/eips/requests.go (about)

     1  package eips
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  type GetResult struct {
     9  	golangsdk.Result
    10  }
    11  
    12  // Get is a method by which can get the detailed information of public ip
    13  func Get(client *golangsdk.ServiceClient, id string) (r GetResult) {
    14  	_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
    15  	return
    16  }
    17  
    18  type ListOpts struct {
    19  	// Specifies the resource ID of pagination query. If the parameter
    20  	// is left blank, only resources on the first page are queried.
    21  	Marker string `q:"marker"`
    22  
    23  	// Specifies the number of records returned on each page. The
    24  	// value ranges from 0 to [2000], of which [2000] is the site difference item.
    25  	// The specific value is determined by the site.
    26  	Limit int `q:"limit"`
    27  
    28  	// Specifies the query field you want.
    29  	Fields []string `q:"fields"`
    30  
    31  	// Sort key, valid values are id, public_ip_address, public_ipv6_address,
    32  	// ip_version, created_at, updated_at and public_border_group.
    33  	SortKey string `q:"sort_key"`
    34  
    35  	// Sorting direction, valid values are asc and desc.
    36  	SortDir string `q:"sort_dir"`
    37  
    38  	Id []string `q:"id"`
    39  
    40  	// Value range: 4, 6
    41  	IPVersion int `q:"ip_version"`
    42  
    43  	// EIP name
    44  	Alias []string `q:"alias"`
    45  
    46  	PublicIp   []string `q:"public_ip_address"`
    47  	PublicIpv6 []string `q:"public_ipv6_address"`
    48  
    49  	// Private IP address
    50  	PrivateIp []string `q:"vnic.private_ip_address"`
    51  
    52  	// Associated port id
    53  	PortId []string `q:"vnic.port_id"`
    54  
    55  	EnterpriseProjectId string `q:"enterprise_project_id"`
    56  
    57  	// Type, valid values are EIP and DUALSTACK.
    58  	Type []string `q:"type"`
    59  
    60  	// Network Type, valid values are 5_telcom, 5_union, 5_bgp, 5_sbgp, 5_ipv6 and 5_graybgp
    61  	NetworkType []string `q:"network_type"`
    62  
    63  	// Public Pool Name
    64  	PublicPoolName []string `q:"public_pool_name"`
    65  
    66  	// Status, valid values are FREEZED、DOWN、ACTIVE、ERROR.
    67  	Status []string `q:"status"`
    68  
    69  	// Device ID
    70  	DeviceID []string `q:"vnic.device_id"`
    71  
    72  	// Device owner
    73  	DeviceOwner []string `q:"vnic.device_owner"`
    74  
    75  	VPCID []string `q:"vnic.vpc_id"`
    76  
    77  	// Instance type the port associated with
    78  	InstanceType []string `q:"vnic.instance_type"`
    79  
    80  	// Instance ID the port associated with
    81  	InstanceID []string `q:"vnic.instance_id"`
    82  
    83  	// Associated instance type
    84  	AssociateInstanceType []string `q:"associate_instance_type"`
    85  
    86  	// Associated instance ID
    87  	AssociateInstanceID []string `q:"associate_instance_id"`
    88  
    89  	BandwidthID         []string `q:"bandwidth.id"`
    90  	BandwidthName       []string `q:"bandwidth.name"`
    91  	BandwidthSize       []string `q:"bandwidth.size"`
    92  	BandwidthShareType  []string `q:"bandwidth.share_type"`
    93  	BandwidthChargeMode []string `q:"bandwidth.charge_mode"`
    94  
    95  	// Public border group
    96  	PublicBorderGroup []string `q:"public_border_group"`
    97  
    98  	AllowShareBandwidthTypeAny []string `q:"allow_share_bandwidth_type_any"`
    99  }
   100  
   101  // List is a method used to query the public ips with given parameters.
   102  func List(client *golangsdk.ServiceClient, opts ListOpts) ([]PublicIp, error) {
   103  	url := listURL(client)
   104  	query, err := golangsdk.BuildQueryString(opts)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	url += query.String()
   109  
   110  	pages, err := pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
   111  		p := PublicIPPage{pagination.MarkerPageBase{PageResult: r}}
   112  		p.MarkerPageBase.Owner = p
   113  		return p
   114  	}).AllPages()
   115  
   116  	if err != nil {
   117  		return nil, err
   118  	}
   119  	return ExtractPublicIPs(pages)
   120  }