move ssh errors from common resource to auth keys service
[arvados.git] / src / services / common-service / common-resource-service.ts
index 90677b05b602e280851c98a0d72ae33c632dea2f..70c1df0e2bc5e665a3c62c05b39b7a50a6705c62 100644 (file)
@@ -62,7 +62,7 @@ export class CommonResourceService<T extends Resource> {
             }
         }
 
-    static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions): Promise<R> {
+    static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions, mapKeys = true): Promise<R> {
         const reqId = uuid();
         actions.progressFn(reqId, true);
         return promise
@@ -70,7 +70,9 @@ export class CommonResourceService<T extends Resource> {
                 actions.progressFn(reqId, false);
                 return data;
             })
-            .then(CommonResourceService.mapResponseKeys)
+            .then((response: { data: any }) => {
+                return mapKeys ? CommonResourceService.mapResponseKeys(response) : response.data;
+            })
             .catch(({ response }) => {
                 actions.progressFn(reqId, false);
                 const errors = CommonResourceService.mapResponseKeys(response) as Errors;
@@ -79,18 +81,6 @@ export class CommonResourceService<T extends Resource> {
             });
     }
 
-    static customResponse<R>(promise: AxiosPromise<R>, actions: ApiActions): Promise<R> {
-        const reqId = uuid();
-        actions.progressFn(reqId, true);
-        return promise
-            .then(data => {
-                actions.progressFn(reqId, false);
-                return data;
-            })
-            .then((response: { data: any }) => response.data);
-    }
-
-
     protected serverApi: AxiosInstance;
     protected resourceType: string;
     protected actions: ApiActions;