From a84e8c693ea6595338f3816b1fc96c6e193418fc Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Thu, 28 Jul 2022 14:33:23 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Add=20worker=20model=20(?= =?UTF-8?q?#1213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: ICU-5239 --- addons/api/addon/generated/models/worker.js | 63 +++++++++++++++++++ addons/api/addon/models/fragment-tag.js | 11 ++++ addons/api/addon/models/worker.js | 27 ++++++++ addons/api/app/models/fragment-tag.js | 1 + addons/api/app/models/worker.js | 1 + .../tests/unit/models/fragment-tag-test.js | 13 ++++ addons/api/tests/unit/models/worker-test.js | 13 ++++ 7 files changed, 129 insertions(+) create mode 100644 addons/api/addon/generated/models/worker.js create mode 100644 addons/api/addon/models/fragment-tag.js create mode 100644 addons/api/addon/models/worker.js create mode 100644 addons/api/app/models/fragment-tag.js create mode 100644 addons/api/app/models/worker.js create mode 100644 addons/api/tests/unit/models/fragment-tag-test.js create mode 100644 addons/api/tests/unit/models/worker-test.js diff --git a/addons/api/addon/generated/models/worker.js b/addons/api/addon/generated/models/worker.js new file mode 100644 index 000000000..52422732a --- /dev/null +++ b/addons/api/addon/generated/models/worker.js @@ -0,0 +1,63 @@ +import BaseModel from '../../models/base'; +import { attr } from '@ember-data/model'; + +/** + * Worker contains all fields related to a worker resource + */ +export default class GeneratedWorkerModel extends BaseModel { + // =attributes + + @attr('string', { + description: 'Optional name for identification purposes.', + }) + name; + + @attr('string', { + description: 'Optional user-set description for identification purposes.', + }) + description; + + @attr('date', { + description: 'The time this resource was created\nOutput only.', + readOnly: true, + }) + created_time; + + @attr('date', { + description: 'The time this resource was last updated\nOutput only.', + readOnly: true, + }) + updated_time; + + @attr('number', { + description: 'Current version number of this resource.', + }) + version; + + @attr('string', { + description: 'The address that this worker is reachable at.\nOutput only.', + readOnly: true, + }) + address; + + @attr('date', { + description: + 'The time this worker was last reported its status.\nOutput only.', + readOnly: true, + }) + last_status_time; + + @attr('number', { + description: + 'The number of connections that this worker is currently handling.\nOutput only.', + readOnly: true, + }) + active_connection_count; + + @attr('string', { + description: + 'The type of the worker, denoted by how it authenticates: pki or kms.\nOutput only.', + readOnly: true, + }) + type; +} diff --git a/addons/api/addon/models/fragment-tag.js b/addons/api/addon/models/fragment-tag.js new file mode 100644 index 000000000..c98ec5a43 --- /dev/null +++ b/addons/api/addon/models/fragment-tag.js @@ -0,0 +1,11 @@ +import Fragment from 'ember-data-model-fragments/fragment'; +import { array } from 'ember-data-model-fragments/attributes'; + +export default class FragmentTagModel extends Fragment { + // =attributes + + @array('string', { + readOnly: true, + }) + type; +} diff --git a/addons/api/addon/models/worker.js b/addons/api/addon/models/worker.js new file mode 100644 index 000000000..f2688f2f7 --- /dev/null +++ b/addons/api/addon/models/worker.js @@ -0,0 +1,27 @@ +import GeneratedWorkerModel from '../generated/models/worker'; +import { fragment } from 'ember-data-model-fragments/attributes'; + +export default class WorkerModel extends GeneratedWorkerModel { + // =attributes + + /** + * @type {[FragmentTagModel]} + */ + @fragment('fragment-tag', { + 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; + + /** + * @type {[FragmentTagModel]} + */ + @fragment('fragment-tag', { + description: + "The tags set in the worker's configuration file.\nOutput only.", + readOnly: true, + }) + config_tags; +} diff --git a/addons/api/app/models/fragment-tag.js b/addons/api/app/models/fragment-tag.js new file mode 100644 index 000000000..48596d6c6 --- /dev/null +++ b/addons/api/app/models/fragment-tag.js @@ -0,0 +1 @@ +export { default } from 'api/models/fragment-tag'; diff --git a/addons/api/app/models/worker.js b/addons/api/app/models/worker.js new file mode 100644 index 000000000..bad690be4 --- /dev/null +++ b/addons/api/app/models/worker.js @@ -0,0 +1 @@ +export { default } from 'api/models/worker'; diff --git a/addons/api/tests/unit/models/fragment-tag-test.js b/addons/api/tests/unit/models/fragment-tag-test.js new file mode 100644 index 000000000..da75f1e5e --- /dev/null +++ b/addons/api/tests/unit/models/fragment-tag-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | fragment tag', function (hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function (assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('fragment-tag', {}); + assert.ok(model); + }); +}); diff --git a/addons/api/tests/unit/models/worker-test.js b/addons/api/tests/unit/models/worker-test.js new file mode 100644 index 000000000..200034c2a --- /dev/null +++ b/addons/api/tests/unit/models/worker-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | worker', function (hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function (assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('worker', {}); + assert.ok(model); + }); +});