github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/fgs/v2/dependencies/requests.go (about)

     1  package dependencies
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // ListOpts allows to filter list data using given parameters.
     9  type ListOpts struct {
    10  	// Dependency type, which support public, private, and all, default to all.
    11  	//   public
    12  	//   private
    13  	//   all
    14  	DependencyType string `q:"dependency_type"`
    15  	// Runtime of function.
    16  	Runtime string `q:"runtime"`
    17  	// Name of the dependency.
    18  	Name string `q:"name"`
    19  	// Final record queried last time. Default value: 0.
    20  	Marker string `q:"marker"`
    21  	// Maximum number of dependencies that can be obtained in a query, default to 400.
    22  	Limit string `q:"limit"`
    23  }
    24  
    25  // ListOptsBuilder is an interface which to support request query build of
    26  // the dependent package search.
    27  type ListOptsBuilder interface {
    28  	ToListQuery() (string, error)
    29  }
    30  
    31  // ToListQuery is a method which to build a request query by the ListOpts.
    32  func (opts ListOpts) ToListQuery() (string, error) {
    33  	q, err := golangsdk.BuildQueryString(opts)
    34  	return q.String(), err
    35  }
    36  
    37  // List is a method to obtain an array of one or more dependent packages according to the query parameters.
    38  func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager {
    39  	url := rootURL(client)
    40  	if opts != nil {
    41  		query, err := opts.ToListQuery()
    42  		if err != nil {
    43  			return pagination.Pager{Err: err}
    44  		}
    45  		url += query
    46  	}
    47  
    48  	return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
    49  		p := DependencyPage{pagination.MarkerPageBase{PageResult: r}}
    50  		p.MarkerPageBase.Owner = p
    51  		return p
    52  	})
    53  }