github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v1/images/RegisterImage.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 RegisterImageOpts struct {
    10  	// Specifies the image ID.
    11  	//
    12  	// image_id is the ID of the image you created by invoking the API for creating image metadata. Registration may fail if you use other image IDs.
    13  	//
    14  	// After this API is invoked, you can check the image status with the image ID. When the image status changes to active, the image file is successfully registered. For details, see Querying Image Details (Native OpenStack API).
    15  	ImageId string `json:"-" required:"true"`
    16  	// Specifies the URL of the image file in the format of Bucket name:File name.
    17  	//
    18  	// Image files in the bucket can be in ZVHD, QCOW2, VHD, RAW, VHDX, QED, VDI, QCOW, ZVHD2, or VMDK format.
    19  	//
    20  	// Note
    21  	//
    22  	// The storage class of the OBS bucket must be Standard.
    23  	ImageUrl string `json:"image_url" required:"true"`
    24  }
    25  
    26  func RegisterImage(client *golangsdk.ServiceClient, opts RegisterImageOpts) (*string, error) {
    27  	b, err := build.RequestBody(opts, "")
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	// PUT /v1/cloudimages/{image_id}/upload
    33  	raw, err := client.Put(client.ServiceURL("cloudimages", opts.ImageId, "upload"), b, nil, &golangsdk.RequestOpts{
    34  		OkCodes: []int{200},
    35  	})
    36  	return others.ExtractJobId(err, raw)
    37  }