github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v1/images/ExportImage.go (about)

     1  package images
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/ims/v1/others"
     7  )
     8  
     9  type ExportImageOpts struct {
    10  	// Specifies the image ID.
    11  	ImageId string `json:"-" required:"true"`
    12  	// Specifies the URL of the image file in the format of Bucket name:File name.
    13  	//
    14  	// Note
    15  	//
    16  	// The storage class of the OBS bucket must be Standard.
    17  	BucketUrl string `json:"bucket_url" required:"true"`
    18  	// Specifies the file format. The value can be qcow2, vhd, zvhd, or vmdk.
    19  	FileFormat string `json:"file_format" required:"true"`
    20  	// Whether to enable fast export. The value can be true or false.
    21  	//
    22  	// Note
    23  	//
    24  	// If fast export is enabled, file_format cannot be specified.
    25  	IsQuickExport *bool `json:"is_quick_export,omitempty"`
    26  }
    27  
    28  func ExportImage(client *golangsdk.ServiceClient, opts ExportImageOpts) (*string, error) {
    29  	b, err := build.RequestBody(opts, "")
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  
    34  	// POST /v1/cloudimages/{image_id}/file
    35  	raw, err := client.Post(client.ServiceURL("cloudimages", opts.ImageId, "file"), b, nil, &golangsdk.RequestOpts{
    36  		OkCodes: []int{200},
    37  	})
    38  	return others.ExtractJobId(err, raw)
    39  }