github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/imageservice/v2/images/doc.go (about) 1 /* 2 Package images enables management and retrieval of images from the OpenStack 3 Image Service. 4 5 Example to List Images 6 7 images.ListOpts{ 8 Owner: "a7509e1ae65945fda83f3e52c6296017", 9 } 10 11 allPages, err := images.List(imagesClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allImages, err := images.ExtractImages(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, image := range allImages { 22 fmt.Printf("%+v\n", image) 23 } 24 25 Example to Create an Image 26 27 createOpts := images.CreateOpts{ 28 Name: "image_name", 29 Visibility: images.ImageVisibilityPrivate, 30 } 31 32 image, err := images.Create(imageClient, createOpts) 33 if err != nil { 34 panic(err) 35 } 36 37 Example to Update an Image 38 39 imageID := "1bea47ed-f6a9-463b-b423-14b9cca9ad27" 40 41 updateOpts := images.UpdateOpts{ 42 images.ReplaceImageName{ 43 NewName: "new_name", 44 }, 45 } 46 47 image, err := images.Update(imageClient, imageID, updateOpts).Extract() 48 if err != nil { 49 panic(err) 50 } 51 52 Example to Delete an Image 53 54 imageID := "1bea47ed-f6a9-463b-b423-14b9cca9ad27" 55 err := images.Delete(imageClient, imageID).ExtractErr() 56 if err != nil { 57 panic(err) 58 } 59 */ 60 package images