2020-09-18 10:14:06 +00:00
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
import { fragmentArray, array } from 'ember-data-model-fragments/attributes';
|
2020-11-09 17:29:12 +00:00
|
|
|
import { attr } from '@ember-data/model';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { or } from '@ember/object/computed';
|
2020-09-18 10:14:06 +00:00
|
|
|
|
2020-09-30 11:33:01 +00:00
|
|
|
export const schema = {
|
|
|
|
PathType: {
|
|
|
|
allowedValues: ['PathPrefix', 'PathExact', 'PathRegex'],
|
|
|
|
},
|
|
|
|
Methods: {
|
|
|
|
allowedValues: ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
export default class IntentionPermissionHttp extends Fragment {
|
|
|
|
@attr('string') PathExact;
|
|
|
|
@attr('string') PathPrefix;
|
|
|
|
@attr('string') PathRegex;
|
|
|
|
|
|
|
|
@fragmentArray('intention-permission-http-header') Header;
|
|
|
|
@array('string') Methods;
|
2020-09-18 10:14:06 +00:00
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
@or(...schema.PathType.allowedValues) Path;
|
2020-09-18 10:14:06 +00:00
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
@computed(...schema.PathType.allowedValues)
|
|
|
|
get PathType() {
|
2020-09-30 11:33:01 +00:00
|
|
|
return schema.PathType.allowedValues.find(prop => typeof this[prop] === 'string');
|
2020-11-09 17:29:12 +00:00
|
|
|
}
|
|
|
|
}
|