flows: add export URL to API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-10 13:52:50 +02:00
parent 3a64d97040
commit 4766d6ff3d
3 changed files with 12 additions and 1 deletions

View File

@ -45,10 +45,16 @@ class FlowSerializer(ModelSerializer):
background = ReadOnlyField(source="background_url")
export_url = SerializerMethodField()
def get_cache_count(self, flow: Flow) -> int:
"""Get count of cached flows"""
return len(cache.keys(f"{cache_key(flow)}*"))
def get_export_url(self, flow: Flow) -> str:
"""Get export URL for flow"""
return reverse("authentik_api:flow-export", kwargs={"slug": flow.slug})
class Meta:
model = Flow
@ -65,6 +71,7 @@ class FlowSerializer(ModelSerializer):
"cache_count",
"policy_engine_mode",
"compatibility_mode",
"export_url",
]
extra_kwargs = {
"background": {"read_only": True},

View File

@ -19372,10 +19372,14 @@ components:
type: boolean
description: Enable compatibility mode, increases compatibility with password
managers on mobile devices.
export_url:
type: string
readOnly: true
required:
- background
- cache_count
- designation
- export_url
- name
- pk
- policies

View File

@ -103,7 +103,7 @@ export class FlowListPage extends TablePage<Flow> {
}}>
${t`Execute`}
</button>
<a class="pf-c-button pf-m-secondary" href="/api/v2beta/flows/instances/${item.slug}/export/">
<a class="pf-c-button pf-m-secondary" href=${flow.exportUrl}>
${t`Export`}
</a>`,
];