import { AdminApi, EventMatcherPolicy, EventsApi, PoliciesApi } from "authentik-api"; import { t } from "@lingui/macro"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../../api/Config"; import { Form } from "../../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/FormGroup"; import { until } from "lit-html/directives/until"; @customElement("ak-policy-event-matcher-form") export class EventMatcherPolicyForm extends Form { set policyUUID(value: string) { new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherRead({ policyUuid: value, }).then(policy => { this.policy = policy; }); } @property({attribute: false}) policy?: EventMatcherPolicy; getSuccessMessage(): string { if (this.policy) { return t`Successfully updated policy.`; } else { return t`Successfully created policy.`; } } send = (data: EventMatcherPolicy): Promise => { if (this.policy) { return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherUpdate({ policyUuid: this.policy.pk || "", data: data }); } else { return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherCreate({ data: data }); } }; renderForm(): TemplateResult { return html`

${t`When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.`}

${t`Policy-specific settings`}

${t`Match created events with this action type. When left empty, all action types will be matched.`}

${t`Matches Event's Client IP (strict matching, for network matching use an Expression Policy.`}

${t`Match events created by selected application. When left empty, all applications are matched.`}

`; } }