Skip to content

Commit

Permalink
feat(jans-cli-tui): missing Lock Configuration parameters (#8251)
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Baser <[email protected]>
Former-commit-id: f5ba105
  • Loading branch information
devrimyatar authored Apr 9, 2024
1 parent 01d7e67 commit 4e0334d
Showing 1 changed file with 88 additions and 7 deletions.
95 changes: 88 additions & 7 deletions jans-cli-tui/cli_tui/plugins/120_lock/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from prompt_toolkit.layout import ScrollablePane
from prompt_toolkit.layout.dimension import D
from prompt_toolkit.widgets import Button
from prompt_toolkit.widgets import Button, Frame
from prompt_toolkit.application import Application
from wui_components.widget_collections import get_logging_level_widget

Expand Down Expand Up @@ -47,8 +47,35 @@ def create_widgets(self):
self.schema = self.app.cli_object.get_schema_from_reference('Lock', '#/components/schemas/AppConfiguration')


self.opa_config_base_url = common_data.app.getTitledText(
title=_("Base URL"),
name='baseUrl',
value=self.data.get('OpaConfiguration', {}).get('baseUrl', ''),
style=cli_style.edit_text,
jans_help=_("Base URL for OPA"),
widget_style=cli_style.black_bg_widget
)

self.opa_config_accessToken = common_data.app.getTitledText(
title=_("Access Token"),
name='accessToken',
value=self.data.get('OpaConfiguration', {}).get('accessToken', ''),
style=cli_style.edit_text,
jans_help=_("Access token for OPA"),
widget_style=cli_style.black_bg_widget
)

self.working_container = HSplit([

common_data.app.getTitledText(
title=_("Base DN"),
name='baseDN',
value=self.data.get('baseDN'),
style=cli_style.edit_text,
jans_help=_("Base DN"),
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledText(
title=_("Token Channels"),
name='tokenChannels',
Expand All @@ -69,6 +96,24 @@ def create_widgets(self):

get_logging_level_widget(self.data.get('loggingLevel', 'INFO')),

common_data.app.getTitledText(
title=_("Logging Layout"),
name='loggingLayout',
value=self.data.get('loggingLayout', 'text'),
style=cli_style.edit_text,
jans_help=_("Logging layout"),
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledText(
title=_("External Logger Configuration"),
name='externalLoggerConfiguration',
value=self.data.get('externalLoggerConfiguration'),
style=cli_style.edit_text,
jans_help=_("Configuration for External Logger"),
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledCheckBox(
title=_("Enable Metric Reporter"),
name='metricReporterEnabled',
Expand All @@ -87,7 +132,7 @@ def create_widgets(self):
),

common_data.app.getTitledText(
title=_("Metric Reporter KeepData Days"),
title=_("Metric Reporter Keep Data Days"),
name='metricReporterKeepDataDays',
value=self.data.get('metricReporterKeepDataDays', '15'),
style=cli_style.edit_text,
Expand All @@ -104,6 +149,11 @@ def create_widgets(self):
text_type='integer'
),

Frame(
title=_("Opa Configuration"),
body=HSplit([self.opa_config_base_url, self.opa_config_accessToken]),
),

common_data.app.getTitledText(
title=_("Message Consumer Type"),
name='messageConsumerType',
Expand All @@ -121,12 +171,41 @@ def create_widgets(self):
),

common_data.app.getTitledText(
title=_("OPA Base URL"),
name='opaConfiguration_baseUrl',
value=self.data.get('opaConfiguration', {}).get('baseUrl', ''),
title=_("Policies JSON URIs Access Token"),
name='policiesJsonUrisAccessToken',
value=self.data.get('policiesJsonUrisAccessToken', ''),
style=cli_style.edit_text,
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledText(
title=_("Policies JSON URIs"),
name='policiesJsonUris',
value=' '.join(self.data.get('policiesJsonUris', [])),
style=cli_style.edit_text,
jans_help=_("Space seperated policies JSON URIs"),
jans_list_type=True,
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledText(
title=_("Policies Zip URIs Access Token"),
name='policiesZipUrisAccessToken',
value=self.data.get('policiesZipUrisAccessToken', ''),
style=cli_style.edit_text,
widget_style=cli_style.black_bg_widget
),

common_data.app.getTitledText(
title=_("Policies Zip URIs"),
name='policiesZipUris',
value=' '.join(self.data.get('policiesZipUris', [])),
style=cli_style.edit_text,
jans_help=_("Space seperated policies Zip URIs"),
jans_list_type=True,
widget_style=cli_style.black_bg_widget
),

Window(height=1),
VSplit([Button(text=_("Save"), handler=self.save)], align=HorizontalAlign.CENTER)

Expand Down Expand Up @@ -163,8 +242,10 @@ def save(self):

async def lock_config_coroutine():
lock_config = self.make_data_from_dialog(tabs={'lock_config': self.working_container})
lock_config['opaConfiguration'] = {'baseUrl': lock_config.pop('opaConfiguration_baseUrl')}
lock_config['loggingLayout'] = 'text'
lock_config['opaConfiguration'] = {
'baseUrl': self.opa_config_base_url.me.text,
'accessToken': self.opa_config_accessToken.me.text,
}

cli_args = {'operation_id': 'put-lock-properties', 'data': lock_config}
common_data.app.start_progressing(_("Saving Lock configuration"))
Expand Down

0 comments on commit 4e0334d

Please sign in to comment.