2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
import { attr } from '@ember-data/model';
|
2020-09-30 11:33:01 +00:00
|
|
|
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 = {
|
|
|
|
Name: {
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
HeaderType: {
|
|
|
|
allowedValues: ['Exact', 'Prefix', 'Suffix', 'Regex', 'Present'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
export default class IntentionPermission extends Fragment {
|
|
|
|
@attr('string') Name;
|
|
|
|
|
|
|
|
@attr('string') Exact;
|
|
|
|
@attr('string') Prefix;
|
|
|
|
@attr('string') Suffix;
|
|
|
|
@attr('string') Regex;
|
|
|
|
// this is a boolean but we don't want it to automatically be set to false
|
|
|
|
@attr() Present;
|
2020-09-18 10:14:06 +00:00
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
@or(...schema.HeaderType.allowedValues) Value;
|
2020-09-30 11:33:01 +00:00
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
@computed(...schema.HeaderType.allowedValues)
|
|
|
|
get HeaderType() {
|
2022-09-15 08:43:17 +00:00
|
|
|
return schema.HeaderType.allowedValues.find((prop) => typeof this[prop] !== 'undefined');
|
2020-11-09 17:29:12 +00:00
|
|
|
}
|
|
|
|
}
|