* feat: 🎸 Add worker serializer Add worker serializer that focus' on `config_tags.type` and `canonical_tags.type`. [API](https://docs.google.com/document/d/1G-lfl8gk9NfoKFImSpHb90E3xC3CSEVDwVy3bJ9eOhA/edit#heading=h.9e06o4b8etpi) ✅ Closes: ICU-5241 * refactor: 💡 refactored `models/worker.js` Because `canonical_tags` and `config_tags` are `readOnly` attributes, we could use `attr` decorator instead of `fragment`. ✅ Closes: ICU-5241 * refactored `model/worker.js and deleted un-needed files * refactor: 💡 Refactored model/worker.js and created test Refactored model/worker.js to include custom method for POST route for adding new worker. BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * refactor: 💡 Refactored custom POST route method for worker Refactored custom method on `model/worker.js` to include serialization for `worker_genrated_auth_token` BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * refactor: 💡 Refactor test Refactor model/worker-test.js and serializers/worker.js BREAKING CHANGE: 🧨 no ✅ Closes: ICU-5241 * Update addons/api/addon/serializers/worker.js Co-authored-by: Dharini Jeeva <dharini@hashicorp.com> * update worker.js documentation block Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import GeneratedWorkerModel from '../generated/models/worker';
|
|
import { attr } from '@ember-data/model';
|
|
|
|
export default class WorkerModel extends GeneratedWorkerModel {
|
|
// =attributes
|
|
|
|
@attr({
|
|
description:
|
|
'The deduplicated union of the tags reported by the worker ' +
|
|
'from its configuration and any tags added through other means.\nOutput only.',
|
|
readOnly: true,
|
|
})
|
|
canonical_tags;
|
|
|
|
@attr({
|
|
description:
|
|
"The tags set in the worker's configuration file.\nOutput only.",
|
|
readOnly: true,
|
|
})
|
|
config_tags;
|
|
|
|
/**
|
|
* Method to modify the adpater to handle custom POST route for creating worker.
|
|
* @param {object} options
|
|
* @param {object} options.adapterOptions
|
|
* @return {Promise}
|
|
*/
|
|
addWorkerLed(workerGeneratedAuthToken, options = { adapterOptions: {} }) {
|
|
const defaultAdapterOptions = {
|
|
method: 'create:worker-led',
|
|
workerGeneratedAuthToken
|
|
};
|
|
return super.save({
|
|
...options,
|
|
adapterOptions: {
|
|
...defaultAdapterOptions,
|
|
...options.adapterOptions,
|
|
},
|
|
});
|
|
}
|
|
}
|