open-nomad/ui/app/serializers/node.js
2023-04-10 15:36:59 +00:00

41 lines
843 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { inject as service } from '@ember/service';
import ApplicationSerializer from './application';
export default class NodeSerializer extends ApplicationSerializer {
@service config;
attrs = {
isDraining: 'Drain',
httpAddr: 'HTTPAddr',
resources: 'NodeResources',
reserved: 'ReservedResources',
};
mapToArray = ['Drivers', 'HostVolumes'];
extractRelationships(modelClass, hash) {
const { modelName } = modelClass;
const nodeURL = this.store
.adapterFor(modelName)
.buildURL(
modelName,
this.extractId(modelClass, hash),
hash,
'findRecord'
);
return {
allocations: {
links: {
related: `${nodeURL}/allocations`,
},
},
};
}
}