task.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package nutanix
  15. type MetaRequest struct {
  16. MethodName string `json:"method_name"`
  17. }
  18. type EntityList struct {
  19. EntityID string `json:"entity_id"`
  20. EntityType string `json:"entity_type"`
  21. EntityName interface{} `json:"entity_name"`
  22. }
  23. type MetaResponse struct {
  24. ErrorCode int `json:"error_code"`
  25. ErrorDetail string `json:"error_detail"`
  26. }
  27. type STask struct {
  28. UUID string `json:"uuid"`
  29. MetaRequest MetaRequest `json:"meta_request"`
  30. MetaResponse MetaResponse `json:"meta_response,omitempty"`
  31. CreateTimeUsecs int64 `json:"create_time_usecs"`
  32. StartTimeUsecs int64 `json:"start_time_usecs"`
  33. CompleteTimeUsecs int64 `json:"complete_time_usecs"`
  34. LastUpdatedTimeUsecs int64 `json:"last_updated_time_usecs"`
  35. EntityList []EntityList `json:"entity_list,omitempty"`
  36. OperationType string `json:"operation_type"`
  37. Message string `json:"message"`
  38. PercentageComplete int `json:"percentage_complete"`
  39. ProgressStatus string `json:"progress_status"`
  40. ClusterUUID string `json:"cluster_uuid"`
  41. SubtaskUUIDList []string `json:"subtask_uuid_list,omitempty"`
  42. }
  43. func (self *SRegion) GetTasks() ([]STask, error) {
  44. tasks := []STask{}
  45. return tasks, self.post("tasks/list", nil, &tasks)
  46. }
  47. func (self *SRegion) GetTask(id string) (*STask, error) {
  48. return self.cli.getTask(id)
  49. }