github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/mrs/v2/jobs/results.go (about) 1 package jobs 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type commonResult struct { 9 golangsdk.Result 10 } 11 12 // CreateResult represents a result of the Create method. 13 type CreateResult struct { 14 golangsdk.Result 15 } 16 17 // CreateResp is a struct that represents the result of Create methods. 18 type CreateResp struct { 19 // Job execution result 20 JobSubmitResult JobResp `json:"job_submit_result"` 21 // Error message 22 ErrorMsg string `json:"error_msg"` 23 // Error code 24 ErrorCode string `json:"error_code"` 25 } 26 27 // JobResp is an object struct that represents the details of the submit result. 28 type JobResp struct { 29 // Job ID 30 JobId string `json:"job_id"` 31 // Job submission status. 32 // COMPLETE: The job is submitted. 33 // JOBSTAT_SUBMIT_FAILED: Failed to submit the job. 34 State string `json:"state"` 35 } 36 37 // Extract is a method which to extract a creation response. 38 func (r CreateResult) Extract() (*CreateResp, error) { 39 var s CreateResp 40 err := r.ExtractInto(&s) 41 return &s, err 42 } 43 44 // Job is a struct that represents the details of the mapreduce job. 45 type Job struct { 46 // Job ID. 47 JobId string `json:"job_id"` 48 // Name of the user who submits a job. 49 User string `json:"user"` 50 // Job name. It contains 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. 51 JobName string `json:"job_name"` 52 // Final result of a job. 53 // FAILED: indicates that the job fails to be executed. 54 // KILLED: indicates that the job is manually terminated during execution. 55 // UNDEFINED: indicates that the job is being executed. 56 // SUCCEEDED: indicates that the job has been successfully executed. 57 JobResult string `json:"job_result"` 58 // Execution status of a job. 59 // FAILED: failed 60 // KILLED: indicates that the job is terminated. 61 // New: indicates that the job is created. 62 // NEW_SAVING: indicates that the job has been created and is being saved. 63 // SUBMITTED: indicates that the job is submitted. 64 // ACCEPTED: indicates that the job is accepted. 65 // RUNNING: indicates that the job is running. 66 // FINISHED: indicates that the job is completed. 67 JobState string `json:"job_state"` 68 // Job execution progress. 69 JobProgress float32 `json:"job_progress"` 70 // Type of a job, which support: 71 // MapReduce 72 // SparkSubmit 73 // HiveScript 74 // HiveSql 75 // DistCp, importing and exporting data 76 // SparkScript 77 // SparkSql 78 // Flink 79 JobType string `json:"job_type"` 80 // Start time to run a job. Unit: ms. 81 StartedTime int `json:"started_time"` 82 // Time when a job is submitted. Unit: ms. 83 SubmittedTime int `json:"submitted_time"` 84 // End time to run a job. Unit: ms. 85 FinishedTime int `json:"finished_time"` 86 // Running duration of a job. Unit: ms. 87 ElapsedTime int `json:"elapsed_time"` 88 // Running parameter. The parameter contains a maximum of 4,096 characters, 89 // excluding special characters such as ;|&>'<$, and can be left blank. 90 Arguments string `json:"arguments"` 91 // Configuration parameter, which is used to configure -d parameters. 92 // The parameter contains a maximum of 2,048 characters, excluding special characters such as ><|'`&!\, 93 // and can be left blank. 94 Properties string `json:"properties"` 95 // Launcher job ID. 96 LauncherId string `json:"launcher_id"` 97 // Actual job ID. 98 AppId string `json:"app_id"` 99 } 100 101 // GetResult represents a result of the Get method. 102 type GetResult struct { 103 commonResult 104 } 105 106 func (r commonResult) Extract() (*Job, error) { 107 var s Job 108 err := r.ExtractIntoStructPtr(&s, "job_detail") 109 return &s, err 110 } 111 112 // JobPage represents the response pages of the List operation. 113 type JobPage struct { 114 pagination.SinglePageBase 115 } 116 117 // ExtractJobs is a method which to extract a job list by job pages. 118 func ExtractJobs(r pagination.Page) ([]Job, error) { 119 var s []Job 120 err := r.(JobPage).Result.ExtractIntoSlicePtr(&s, "job_list") 121 return s, err 122 } 123 124 // DeleteResult represents a result of the Delete method. 125 type DeleteResult struct { 126 golangsdk.ErrResult 127 }