github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ims/v2/images/UpdateImage.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/internal/extract" 7 ) 8 9 type UpdateImageOpts struct { 10 // Specifies the operation. The value can be add, replace, or remove. 11 Op string `json:"op" required:"true"` 12 // Specifies the name of the attribute to be modified. / needs to be added in front of it. 13 // 14 // You can modify the following attributes: 15 // 16 // name: specifies the image name. 17 // __description: specifies the image description. 18 // __support_xen: Xen is supported. 19 // __support_largememory: Ultra-large memory is supported. 20 // __support_diskintensive: Intensive storage is supported. 21 // __support_highperformance: High-performance computing (HPC) is supported. 22 // __support_xen_gpu_type: GPU-accelerated ECSs that use Xen for virtualization are supported. 23 // __support_kvm_gpu_type: GPU-accelerated ECSs that use KVM for virtualization are supported. 24 // __support_xen_hana: HANA ECSs that use Xen for virtualization are supported. 25 // __is_config_init: specifies whether initialization configuration is complete. 26 // enterprise_project_id: specifies the enterprise project ID. 27 // min_ram: specifies the minimum memory. 28 // hw_vif_multiqueue_enabled: The NIC multi-queue feature is supported. 29 // hw_firmware_type: specifies the boot mode. The value can be bios or uefi. 30 // You can add or delete extension attributes. 31 Path string `json:"path" required:"true"` 32 // Specifies the new value of the attribute. For detailed description, see Image Attributes. 33 Value interface{} `json:"value"` 34 } 35 36 // UpdateImage This API is used to modify image attributes and update image information. 37 // Only information of images in active status can be changed. 38 func UpdateImage(client *golangsdk.ServiceClient, imageId string, opts []UpdateImageOpts) (*ImageInfo, error) { 39 b, err := build.RequestBody(opts, "") 40 if err != nil { 41 return nil, err 42 } 43 44 // PATCH /v2/cloudimages/{image_id} 45 raw, err := client.Patch(client.ServiceURL("cloudimages", imageId), b, nil, &golangsdk.RequestOpts{ 46 OkCodes: []int{200}, 47 }) 48 if err != nil { 49 return nil, err 50 } 51 52 var res ImageInfo 53 err = extract.Into(raw.Body, &res) 54 return &res, err 55 }