github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/er/v3/attachments/requests.go (about) 1 package attachments 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 // ListOpts allows to filter list data using given parameters. 9 type ListOpts struct { 10 // Number of records to be queried. 11 // The valid value is range from 0 to 2000. 12 Limit int `q:"limit"` 13 // The next page index for the attachments query. 14 // If it is empty, it is the first page of the query. 15 // This parameter must be used together with limit. 16 Marker string `q:"marker"` 17 // The list of current status of the attachments (type of VPC, VPN, VGW and PEERING), support for querying multiple 18 // attachments. 19 Statuses []string `q:"state"` 20 // The resource types to be filtered. 21 // + vpc: virtual private cloud 22 // + vpn: vpn gateway 23 // + vgw: virtual gateway of cloud private line 24 // + peering: Peering connection, through the cloud connection (CC) to load enterprise routers in different regions 25 // to create a peering connection 26 ResourceTypes []string `q:"resource_type"` 27 // The resource IDs corresponding to the attachment to be filtered. 28 ResourceIds []string `q:"resource_id"` 29 // The list of keyword to sort the attachments result, sort by ID by default. 30 // The optional values are as follow: 31 // + id 32 // + name 33 // + state 34 SortKey []string `q:"sort_key"` 35 // The returned results are arranged in ascending or descending order, the default is asc. 36 // The valid values are as follows: 37 // + asc 38 // + desc 39 SortDir []string `q:"sort_dir"` 40 } 41 42 // List is a method to query the list of the propagations under specified route table using given opts. 43 func List(client *golangsdk.ServiceClient, instanceId string, opts ListOpts) ([]Attachment, error) { 44 url := queryURL(client, instanceId) 45 query, err := golangsdk.BuildQueryString(opts) 46 if err != nil { 47 return nil, err 48 } 49 url += query.String() 50 51 pages, err := pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { 52 p := AttachmentPage{pagination.MarkerPageBase{PageResult: r}} 53 p.MarkerPageBase.Owner = p 54 return p 55 }).AllPages() 56 57 if err != nil { 58 return nil, err 59 } 60 return extractAttachments(pages) 61 }