(w http.ResponseWriter, r *http.Request)
| 70 | } |
| 71 | |
| 72 | func GetLogURL(w http.ResponseWriter, r *http.Request) { |
| 73 | apiName := mux.Vars(r)["apiName"] |
| 74 | jobID := getOptionalQParam("jobID", r) |
| 75 | |
| 76 | if jobID != "" { |
| 77 | GetJobLogURL(w, r) |
| 78 | return |
| 79 | } |
| 80 | |
| 81 | deployedResource, err := resources.GetDeployedResourceByName(apiName) |
| 82 | if err != nil { |
| 83 | respondError(w, r, err) |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | if deployedResource.Kind == userconfig.BatchAPIKind || deployedResource.Kind == userconfig.TaskAPIKind { |
| 88 | respondError(w, r, ErrorLogsJobIDRequired(*deployedResource)) |
| 89 | return |
| 90 | } |
| 91 | |
| 92 | switch deployedResource.Kind { |
| 93 | case userconfig.AsyncAPIKind: |
| 94 | apiResponse, err := asyncapi.GetAPIByName(deployedResource) |
| 95 | if err != nil { |
| 96 | respondError(w, r, err) |
| 97 | return |
| 98 | } |
| 99 | if apiResponse[0].Spec == nil { |
| 100 | respondError(w, r, errors.ErrorUnexpected("unable to get api spec", apiName)) |
| 101 | } |
| 102 | logURL, err := operator.APILogURL(*apiResponse[0].Spec) |
| 103 | if err != nil { |
| 104 | respondError(w, r, err) |
| 105 | return |
| 106 | } |
| 107 | respondJSON(w, r, schema.LogResponse{ |
| 108 | LogURL: logURL, |
| 109 | }) |
| 110 | case userconfig.RealtimeAPIKind: |
| 111 | apiResponse, err := realtimeapi.GetAPIByName(deployedResource) |
| 112 | if err != nil { |
| 113 | respondError(w, r, err) |
| 114 | return |
| 115 | } |
| 116 | if apiResponse[0].Spec == nil { |
| 117 | respondError(w, r, errors.ErrorUnexpected("unable to get api spec", apiName)) |
| 118 | } |
| 119 | logURL, err := operator.APILogURL(*apiResponse[0].Spec) |
| 120 | if err != nil { |
| 121 | respondError(w, r, err) |
| 122 | return |
| 123 | } |
| 124 | respondJSON(w, r, schema.LogResponse{ |
| 125 | LogURL: logURL, |
| 126 | }) |
| 127 | default: |
| 128 | respondError(w, r, resources.ErrorOperationIsOnlySupportedForKind(*deployedResource, userconfig.RealtimeAPIKind, userconfig.AsyncAPIKind)) |
| 129 | } |
nothing calls this directly
no test coverage detected