github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/image/v2/images/Create.go (about) 1 package images 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/openstack/ims/v2/images" 7 ) 8 9 type CreateOpts struct { 10 // Specifies the image OS version. For the value range, see Values of Related Parameters. 11 // 12 // If this parameter is not specified, the value Other Linux(64 bit) will be used. In that case, the ECS creation using this image may fail, and the ECS created using this image may fail to run properly. 13 OsVersion string `json:"__os_version,omitempty"` 14 // Specifies the container format. 15 // 16 // The default value is bare. 17 ContainerFormat string `json:"container_format,omitempty"` 18 // Specifies the image format. The value can be zvhd2, vhd, zvhd, raw, or qcow2. The default value is zvhd2. 19 DiskFormat string `json:"disk_format,omitempty"` 20 // Specifies the minimum disk space (GB) required for running the image. The value ranges from 1 GB to 1024 GB. 21 // 22 // The value of this parameter must be greater than the image system disk capacity. Otherwise, the ECS creation may fail. 23 MinDisk int `json:"min_disk,omitempty"` 24 // Specifies the minimum memory size (MB) required for running the image. The parameter value depends on ECS specifications. The default value is 0. 25 MinRam int `json:"min_ram,omitempty"` 26 // Specifies the image name. If this parameter is not specified, its value is empty by default. In that case, ECS creation using this image will fail. The name contains 1 to 255 characters. For detailed description, see Image Attributes. This parameter is left blank by default. 27 Name string `json:"name,omitempty"` 28 // Lists the image tags. The tag contains 1 to 255 characters. The value is left blank by default. 29 Tags []string `json:"tags,omitempty"` 30 // Specifies whether the image is available to other tenants. 31 // 32 // The default value is private. When creating image metadata, the value of visibility can be set to private only. 33 Visibility string `json:"visibility,omitempty"` 34 // Specifies whether the image is protected. A protected image cannot be deleted. The default value is false. 35 Protected bool `json:"protected,omitempty"` 36 } 37 38 // Create implements create image request. 39 func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*images.ImageInfo, error) { 40 b, err := build.RequestBody(opts, "") 41 if err != nil { 42 return nil, err 43 } 44 45 // POST /v2/images 46 raw, err := client.Post(client.ServiceURL("images"), b, nil, &golangsdk.RequestOpts{OkCodes: []int{201}}) 47 return extractImage(err, raw) 48 }