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")
|
background = ReadOnlyField(source="background_url")
|
||||||
|
|
||||||
|
export_url = SerializerMethodField()
|
||||||
|
|
||||||
def get_cache_count(self, flow: Flow) -> int:
|
def get_cache_count(self, flow: Flow) -> int:
|
||||||
"""Get count of cached flows"""
|
"""Get count of cached flows"""
|
||||||
return len(cache.keys(f"{cache_key(flow)}*"))
|
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:
|
class Meta:
|
||||||
|
|
||||||
model = Flow
|
model = Flow
|
||||||
|
@ -65,6 +71,7 @@ class FlowSerializer(ModelSerializer):
|
||||||
"cache_count",
|
"cache_count",
|
||||||
"policy_engine_mode",
|
"policy_engine_mode",
|
||||||
"compatibility_mode",
|
"compatibility_mode",
|
||||||
|
"export_url",
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
"background": {"read_only": True},
|
"background": {"read_only": True},
|
||||||
|
|
|
@ -19372,10 +19372,14 @@ components:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Enable compatibility mode, increases compatibility with password
|
description: Enable compatibility mode, increases compatibility with password
|
||||||
managers on mobile devices.
|
managers on mobile devices.
|
||||||
|
export_url:
|
||||||
|
type: string
|
||||||
|
readOnly: true
|
||||||
required:
|
required:
|
||||||
- background
|
- background
|
||||||
- cache_count
|
- cache_count
|
||||||
- designation
|
- designation
|
||||||
|
- export_url
|
||||||
- name
|
- name
|
||||||
- pk
|
- pk
|
||||||
- policies
|
- policies
|
||||||
|
|
|
@ -103,7 +103,7 @@ export class FlowListPage extends TablePage<Flow> {
|
||||||
}}>
|
}}>
|
||||||
${t`Execute`}
|
${t`Execute`}
|
||||||
</button>
|
</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`}
|
${t`Export`}
|
||||||
</a>`,
|
</a>`,
|
||||||
];
|
];
|
||||||
|
|
Reference in New Issue