feat: 🎸 Add worker model (#1213)

✅ Closes: ICU-5239
This commit is contained in:
Zhihe Li authored and GitHub committed 2022-07-28 14:33:23 -04:00
1 parent dcf24478bd
commit a84e8c693e
7 files changed
+129

No files matched your search

@@ -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;
}
+11
View File
@@ -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;
}
+27
View File
@@ -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;
}
+1
View File
@@ -0,0 +1 @@
export { default } from 'api/models/fragment-tag';
+1
View File
@@ -0,0 +1 @@
export { default } from 'api/models/worker';
@@ -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);
});
});
@@ -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);
});
});