

# global_settings_manager

`config.global_settings_manager`

Centralized Global Settings Management for nova_fde

This module provides functionality for managing global database settings that can be shared across multiple projects to reduce duplication.

## Classes

| Name | Description |
|----|----|
| [GlobalSettingsManager](#nova_fde.config.global_settings_manager.GlobalSettingsManager) | Manages global settings across projects using nova_fde. |

### GlobalSettingsManager

``` python
config.global_settings_manager.GlobalSettingsManager(self, settings_path=None)
```

Manages global settings across projects using nova_fde.

This class provides functionality to store and retrieve database settings, project templates, and other configuration that should be shared across multiple projects.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| settings_path | str or Path | Path to global settings file. If not provided, default locations are searched. | `None` |

#### Attributes

| Name | Type | Description |
|----|----|----|
| DEFAULT_SETTINGS_PATHS | list | List of default paths to search for global settings in order of preference. |
| settings_path | Path | Path to the global settings file. |
| \_settings | dict | Cached settings data. |

#### Notes

Global settings are stored in YAML or JSON format in one of the following locations by default (in order of preference): - ~/.nova_fde/settings.yaml - ~/.config/nova_fde/settings.yaml - ~/.nova_fde/settings.json - ~/.config/nova_fde/settings.json

#### Methods

| Name | Description |
|----|----|
| [check_password_expiration](#nova_fde.config.global_settings_manager.GlobalSettingsManager.check_password_expiration) | Check password expiration status. |
| [create_template_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.create_template_settings) | Create a template settings file with database connection information. |
| [get_db_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.get_db_settings) | Get database-specific settings. |
| [get_password_meta](#nova_fde.config.global_settings_manager.GlobalSettingsManager.get_password_meta) | Get password metadata for expiration tracking. |
| [get_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.get_settings) | Get the global settings. |
| [load_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.load_settings) | Load settings from the global settings file. |
| [save_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.save_settings) | Save settings to the global settings file. |
| [update_db_settings](#nova_fde.config.global_settings_manager.GlobalSettingsManager.update_db_settings) | Update database settings in the global settings file. |
| [update_password_meta](#nova_fde.config.global_settings_manager.GlobalSettingsManager.update_password_meta) | Update password metadata when password is changed. |

##### check_password_expiration

``` python
config.global_settings_manager.GlobalSettingsManager.check_password_expiration()
```

Check password expiration status.

###### Returns

| Name | Type | Description |
|----|----|----|
|  | Dict\[str, Any\] | Dictionary containing password expiration information including: - status: ‘expired’, ‘warning’, or ‘ok’ - days_remaining: Number of days until expiration - expiry_date: Date of expiration - last_updated: Date when password was last updated |

##### create_template_settings

``` python
config.global_settings_manager.GlobalSettingsManager.create_template_settings(
    db_host,
    db_port,
    db_name,
    expiry_days=90,
    reminder_days=14,
)
```

Create a template settings file with database connection information.

###### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| db_host | str | Database host name or IP address | *required* |
| db_port | int | Database port | *required* |
| db_name | str | Database name | *required* |
| expiry_days | int | Number of days before password expires, by default 90 | `90` |
| reminder_days | int | Number of days before expiration to start reminders, by default 14 | `14` |

###### Returns

| Name | Type | Description                                                |
|------|------|------------------------------------------------------------|
|      | bool | True if template was created successfully, False otherwise |

##### get_db_settings

``` python
config.global_settings_manager.GlobalSettingsManager.get_db_settings()
```

Get database-specific settings.

###### Returns

| Name | Type             | Description                              |
|------|------------------|------------------------------------------|
|      | Dict\[str, Any\] | Dictionary containing database settings. |

##### get_password_meta

``` python
config.global_settings_manager.GlobalSettingsManager.get_password_meta()
```

Get password metadata for expiration tracking.

###### Returns

| Name | Type | Description |
|----|----|----|
|  | Dict\[str, Any\] | Dictionary containing password metadata including last update date and expiry policy. |

##### get_settings

``` python
config.global_settings_manager.GlobalSettingsManager.get_settings()
```

Get the global settings.

###### Returns

| Name | Type             | Description                            |
|------|------------------|----------------------------------------|
|      | Dict\[str, Any\] | Dictionary containing global settings. |

##### load_settings

``` python
config.global_settings_manager.GlobalSettingsManager.load_settings()
```

Load settings from the global settings file.

###### Returns

| Name | Type | Description                                                 |
|------|------|-------------------------------------------------------------|
|      | bool | True if settings were loaded successfully, False otherwise. |

##### save_settings

``` python
config.global_settings_manager.GlobalSettingsManager.save_settings(settings)
```

Save settings to the global settings file.

###### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| settings | Dict\[str, Any\] | Dictionary containing settings to save. | *required* |

###### Returns

| Name | Type | Description                                                |
|------|------|------------------------------------------------------------|
|      | bool | True if settings were saved successfully, False otherwise. |

##### update_db_settings

``` python
config.global_settings_manager.GlobalSettingsManager.update_db_settings(
    db_settings,
)
```

Update database settings in the global settings file.

###### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| db_settings | Dict\[str, Any\] | Dictionary containing database settings to update. | *required* |

###### Returns

| Name | Type | Description                                                  |
|------|------|--------------------------------------------------------------|
|      | bool | True if settings were updated successfully, False otherwise. |

##### update_password_meta

``` python
config.global_settings_manager.GlobalSettingsManager.update_password_meta(
    username=None,
)
```

Update password metadata when password is changed.

###### Parameters

| Name     | Type | Description                          | Default |
|----------|------|--------------------------------------|---------|
| username | str  | Username whose password was updated. | `None`  |

###### Returns

| Name | Type | Description                                                 |
|------|------|-------------------------------------------------------------|
|      | bool | True if metadata was updated successfully, False otherwise. |

## Functions

| Name | Description |
|----|----|
| [create_calendar_reminder](#nova_fde.config.global_settings_manager.create_calendar_reminder) | Create a calendar reminder file for password rotation. |

### create_calendar_reminder

``` python
config.global_settings_manager.create_calendar_reminder(
    password_meta,
    output_path=None,
)
```

Create a calendar reminder file for password rotation.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| password_meta | Dict\[str, Any\] | Password metadata containing expiration information | *required* |
| output_path | str | Path to save the calendar file to. If not provided, saves to user’s home directory. | `None` |

#### Returns

| Name | Type | Description                       |
|------|------|-----------------------------------|
|      | str  | Path to the created calendar file |

#### Notes

Creates an .ics file that can be imported into calendar applications like Outlook, Google Calendar, or Apple Calendar.
