-import * as _ from "lodash";
-import { Resource } from "src/models/resource";
-import { ApiActions } from "~/services/api/api-actions";
-import { CommonService } from "~/services/common-service/common-service";
+import { snakeCase } from "lodash";
+import { Resource } from "models/resource";
+import { ApiActions } from "services/api/api-actions";
+import { CommonService } from "services/common-service/common-service";
export enum CommonResourceServiceError {
UNIQUE_NAME_VIOLATION = 'UniqueNameViolation',
OWNERSHIP_CYCLE = 'OwnershipCycle',
MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState',
NAME_HAS_ALREADY_BEEN_TAKEN = 'NameHasAlreadyBeenTaken',
export enum CommonResourceServiceError {
UNIQUE_NAME_VIOLATION = 'UniqueNameViolation',
OWNERSHIP_CYCLE = 'OwnershipCycle',
MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState',
NAME_HAS_ALREADY_BEEN_TAKEN = 'NameHasAlreadyBeenTaken',
super(serverApi, resourceType, actions, readOnlyFields.concat([
'uuid',
'etag',
super(serverApi, resourceType, actions, readOnlyFields.concat([
'uuid',
'etag',
- [this.resourceType.slice(0, -1)]: CommonService.mapKeys(_.snakeCase)(data),
+ [this.resourceType.slice(0, -1)]: CommonService.mapKeys(snakeCase)(data),
+ };
+ if (select !== undefined && select.length > 0) {
+ payload.select = ['uuid', ...select.map(field => snakeCase(field))];
return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE;
case /Name has already been taken/.test(error):
return CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN;
return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE;
case /Name has already been taken/.test(error):
return CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN;
+ case /403 Forbidden/.test(error):
+ return CommonResourceServiceError.PERMISSION_ERROR_FORBIDDEN;
+ case new RegExp(CommonResourceServiceError.SOURCE_DESTINATION_CANNOT_BE_SAME).test(error):
+ return CommonResourceServiceError.SOURCE_DESTINATION_CANNOT_BE_SAME;