chore: add writeOnce field support

This commit is contained in:
Randall Morey committed 2022-01-20 17:20:24 -05:00
1 parent 1889dd0090
commit cd60c0bbc3
3 files changed
+8 -6

No files matched your search

@@ -73,14 +73,14 @@ export default class GeneratedHostCatalogModel extends BaseModel {
@attr('string', {
isNestedAttribute: true,
readOnly: true,
writeOnce: true,
description: '',
})
access_key_id;
@attr('string', {
isNestedAttribute: true,
readOnly: true,
writeOnce: true,
description: '',
})
secret_access_key;
@@ -107,14 +107,14 @@ export default class GeneratedHostCatalogModel extends BaseModel {
@attr('string', {
isNestedAttribute: true,
readOnly: true,
writeOnce: true,
description: '',
})
secret_id;
@attr('string', {
isNestedAttribute: true,
readOnly: true,
writeOnce: true,
description: '',
})
secret_value;
@@ -43,6 +43,8 @@ export default class ApplicationSerializer extends RESTSerializer {
if (type === 'string' && json[key] === '') json[key] = null;
// Do not serialize read-only attributes.
if (options.readOnly) delete json[key];
// Only serialize write-once fields on create.
if (options.writeOnce && !snapshot.record.isNew) delete json[key];
// Version is sent only if it has a non-nullish value
if (key === 'version') {
if (json[key] === null || json[key] === undefined) delete json[key];