github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rds/v3/flavors/requests.go (about)

     1  package flavors
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  type DbFlavorsOpts struct {
     9  	Versionname string `q:"version_name"`
    10  }
    11  
    12  type DbFlavorsBuilder interface {
    13  	ToDbFlavorsListQuery() (string, error)
    14  }
    15  
    16  func (opts DbFlavorsOpts) ToDbFlavorsListQuery() (string, error) {
    17  	q, err := golangsdk.BuildQueryString(opts)
    18  	if err != nil {
    19  		return "", err
    20  	}
    21  	return q.String(), err
    22  }
    23  
    24  func List(client *golangsdk.ServiceClient, opts DbFlavorsBuilder, databasename string) pagination.Pager {
    25  	url := listURL(client, databasename)
    26  	if opts != nil {
    27  		query, err := opts.ToDbFlavorsListQuery()
    28  
    29  		if err != nil {
    30  			return pagination.Pager{Err: err}
    31  		}
    32  		url += query
    33  	}
    34  
    35  	pageRdsList := pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
    36  		return DbFlavorsPage{pagination.SinglePageBase(r)}
    37  	})
    38  
    39  	rdsheader := map[string]string{"Content-Type": "application/json"}
    40  	pageRdsList.Headers = rdsheader
    41  	return pageRdsList
    42  }