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

     1  package images
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // ListOptsBuilder allows extensions to add additional parameters to the
     9  // List request.
    10  type ListOptsBuilder interface {
    11  	ToImageListQuery() (string, error)
    12  }
    13  
    14  // ListOpts allows the filtering and sorting of paginated collections through
    15  // the API. Filtering is achieved by passing in struct field values that map to
    16  // the server attributes you want to see returned. Marker and Limit are used
    17  // for pagination.
    18  //
    19  // http://developer.openstack.org/api-ref-image-v2.html
    20  type ListOpts struct {
    21  	//Image type
    22  	ImageType string `q:"__imagetype"`
    23  
    24  	Protected string `q:"protected"`
    25  
    26  	// Visibility filters on the visibility of the image.
    27  	Visibility string `q:"visibility"`
    28  
    29  	// Status filters on the status of the image.
    30  	Status string `q:"status"`
    31  
    32  	// Name filters on the name of the image.
    33  	Name string `q:"name"`
    34  
    35  	//Indicates the image OS type. The value can be Linux, Windows, or Other.
    36  	OsType string `q:"__os_type"`
    37  
    38  	//
    39  	VirtualEnvType string `q:"virtual_env_type"`
    40  
    41  	// Specifies whether the image is available.
    42  	IsRegistered string `q:"__isregistered"`
    43  
    44  	// Integer value for the limit of values to return.
    45  	Limit int `q:"limit"`
    46  
    47  	Offset string `q:"offset"`
    48  
    49  	// SortKey will sort the results based on a specified image property.
    50  	SortKey string `q:"sort_key"`
    51  
    52  	// SortDir will sort the list results either ascending or decending.
    53  	SortDir string `q:"sort_dir"`
    54  
    55  	// Owner filters on the project ID of the image.
    56  	Owner string `q:"owner"`
    57  
    58  	//Image ID
    59  	ID string `q:"id"`
    60  
    61  	//Specifies whether the image supports KVM.
    62  	//If yes, the value is true. Otherwise, this attribute is not required.
    63  	SupportKvm string `q:"__support_kvm"`
    64  
    65  	//If the image supports the GPU type on the KVM virtualization platform,
    66  	//the value is V100_vGPU or RTX5000. Otherwise, this attribute is unavailable.
    67  	SupportKvmGpuType string `q:"__support_kvm_gpu_type"`
    68  
    69  	//Specifies whether the image supports AI acceleration.
    70  	SupportKvmAscend310 string `q:"__support_kvm_ascend_310"`
    71  
    72  	//Specifies whether the image supports Computing enhancement
    73  	SupportKvmHi1822Hiovs string `q:"__support_kvm_hi1822_hiovs"`
    74  
    75  	//Specifies whether the image supports ARM architecture
    76  	SupportArm string `q:"__support_arm"`
    77  
    78  	//HwFirmwareType firmware type
    79  	HwFirmwareType string `q:"hw_firmware_type"`
    80  }
    81  
    82  // ToImageListQuery formats a ListOpts into a query string.
    83  func (opts ListOpts) ToImageListQuery() (string, error) {
    84  	q, err := golangsdk.BuildQueryString(opts)
    85  	return q.String(), err
    86  }
    87  
    88  // List implements image list request.
    89  func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager {
    90  	url := ListURL(c)
    91  	if opts != nil {
    92  		query, err := opts.ToImageListQuery()
    93  		if err != nil {
    94  			return pagination.Pager{Err: err}
    95  		}
    96  		url += query
    97  	}
    98  	return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
    99  		return ImagePage{pagination.LinkedPageBase{PageResult: r}}
   100  	})
   101  }