github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dds/v3/connection/ListConnections.go (about) 1 package connection 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListConnectionsOpts struct { 9 // Specifies the DB instance ID. 10 InstanceId string `json:"-"` 11 // Specifies the node ID. 12 // If this parameter is left blank, the number of connections of all nodes that can be connected in the instance is queried. 13 NodeId string `q:"node_id"` 14 } 15 16 func ListConnections(client *golangsdk.ServiceClient, opts ListConnectionsOpts) (*ListConnectionsResponse, error) { 17 url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", opts.InstanceId, "conn-statistics").WithQueryParams(&opts).Build() 18 if err != nil { 19 return nil, err 20 } 21 22 // GET https://{Endpoint}/v3/{project_id}/instances/{instance_id}/conn-statistics 23 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 24 if err != nil { 25 return nil, err 26 } 27 28 var res ListConnectionsResponse 29 err = extract.Into(raw.Body, &res) 30 return &res, err 31 } 32 33 type ListConnectionsResponse struct { 34 // Indicates the total number of connections, including internal and external connections. 35 TotalConnections int `json:"total_connections"` 36 // Indicates the total number of internal connections. 37 TotalInnerConnections int `json:"total_inner_connections"` 38 // Indicates the total number of external connections. 39 TotalOuterConnections int `json:"total_outer_connections"` 40 // Indicates the internal connection statistics array. Up to 200 records are supported. 41 InnerConnections []Connections `json:"inner_connections"` 42 // Indicates the external connection statistics array. Up to 200 records are supported. 43 OuterConnections []Connections `json:"outer_connections"` 44 } 45 46 type Connections struct { 47 // Indicates the IP address of the client connected to the instance or node. 48 ClientIp string `json:"client_ip"` 49 // Indicates the number of connections corresponding to the IP address. 50 Count int `json:"count"` 51 }