2018-10-26 16:36:15 +00:00
|
|
|
import RepositoryService from 'consul-ui/services/repository';
|
|
|
|
import { PRIMARY_KEY } from 'consul-ui/models/intention';
|
|
|
|
const modelName = 'intention';
|
|
|
|
export default RepositoryService.extend({
|
|
|
|
getModelName: function() {
|
|
|
|
return modelName;
|
|
|
|
},
|
|
|
|
getPrimaryKey: function() {
|
|
|
|
return PRIMARY_KEY;
|
|
|
|
},
|
2020-07-09 09:08:47 +00:00
|
|
|
create: function(obj) {
|
|
|
|
delete obj.Namespace;
|
|
|
|
return this._super(obj);
|
|
|
|
},
|
2020-06-05 13:44:57 +00:00
|
|
|
shouldReconcile: function(method) {
|
2020-07-09 09:08:47 +00:00
|
|
|
// TODO: This is to be switched out for something at an adapter level
|
|
|
|
// so it works for both methods of interacting with data-sources
|
|
|
|
switch (true) {
|
|
|
|
case method === 'findByService' || method.indexOf('for-service') !== -1:
|
2020-06-05 13:44:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this._super(...arguments);
|
|
|
|
},
|
2020-04-16 14:15:45 +00:00
|
|
|
findByService: function(slug, dc, nspace, configuration = {}) {
|
|
|
|
const query = {
|
|
|
|
dc: dc,
|
|
|
|
nspace: nspace,
|
2020-05-14 16:18:24 +00:00
|
|
|
filter: `SourceName == "${slug}" or DestinationName == "${slug}"`,
|
2020-04-16 14:15:45 +00:00
|
|
|
};
|
|
|
|
if (typeof configuration.cursor !== 'undefined') {
|
|
|
|
query.index = configuration.cursor;
|
2020-07-17 13:42:45 +00:00
|
|
|
query.uri = configuration.uri;
|
2020-04-16 14:15:45 +00:00
|
|
|
}
|
|
|
|
return this.store.query(this.getModelName(), {
|
|
|
|
...query,
|
|
|
|
});
|
|
|
|
},
|
2018-10-26 16:36:15 +00:00
|
|
|
});
|