OCI Policy Analysis UI

Tkinter UI components for OCI Policy Analysis.

SettingsTab

class oci_policy_analysis.ui.SettingsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Settings Tab for OCI Policy Analysis UI. Allows configuration of tenancy, profile, MCP server, and AI settings. All tenancy data is loaded via this tab.

_on_ai_enablement_finished(success: bool, message: str, clear: bool = False)[source]

Callback from App once AI loading completes. Used to enable AI toggle button if successful.

Parameters:
  • success (bool) – Whether the AI call was successful.

  • message (str) – Message to display.

  • clear (bool) – Whether to clear the message after a delay.

_toggle_console_tab()[source]

Toggle the visibility of the console and debug tab in the notebook.

_toggle_maintenance_tab()[source]

Toggle the visibility of the maintenance tab in the notebook.

refresh_context_help()[source]

Refresh style/visibility of Page Help label. (SettingsTab extension point)

refresh_cache_list()[source]

Update the cache list OptionMenu in the Settings tab to reflect the current state.

apply_config()[source]

Apply changes to Model ID and Endpoint in AI client.

PoliciesTab

class oci_policy_analysis.ui.PoliciesTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Tab for displaying and filtering OCI policies.

  • Supports searching and filtering by multiple criteria (OR via | character in fields).

  • Includes saved search/load, policy export, and summary displays.

  • Context help is unified and appears at the top, per app setting.

  • Provides right-click analysis and integration with other app tabs.

clear_policy_filters()[source]
export_policy_to_csv()[source]
update_policy_output(*args)[source]

Update the policy output based on current filters.

enable_widgets_after_load()[source]

Enable widgets after load.

DynamicGroupsTab

class oci_policy_analysis.ui.DynamicGroupsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Dynamic Groups Tab for OCI Policy Analysis UI.

Browse, filter, and analyze dynamic groups and related policies. Select dynamic groups to reveal matching policy statements below.

apply_settings(context_help: bool, font_size: str)[source]

Update context help and font settings (called globally from main app).

enable_controls()[source]

Called from main app when data is loaded to enable the controls

UsersTab

class oci_policy_analysis.ui.UsersTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Users Tab for OCI Policy Analysis UI. Allows selection of Groups or Users, and displays associated policy statements. Supports filtering and detailed policy statement views.

sync_load_all_users_checkbox()[source]

Ensures the checkbox/UI for load_all_users matches the repository state. Should be called after loading data/cache if UI lags behind data model.

should_show_users_option()[source]

Returns True if the USERS option should be available in the dropdown, i.e., only if load_all_users is True AND there are users loaded.

update_users_dropdown_options()[source]

Update the GROUPS/USERS dropdown menu to reflect actual repo state. Should be called after any tenancy/repo load; safe to call any time. Also forces the table below to reload for the current selection.

update_user_analysis_output()[source]

Update the user/group table based on selection and search. Called initially after load from main class and when search or selection changes.

update_user_policy_output()[source]

Update the display elements for the user analysis policy statements. Called when the selection of groups/users changes, or when the checkboxes change.

Parameters:
  • groups_for_filter (list[Group], optional) – List of groups to filter policies for. Defaults to None.

  • users_for_filter (list[User], optional) – List of users to filter policies for. Defaults to None.

on_load_all_users_setting_changed(enabled: bool)[source]

Called if settings change for Load All Users to refresh user/group options and UI. Synchronizes between UI and model: both directions.

ReportTab

class oci_policy_analysis.ui.ReportTab(*args: Any, **kwargs: Any)[source]

Bases: Frame

create_tab()[source]
update_report_output()[source]

ConsoleTab

class oci_policy_analysis.ui.ConsoleTab(*args: Any, **kwargs: Any)[source]

Bases: Frame

Console Tab: Show all logs (unfiltered) with control of log level. Debug logs go to shell only. For this reason, the level selector excludes DEBUG.

PolicyRecommendationsTab

class oci_policy_analysis.ui.PolicyRecommendationsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Unified UI tab for displaying Oracle Cloud Policy Recommendations and analytics.

This tab contains an internal notebook with subtabs for:
  • Risk assessment and scores for policy statements

  • Policy overlap analysis (potential overrides/superseding statements)

  • Consolidation opportunities

  • Policy hygiene and clean-up actions

  • Future analytics extensions

Parameters:
  • parent (tk.Widget) – The parent widget for this frame.

  • app (Any) – The main application object containing state and analysis engines.

app

The main application reference with policy and intelligence engines.

Type:

Any

policy_repo

Reference to analysis data for rendering UI.

recommendation_table

DataTable widget for summary.

notebook

ttk.Notebook for switching between analytics views.

risk_table

DataTable for risk scores.

overlap_table

DataTable for policy overlaps.

consolidation_table

CheckboxTable for consolidation findings.

cleanup_table

CheckboxTable for actionable cleanup/fix items.

reload_all_analytics()[source]
update_risk_tab_output()[source]
update_overlap_tab_output()[source]
update_consolidation_tab_output()[source]

Refresh the consolidation tab’s data after analytics reload.

update_cleanup_tab_output()[source]

Refresh the cleanup tab’s data after analytics reload.

apply_settings(context_help: bool, font_size: str)[source]

Apply context help and font size settings for the recommendations tab.

McpTab

class oci_policy_analysis.ui.McpTab(*args: Any, **kwargs: Any)[source]

Bases: Frame

MCP Tab for OCI Policy Analysis UI. Allows starting/stopping the MCP server and viewing its logs. .. method:: __init__

Initializes the McpTab with UI components and callbacks.

_start_mcp()[source]

(Internal) Starts the MCP server in a separate thread.

ResourcePrincipalsTab

class oci_policy_analysis.ui.ResourcePrincipalsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Resource Principals Tab for OCI Policy Analysis UI.

Allows viewing Dynamic Groups and associated policy statements, with contextual page help. Now inherits from BaseUITab. .. method:: __init__

Initializes the ResourcePrincipalsTab with UI components and context help.

_build_ui()[source]

(Internal) Builds the UI components for the tab.

apply_settings()[source]

Updates tab appearance and page help when global UI settings change.

update_principals_sheets()[source]

Updates sheets based on dropdown and DG selection (called from main app, or internally).

update_principals_sheets(*args)[source]

Update view: show or hide tables depending on dropdown, update data in both tables.

  • In DG mode, show both tables; in other principal modes, show only matching policy table, hiding DG table.

  • Refresh table data for all cases.

  • Text filter field applies to Matching Rule (DG) or Policy Statement (any-user modes).

apply_settings(context_help: bool, font_size: str)[source]

Update help area and style on global context help and font size change (from main.py).

MaintenanceTab

class oci_policy_analysis.ui.MaintenanceTab(*args: Any, **kwargs: Any)[source]

Bases: Frame

Maintenance Tab for OCI Policy Analysis UI. Provides cache management and permissions testing tools. .. method:: __init__

Initializes the MaintenanceTab with UI components and callbacks.

_refresh_maintenance_cache_list()[source]

(Internal) Refreshes the cache list display.

_maintenance_remove_selected_cache()[source]

(Internal) Removes the selected cache entry.

_maintenance_rename_selected_cache()[source]

(Internal) Renames the selected cache entry.

_maintenance_preserve_selected_cache()[source]

(Internal) Toggles the preserve status of the selected cache entry.

_maintenance_permissions_load_data()[source]

(Internal) Loads reference data for permissions testing.

_maintenance_get_permission()[source]

(Internal) Retrieves permissions for the selected resource/family and verb.

_maintenance_check_overlap()[source]

(Internal) Checks for overlap between two permission statements.

build_ui()[source]
refresh_data()[source]

Public method: must be called after reference data is loaded and ready. Loads or reloads all data-dependent UI elements (comboboxes, JSON viewers, permissions, etc).

DataTable

class oci_policy_analysis.ui.DataTable(*args: Any, **kwargs: Any)[source]

Bases: Frame

A Tkinter table widget with alternating row colors, sortable columns, resizable columns, show/hide columns, row selection with callback, full space utilization, cell copy functionality, and row context menu.

Note: for checklist-style tables with checkboxes and custom action button, see the more generic CheckboxTable class also defined below.

Note: ttk.Treeview does not natively support multi-line text wrapping. Text with newlines may appear clipped; use wider columns (via column_widths) for better visibility. Font, padding, and ttk.Style must be configured externally to include right-side cell padding (e.g., padding=(0, 0, 5, 0)) for column separation.

parent

The parent Tkinter widget.

columns

List of all possible column names.

display_columns

List of initially displayed column names.

data

List of dictionaries containing row data.

sortable

Enable/disable column sorting (default: True).

row_colors

Tuple of colors for alternating rows (default: white, light gray).

selection_callback

Optional function to call with selected rows (default: None). Can be omitted if no callback is needed.

multi_select

Enable/disable multi-row selection (default: False).

column_widths

Dictionary mapping column names to initial widths (default: None, uses 100 for all columns).

row_context_menu_callback

Optional function to create a context menu for a row (default: None).

set_multi_select(multi_select: bool) None[source]

Set single or multi-select mode.

set_display_columns(display_columns: list[str]) None[source]

Set the displayed columns externally.

update_data(new_data: list[dict]) None[source]

Update table data and refresh display.

Parameters:

new_data – List of dictionaries containing new row data.

apply_theme(theme: str) None[source]

Apply light or dark theme colors to the Treeview. :param theme: ‘light’ or ‘dark’

CheckboxTable

class oci_policy_analysis.ui.CheckboxTable(*args: Any, **kwargs: Any)[source]

Bases: Frame

A DataTable-based Tkinter widget for a table with a first-column checkbox and resizable columns, alternating backgrounds, and an action button.

get_checked_rows()[source]
update_data(data)[source]