github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/eps/v1/enterpriseprojects/requests.go (about)

     1  package enterpriseprojects
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  type ListOpts struct {
     8  	Name   string `q:"name"`
     9  	ID     string `q:"id"`
    10  	Status int    `q:"status"`
    11  }
    12  
    13  func (opts ListOpts) ToEnterpriseProjectListQuery() (string, error) {
    14  	q, err := golangsdk.BuildQueryString(opts)
    15  	return q.String(), err
    16  }
    17  
    18  type ListOptsBuilder interface {
    19  	ToEnterpriseProjectListQuery() (string, error)
    20  }
    21  
    22  func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) (r ListResult) {
    23  	url := rootURL(c)
    24  	if opts != nil {
    25  		query, err := opts.ToEnterpriseProjectListQuery()
    26  		if err != nil {
    27  			r.Err = err
    28  		}
    29  		url += query
    30  	}
    31  
    32  	_, r.Err = c.Get(url, &r.Body, nil)
    33  	return
    34  }