import { KubernetesServiceConnection, OutpostsApi } 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/CodeMirror"; import YAML from "yaml"; import { first } from "../../utils"; @customElement("ak-service-connection-kubernetes-form") export class ServiceConnectionKubernetesForm extends Form { set scUUID(value: string) { new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsKubernetesRead({ uuid: value, }).then(sc => { this.sc = sc; }); } @property({attribute: false}) sc?: KubernetesServiceConnection; getSuccessMessage(): string { if (this.sc) { return t`Successfully updated service-connection.`; } else { return t`Successfully created service-connection.`; } } send = (data: KubernetesServiceConnection): Promise => { if (this.sc) { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsKubernetesUpdate({ uuid: this.sc.pk || "", data: data }); } else { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsKubernetesCreate({ data: data }); } }; renderForm(): TemplateResult { return html`

${t`If enabled, use the local connection. Required Docker socket/Kubernetes Integration.`}

${t`Set custom attributes using YAML or JSON.`}

`; } }