(w http.ResponseWriter, r *http.Request)
| 30 | ) |
| 31 | |
| 32 | func GetTaskJob(w http.ResponseWriter, r *http.Request) { |
| 33 | vars := mux.Vars(r) |
| 34 | apiName := vars["apiName"] |
| 35 | jobID, err := getRequiredQueryParam("jobID", r) |
| 36 | if err != nil { |
| 37 | respondError(w, r, err) |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | deployedResource, err := resources.GetDeployedResourceByName(apiName) |
| 42 | if err != nil { |
| 43 | respondError(w, r, err) |
| 44 | return |
| 45 | } |
| 46 | if deployedResource.Kind != userconfig.TaskAPIKind { |
| 47 | respondError(w, r, resources.ErrorOperationIsOnlySupportedForKind(*deployedResource, userconfig.TaskAPIKind)) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | jobKey := spec.JobKey{ |
| 52 | APIName: apiName, |
| 53 | ID: jobID, |
| 54 | Kind: userconfig.TaskAPIKind, |
| 55 | } |
| 56 | |
| 57 | jobStatus, err := taskapi.GetJobStatus(jobKey) |
| 58 | if err != nil { |
| 59 | respondError(w, r, err) |
| 60 | return |
| 61 | } |
| 62 | |
| 63 | apiSpec, err := operator.DownloadAPISpec(jobStatus.APIName, jobStatus.APIID) |
| 64 | if err != nil { |
| 65 | respondError(w, r, err) |
| 66 | return |
| 67 | } |
| 68 | |
| 69 | endpoint, err := operator.APIEndpoint(apiSpec) |
| 70 | if err != nil { |
| 71 | respondError(w, r, err) |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | parsedURL, err := url.Parse(endpoint) |
| 76 | if err != nil { |
| 77 | respondError(w, r, err) |
| 78 | } |
| 79 | q := parsedURL.Query() |
| 80 | q.Add("jobID", jobKey.ID) |
| 81 | parsedURL.RawQuery = q.Encode() |
| 82 | |
| 83 | response := schema.TaskJobResponse{ |
| 84 | JobStatus: *jobStatus, |
| 85 | APISpec: *apiSpec, |
| 86 | Endpoint: parsedURL.String(), |
| 87 | } |
| 88 | |
| 89 | respondJSON(w, r, response) |
nothing calls this directly
no test coverage detected