github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/networking/v2/extensions/dnatrules/List.go (about) 1 package dnatrules 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 func List(client *golangsdk.ServiceClient, opts ListOpts) ([]DnatRule, error) { 9 url, err := golangsdk.NewURLBuilder().WithEndpoints("dnat_rules").WithQueryParams(&opts).Build() 10 if err != nil { 11 return nil, err 12 } 13 14 // GET /v2.0/dnat_rules 15 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 16 if err != nil { 17 return nil, err 18 } 19 20 var res []DnatRule 21 err = extract.IntoSlicePtr(raw.Body, &res, "dnat_rules") 22 return res, err 23 } 24 25 type ListOpts struct { 26 // Specifies the DNAT rule ID. 27 Id string `q:"id,omitempty"` 28 // Specifies the number of records returned on each page. 29 Limit int `q:"limit,omitempty"` 30 // Specifies the project ID. 31 ProjectId string `q:"tenant_id,omitempty"` 32 // Specifies the NAT gateway ID. 33 NatGatewayId string `q:"nat_gateway_id,omitempty"` 34 // Specifies the port ID of the cloud server (ECS or BMS). 35 PortId string `q:"port_id,omitempty"` 36 // Private IP address 37 PrivateIp string `q:"private_ip,omitempty"` 38 // Specifies the port number used by the cloud server (ECS or BMS) to provide services for external systems. 39 InternalServicePort int `q:"internal_service_port,omitempty"` 40 // Specifies the EIP ID. 41 FloatingIpId string `q:"floating_ip_id,omitempty"` 42 // Specifies the EIP address. 43 FloatingIpAddress string `q:"floating_ip_address,omitempty"` 44 // Specifies the port for providing services for external systems. 45 ExternalServicePort int `q:"external_service_port,omitempty"` 46 // Specifies the protocol. TCP, UDP, and ANY are supported. 47 // The protocol number of TCP, UDP, and ANY are 6, 17, and 0, respectively. 48 Protocol string `q:"protocol,omitempty"` 49 // Provides supplementary information about the DNAT rule. 50 Description string `q:"description,omitempty"` 51 // Specifies the status of the DNAT rule. 52 Status string `q:"status,omitempty"` 53 // Specifies whether the DNAT rule is enabled or disabled. 54 // The value can be: 55 // true: The DNAT rule is enabled. 56 // false: The DNAT rule is disabled. 57 AdminStateUp bool `q:"admin_state_up,omitempty"` 58 // Specifies when the DNAT rule was created (UTC time). 59 // Its value rounds to 6 decimal places for seconds. The format is yyyy-mm-dd hh:mm:ss. 60 CreatedAt bool `q:"created_at,omitempty"` 61 }