github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v1/images/CreateDataImage.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/common/tags"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/ims/v1/others"
     8  )
     9  
    10  type CreateDataImageOpts struct {
    11  	// Specifies the image name.
    12  	Name string `json:"name" required:"true"`
    13  	// Provides supplementary information about the image. For detailed description, see Image Attributes. The value contains a maximum of 1024 characters and consists of only letters and digits. Carriage returns and angle brackets (< >) are not allowed. This parameter is left blank by default.
    14  	Description string `json:"description,omitempty"`
    15  	// Specifies the OS type.
    16  	//
    17  	// It can only be Windows or Linux. The default is Linux.
    18  	OsType string `json:"os_type,omitempty"`
    19  	// Specifies the URL of the external image file in the OBS bucket.
    20  	//
    21  	// The format is OBS bucket name:Image file name.
    22  	//
    23  	// NOTE:
    24  	// The storage class of the OBS bucket must be Standard.
    25  	ImageUrl string `json:"image_url" required:"true"`
    26  	// Specifies the minimum size of the data disk.
    27  	// Value range: 40 GB to 2048 GB
    28  	MinDisk int `json:"min_disk" required:"true"`
    29  	// Specifies the master key used for encrypting an image. For its value, see the Key Management Service User Guide.
    30  	CmkId string `json:"cmk_id,omitempty"`
    31  	// Specifies image tags. This parameter is left blank by default.
    32  	//
    33  	// For detailed parameter description, see Image Tag Data Formats.
    34  	//
    35  	// Use either tags or image_tags.
    36  	Tags []string `json:"tags,omitempty"`
    37  	// Lists the image tags. This parameter is left blank by default.
    38  	//
    39  	// Use either tags or image_tags.
    40  	ImageTags []tags.ResourceTag `json:"image_tags,omitempty"`
    41  }
    42  
    43  // CreateDataImage This API is used to create a data disk image from a data disk image file uploaded to the OBS bucket. The API is an asynchronous one. If it is successfully called, the cloud service system receives the request. However, you need to use the asynchronous job query API to query the image creation status. For details, see Asynchronous Job Query.
    44  func CreateDataImage(client *golangsdk.ServiceClient, opts CreateDataImageOpts) (*string, error) {
    45  	b, err := build.RequestBody(opts, "")
    46  	if err != nil {
    47  		return nil, err
    48  	}
    49  
    50  	// POST /v1/cloudimages/dataimages/action
    51  	raw, err := client.Post(client.ServiceURL("cloudimages", "dataimages", "action"), b, nil, &golangsdk.RequestOpts{
    52  		OkCodes: []int{200},
    53  	})
    54  	return others.ExtractJobId(err, raw)
    55  }