github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/imageservice/v2/tasks/doc.go (about) 1 /* 2 Package tasks enables management and retrieval of tasks from the OpenStack 3 Imageservice. 4 5 Example to List Tasks 6 7 listOpts := tasks.ListOpts{ 8 Owner: "424e7cf0243c468ca61732ba45973b3e", 9 } 10 11 allPages, err := tasks.List(imagesClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allTasks, err := tasks.ExtractTasks(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, task := range allTasks { 22 fmt.Printf("%+v\n", task) 23 } 24 25 Example to Get a Task 26 27 task, err := tasks.Get(imagesClient, "1252f636-1246-4319-bfba-c47cde0efbe0").Extract() 28 if err != nil { 29 panic(err) 30 } 31 32 fmt.Printf("%+v\n", task) 33 34 Example to Create a Task 35 36 createOpts := tasks.CreateOpts{ 37 Type: "import", 38 Input: map[string]interface{}{ 39 "image_properties": map[string]interface{}{ 40 "container_format": "bare", 41 "disk_format": "raw", 42 }, 43 "import_from_format": "raw", 44 "import_from": "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img", 45 }, 46 } 47 48 task, err := tasks.Create(imagesClient, createOpts).Extract() 49 if err != nil { 50 panic(err) 51 } 52 53 fmt.Printf("%+v\n", task) 54 */ 55 package tasks