github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/policies/list.go (about)

     1  package policies
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  // OperationType is a Policy type.
     9  // One of `backup` and `replication`.
    10  type OperationType string
    11  
    12  type ListOpts struct {
    13  	OperationType OperationType `q:"operation_type"`
    14  	VaultID       string        `q:"vault_id"`
    15  }
    16  
    17  func List(client *golangsdk.ServiceClient, opts ListOpts) ([]Policy, error) {
    18  	url, err := golangsdk.NewURLBuilder().WithEndpoints("policies").WithQueryParams(&opts).Build()
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  
    23  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	var res []Policy
    29  	err = extract.IntoSlicePtr(raw.Body, &res, "policies")
    30  	return res, err
    31  }