flows: add export URL to API
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
3a64d97040
commit
4766d6ff3d
|
@ -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},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>`,
|
||||
];
|
||||
|
|
Reference in New Issue