github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/icd/icdv4/task.go (about) 1 package icdv4 2 3 import ( 4 "fmt" 5 "github.com/IBM-Cloud/bluemix-go/client" 6 "github.com/IBM-Cloud/bluemix-go/utils" 7 ) 8 9 // type TaskResult struct { 10 // Task Task `json:"task"` 11 // } 12 13 // type Task struct { 14 // Id string `json:"id"` 15 // Description string `json:"description"` 16 // Status string `json:"status"` 17 // DeploymentId string `json:"deployment_id"` 18 // ProgressPercent int `json:"progress_percent"` 19 // CreatedAt string `json:"created_at"` 20 21 // } 22 23 type Tasks interface { 24 GetTask(taskId string) (Task, error) 25 } 26 27 type tasks struct { 28 client *client.Client 29 } 30 31 func newTaskAPI(c *client.Client) Tasks { 32 return &tasks{ 33 client: c, 34 } 35 } 36 37 func (r *tasks) GetTask(taskId string) (Task, error) { 38 taskResult := TaskResult{} 39 rawURL := fmt.Sprintf("/v4/ibm/tasks/%s", utils.EscapeUrlParm(taskId)) 40 _, err := r.client.Get(rawURL, &taskResult) 41 if err != nil { 42 return taskResult.Task, err 43 } 44 return taskResult.Task, nil 45 }