X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/83cc752d85a910c19ffaf5c74433fbf7fa76e038..3b2372cd1ce9528803e32393132b16645aff25f7:/src/services/common-service/common-resource-service.ts diff --git a/src/services/common-service/common-resource-service.ts b/src/services/common-service/common-resource-service.ts index d29ea15642..bc24f22796 100644 --- a/src/services/common-service/common-resource-service.ts +++ b/src/services/common-service/common-resource-service.ts @@ -17,8 +17,26 @@ export enum CommonResourceServiceError { } export class CommonResourceService extends CommonService { - constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) { - super(serverApi, resourceType, actions); + constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions, readOnlyFields: string[] = []) { + super(serverApi, resourceType, actions, readOnlyFields.concat([ + 'uuid', + 'etag', + 'kind' + ])); + } + + create(data?: Partial) { + if (data !== undefined) { + this.readOnlyFields.forEach( field => delete data[field] ); + } + return super.create(data); + } + + update(uuid: string, data: Partial) { + if (data !== undefined) { + this.readOnlyFields.forEach( field => delete data[field] ); + } + return super.update(uuid, data); } }