style: format addons/api
This commit is contained in:
62 files changed
+590
-521
No files matched your search
@@ -2,7 +2,6 @@ import GeneratedAccountModel from '../generated/models/account';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default class AccountModel extends GeneratedAccountModel {
|
||||
|
||||
/**
|
||||
* Attributes of this resource, if any, represented as a JSON fragment.
|
||||
* @type {FragmentAccountAttributesModel}
|
||||
@@ -19,18 +18,17 @@ export default class AccountModel extends GeneratedAccountModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
setPassword(password, options={ adapterOptions: {} }) {
|
||||
setPassword(password, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'set-password',
|
||||
password
|
||||
password,
|
||||
};
|
||||
return this.save({
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import { get } from '@ember/object';
|
||||
* 2) Or as an ID: `record.scopeID`.
|
||||
*/
|
||||
export default class BaseModel extends Model {
|
||||
|
||||
// =relationships
|
||||
|
||||
/**
|
||||
@@ -83,5 +82,4 @@ export default class BaseModel extends Model {
|
||||
get cannotSave() {
|
||||
return !this.canSave;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,8 @@ import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentAccountAttributesModel extends Fragment {
|
||||
|
||||
@attr('string', {
|
||||
description: 'The account login name'
|
||||
}) login_name;
|
||||
|
||||
description: 'The account login name',
|
||||
})
|
||||
login_name;
|
||||
}
|
||||
@@ -2,9 +2,8 @@ import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentHostAttributesModel extends Fragment {
|
||||
|
||||
@attr('string', {
|
||||
description: 'The address (DNS or IP name) used to reach the host'
|
||||
}) address;
|
||||
|
||||
description: 'The address (DNS or IP name) used to reach the host',
|
||||
})
|
||||
address;
|
||||
}
|
||||
@@ -2,15 +2,15 @@ import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentHostSetModel extends Fragment {
|
||||
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the related host set'
|
||||
}) host_set_id;
|
||||
description: 'ID of the related host set',
|
||||
})
|
||||
host_set_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the catalog to which the host set belongs'
|
||||
}) host_catalog_id;
|
||||
|
||||
description: 'ID of the catalog to which the host set belongs',
|
||||
})
|
||||
host_catalog_id;
|
||||
}
|
||||
@@ -2,19 +2,20 @@ import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentPrincipal extends Fragment {
|
||||
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the related scope'
|
||||
}) scope_id;
|
||||
description: 'ID of the related scope',
|
||||
})
|
||||
scope_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the related principal (user or group)'
|
||||
}) principal_id;
|
||||
description: 'ID of the related principal (user or group)',
|
||||
})
|
||||
principal_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'Type of the related principal (user or group)'
|
||||
}) type;
|
||||
|
||||
description: 'Type of the related principal (user or group)',
|
||||
})
|
||||
type;
|
||||
}
|
||||
@@ -4,33 +4,39 @@ import { attr } from '@ember-data/model';
|
||||
import { scopeTypes } from './scope';
|
||||
|
||||
export default class FragmentScope extends Fragment {
|
||||
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the related scope'
|
||||
}) scope_id;
|
||||
description: 'ID of the related scope',
|
||||
})
|
||||
scope_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The type of the resource'
|
||||
}) type;
|
||||
description: 'The type of the resource',
|
||||
})
|
||||
type;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isGlobal() { return this.type === scopeTypes.global; }
|
||||
get isGlobal() {
|
||||
return this.type === scopeTypes.global;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isOrg() { return this.type === scopeTypes.org; }
|
||||
get isOrg() {
|
||||
return this.type === scopeTypes.org;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isProject() { return this.type === scopeTypes.project; }
|
||||
|
||||
get isProject() {
|
||||
return this.type === scopeTypes.project;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,10 @@ import { attr } from '@ember-data/model';
|
||||
* Represents an item in an array of strings.
|
||||
*/
|
||||
export default class FragmentStringModel extends Fragment {
|
||||
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'The value of the string.'
|
||||
description: 'The value of the string.',
|
||||
})
|
||||
value;
|
||||
|
||||
}
|
||||
@@ -2,9 +2,8 @@ import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentTargetAttributesModel extends Fragment {
|
||||
|
||||
@attr('number', {
|
||||
description: 'The default port a target should use if present.'
|
||||
}) default_port;
|
||||
|
||||
description: 'The default port a target should use if present.',
|
||||
})
|
||||
default_port;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { computed } from '@ember/object';
|
||||
import { A } from '@ember/array';
|
||||
|
||||
export default class GroupModel extends GeneratedGroupModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
@@ -14,8 +13,9 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
@attr({
|
||||
readOnly: true,
|
||||
defaultValue: () => A(),
|
||||
emptyArrayIfMissing: true
|
||||
}) member_ids;
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
member_ids;
|
||||
|
||||
/**
|
||||
* An array of resolved user instances.
|
||||
@@ -26,7 +26,7 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
@computed('member_ids.[]')
|
||||
get members() {
|
||||
return this.member_ids
|
||||
.map(id => this.store.peekRecord('user', id))
|
||||
.map((id) => this.store.peekRecord('user', id))
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addMembers(memberIDs, options={ adapterOptions: {} }) {
|
||||
addMembers(memberIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-members',
|
||||
memberIDs
|
||||
memberIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -52,8 +52,8 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeMembers(memberIDs, options={ adapterOptions: {} }) {
|
||||
removeMembers(memberIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-members',
|
||||
memberIDs
|
||||
memberIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -77,8 +77,8 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,5 +91,4 @@ export default class GroupModel extends GeneratedGroupModel {
|
||||
removeMember(memberID, options) {
|
||||
return this.removeMembers([memberID], options);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import GeneratedHostSetModel from '../generated/models/host-set';
|
||||
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default class HostSetModel extends GeneratedHostSetModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
@@ -11,8 +10,9 @@ export default class HostSetModel extends GeneratedHostSetModel {
|
||||
*/
|
||||
@fragmentArray('fragment-string', {
|
||||
readOnly: true,
|
||||
emptyArrayIfMissing: true
|
||||
}) host_ids;
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
host_ids;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -24,17 +24,17 @@ export default class HostSetModel extends GeneratedHostSetModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addHosts(hostIDs, options={ adapterOptions: {} }) {
|
||||
addHosts(hostIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-hosts',
|
||||
hostIDs
|
||||
hostIDs,
|
||||
};
|
||||
return this.save({
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,17 +46,17 @@ export default class HostSetModel extends GeneratedHostSetModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeHosts(hostIDs, options={ adapterOptions: {} }) {
|
||||
removeHosts(hostIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-hosts',
|
||||
hostIDs
|
||||
hostIDs,
|
||||
};
|
||||
return this.save({
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,9 @@ import GeneratedHostModel from '../generated/models/host';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default class HostModel extends GeneratedHostModel {
|
||||
|
||||
/**
|
||||
* Attributes of this resource, if any, represented as a JSON fragment.
|
||||
* @type {FragmentHostAttributesModel}
|
||||
*/
|
||||
@fragment('fragment-host-attributes', { defaultValue: {} }) attributes;
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import GeneratedRoleModel from '../generated/models/role';
|
||||
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default class RoleModel extends GeneratedRoleModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
@@ -14,14 +13,15 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
*/
|
||||
@fragmentArray('fragment-principal', {
|
||||
readOnly: true,
|
||||
emptyArrayIfMissing: true
|
||||
}) principals;
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
principals;
|
||||
|
||||
/**
|
||||
* Grants is read-only _most_ under normal circumstances. But grants can
|
||||
* be persisted via a dedicated call to `saveGrants()`.
|
||||
*/
|
||||
@fragmentArray('fragment-string', {readOnly: true}) grants;
|
||||
@fragmentArray('fragment-string', { readOnly: true }) grants;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -34,8 +34,8 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
return this.save({
|
||||
adapterOptions: {
|
||||
method: 'set-grants',
|
||||
serializeGrants: true
|
||||
}
|
||||
serializeGrants: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addPrincipals(principalIDs, options={ adapterOptions: {} }) {
|
||||
addPrincipals(principalIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-principals',
|
||||
principalIDs
|
||||
principalIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -59,8 +59,8 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removePrincipals(principalIDs, options={ adapterOptions: {} }) {
|
||||
removePrincipals(principalIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-principals',
|
||||
principalIDs
|
||||
principalIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -84,8 +84,8 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,5 +98,4 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
removePrincipal(principalID, options) {
|
||||
return this.removePrincipals([principalID], options);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,11 +4,10 @@ import { computed } from '@ember/object';
|
||||
export const scopeTypes = {
|
||||
global: 'global',
|
||||
org: 'org',
|
||||
project: 'project'
|
||||
project: 'project',
|
||||
};
|
||||
|
||||
export default class ScopeModel extends GeneratedScopeModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
@@ -42,5 +41,4 @@ export default class ScopeModel extends GeneratedScopeModel {
|
||||
set isProject(value) {
|
||||
if (value) this.type = scopeTypes.project;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { fragment, fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
export default class TargetModel extends GeneratedTargetModel {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
@@ -17,8 +16,9 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
*/
|
||||
@fragmentArray('fragment-host-set', {
|
||||
readOnly: true,
|
||||
emptyArrayIfMissing: true
|
||||
}) host_sets;
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
host_sets;
|
||||
|
||||
/**
|
||||
* An array of resolved host set and host catalog instances. Model instances
|
||||
@@ -31,9 +31,9 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
return this.host_sets
|
||||
.map(({ host_set_id, host_catalog_id }) => ({
|
||||
model: this.store.peekRecord('host-set', host_set_id),
|
||||
hostCatalog: this.store.peekRecord('host-catalog', host_catalog_id)
|
||||
hostCatalog: this.store.peekRecord('host-catalog', host_catalog_id),
|
||||
}))
|
||||
.filter(hostSetRef => hostSetRef.model !== null);
|
||||
.filter((hostSetRef) => hostSetRef.model !== null);
|
||||
}
|
||||
|
||||
// =methods
|
||||
@@ -46,10 +46,10 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addHostSets(hostSetIDs, options={ adapterOptions: {} }) {
|
||||
addHostSets(hostSetIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-host-sets',
|
||||
hostSetIDs
|
||||
hostSetIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -58,8 +58,8 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeHostSets(hostSetIDs, options={ adapterOptions: {} }) {
|
||||
removeHostSets(hostSetIDs, options = { adapterOptions: {} }) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-host-sets',
|
||||
hostSetIDs
|
||||
hostSetIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
// All of this nonsense is here to ensure we get
|
||||
@@ -83,8 +83,8 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions
|
||||
}
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -97,5 +97,4 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
removeHostSet(hostSetID, options) {
|
||||
return this.removeHostSets([hostSetID], options);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user