github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcs/v1/lifecycle/List.go (about) 1 package lifecycle 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListDcsInstanceOpts struct { 9 // Instance ID. 10 Id string `q:"id"` 11 // DCS instance name. 12 Name string `q:"name"` 13 // Number of DCS instances displayed on each page. 14 // Minimum value: 1 15 // Maximum value: 2000 16 // If this parameter is left unspecified, a maximum of 1000 DCS instances are displayed on each page. 17 Limit int `q:"limit"` 18 // Start number for querying DCS instances. It cannot be lower than 1. 19 // By default, the start number is 1. 20 Start int `q:"start"` 21 // DCS instance status. 22 Status string `q:"status"` 23 // An indicator of whether to perform an exact or fuzzy match based on instance name. 24 // Options: 25 // true: exact match 26 // false: fuzzy match 27 // Default value: false. 28 IsExactMatchName bool `q:"isExactMatchName"` 29 // IP address for connecting to the DCS instance 30 Ip string `q:"ip"` 31 // Query based on the instance tag key and value. {key} indicates the tag key, and {value} indicates the tag value. 32 // To query instances with multiple tag keys and values, separate key-value pairs with commas (,). 33 Tags map[string]string `q:"tags"` 34 } 35 36 func List(client *golangsdk.ServiceClient, opts ListDcsInstanceOpts) (*ListDcsResponse, error) { 37 url, err := golangsdk.NewURLBuilder().WithEndpoints("instances").WithQueryParams(&opts).Build() 38 if err != nil { 39 return nil, err 40 } 41 42 // GET /v1.0/{project_id}/instances 43 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 44 if err != nil { 45 return nil, err 46 } 47 48 var res ListDcsResponse 49 err = extract.Into(raw.Body, &res) 50 return &res, err 51 } 52 53 type ListDcsResponse struct { 54 // Array of DCS instance details. 55 Instances []Instance `json:"instances"` 56 // Number of DCS instances. 57 TotalCount int `json:"instance_num"` 58 }