github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/serializers/agent.js (about) 1 import ApplicationSerializer from './application'; 2 import AdapterError from '@ember-data/adapter/error'; 3 4 export default ApplicationSerializer.extend({ 5 attrs: { 6 datacenter: 'dc', 7 address: 'Addr', 8 serfPort: 'Port', 9 }, 10 11 normalize(typeHash, hash) { 12 if (!hash) { 13 // It's unusual to throw an adapter error from a serializer, 14 // but there is no single server end point so the serializer 15 // acts like the API in this case. 16 const error = new AdapterError([{ status: '404' }]); 17 18 error.message = 'Requested Agent was not found in set of available Agents'; 19 throw error; 20 } 21 22 hash.ID = hash.Name; 23 hash.Datacenter = hash.Tags && hash.Tags.dc; 24 hash.Region = hash.Tags && hash.Tags.region; 25 hash.RpcPort = hash.Tags && hash.Tags.port; 26 27 return this._super(typeHash, hash); 28 }, 29 30 normalizeResponse(store, typeClass, hash, ...args) { 31 return this._super(store, typeClass, hash.Members || [], ...args); 32 }, 33 34 normalizeSingleResponse(store, typeClass, hash, id, ...args) { 35 return this._super(store, typeClass, hash.findBy('Name', id), id, ...args); 36 }, 37 });