nui-python-shared-utils 1.3.0__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.github/workflows/ci.yml +6 -5
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.github/workflows/publish.yml +1 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.github/workflows/test.yml +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/CLAUDE.md +8 -8
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/CONTRIBUTING.md +9 -9
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/MANIFEST.in +2 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/PKG-INFO +12 -12
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/README.md +11 -11
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/development/testing.md +12 -12
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/getting-started/configuration.md +6 -6
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/getting-started/installation.md +2 -2
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/getting-started/quickstart.md +10 -10
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/cli-tools.md +1 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/elasticsearch-integration.md +8 -8
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/jwt-authentication.md +2 -2
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/lambda-utilities.md +7 -7
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/log-processing.md +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/powertools-integration.md +9 -9
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/shared-types.md +17 -17
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/guides/slack-integration.md +12 -12
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/__init__.py +25 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/base_client.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/cli.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/cloudwatch_metrics.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/config.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/db_client.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/error_handler.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/es_client.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/es_query_builder.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/jwt_auth.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/lambda_helpers.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/log_processors.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/powertools_helpers.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/secrets_helper.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_client.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_formatter.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_setup/__init__.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_setup/channel_creator.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_setup/channel_definitions.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/slack_setup/setup_helpers.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/timezone.py +2 -0
- nui_python_shared_utils-1.3.2/nui_lambda_shared_utils/utils.py +2 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/nui_python_shared_utils.egg-info/SOURCES.txt +22 -1
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/es_client.py +4 -4
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/lambda_helpers.py +1 -1
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/secrets_helper.py +17 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/pyproject.toml +4 -4
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/setup.py +1 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_aws_utils.py +7 -7
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_base_client.py +88 -88
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_cloudwatch_metrics.py +28 -28
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_config.py +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_db_client.py +29 -29
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_error_handler.py +2 -2
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_es_client.py +73 -62
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_es_query_builder.py +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_jwt_auth.py +1 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_lambda_helpers.py +19 -19
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_log_processors.py +1 -1
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_powertools_helpers.py +38 -38
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_secrets_helper.py +41 -4
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_slack_client.py +100 -100
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_slack_formatter.py +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_timezone.py +3 -3
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/test_utils.py +12 -12
- nui_python_shared_utils-1.3.0/CHANGELOG.md +0 -122
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.editorconfig +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.markdownlint-cli2.yaml +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/LICENSE +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/README.md +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/mypy.ini +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/__init__.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/base_client.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/cli.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/cloudwatch_metrics.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/config.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/db_client.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/error_handler.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/es_query_builder.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/jwt_auth.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/log_processors.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/powertools_helpers.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_client.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_formatter.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_setup/__init__.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_setup/channel_creator.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_setup/channel_definitions.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/slack_setup/setup_helpers.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/timezone.py +0 -0
- {nui_python_shared_utils-1.3.0/nui_lambda_shared_utils → nui_python_shared_utils-1.3.2/nui_shared_utils}/utils.py +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/pytest.ini +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/redirect/README.md +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/redirect/pyproject.toml +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/redirect/setup.py +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/requirements-test.txt +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/setup.cfg +0 -0
- {nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/tests/__init__.py +0 -0
|
@@ -44,7 +44,7 @@ jobs:
|
|
|
44
44
|
|
|
45
45
|
- name: Auto-format with black
|
|
46
46
|
run: |
|
|
47
|
-
black
|
|
47
|
+
black nui_shared_utils tests
|
|
48
48
|
if ! git diff --quiet; then
|
|
49
49
|
echo "::warning::Code was auto-formatted by Black"
|
|
50
50
|
git config --local user.email "action@github.com"
|
|
@@ -57,12 +57,12 @@ jobs:
|
|
|
57
57
|
|
|
58
58
|
- name: Type check with mypy
|
|
59
59
|
run: |
|
|
60
|
-
mypy
|
|
60
|
+
mypy nui_shared_utils --ignore-missing-imports
|
|
61
61
|
continue-on-error: true # Don't fail CI on type errors yet
|
|
62
62
|
|
|
63
63
|
- name: Test with pytest
|
|
64
64
|
run: |
|
|
65
|
-
pytest --cov=
|
|
65
|
+
pytest --cov=nui_shared_utils --cov-report=xml --cov-report=term-missing -v
|
|
66
66
|
|
|
67
67
|
- name: Upload coverage to Codecov
|
|
68
68
|
uses: codecov/codecov-action@v3
|
|
@@ -104,5 +104,6 @@ jobs:
|
|
|
104
104
|
- name: Test installation
|
|
105
105
|
run: |
|
|
106
106
|
pip install dist/*.whl
|
|
107
|
-
python -c "import
|
|
108
|
-
python -c "from
|
|
107
|
+
python -c "import nui_shared_utils; print('✅ Package imports successfully')"
|
|
108
|
+
python -c "from nui_shared_utils import Config, get_secret; print('✅ Core imports work')"
|
|
109
|
+
python -W ignore::DeprecationWarning -c "import nui_lambda_shared_utils; print('✅ Backwards-compat shim works')"
|
{nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/.github/workflows/publish.yml
RENAMED
|
@@ -38,7 +38,7 @@ jobs:
|
|
|
38
38
|
|
|
39
39
|
- name: Run tests
|
|
40
40
|
run: |
|
|
41
|
-
pytest --cov=
|
|
41
|
+
pytest --cov=nui_shared_utils --cov-report=xml --cov-report=term-missing
|
|
42
42
|
|
|
43
43
|
- name: Upload coverage to Codecov
|
|
44
44
|
uses: codecov/codecov-action@v3
|
|
@@ -29,8 +29,8 @@ jobs:
|
|
|
29
29
|
|
|
30
30
|
- name: Check formatting with black
|
|
31
31
|
run: |
|
|
32
|
-
black --check --diff
|
|
33
|
-
echo "::warning::Code formatting issues found - run 'black
|
|
32
|
+
black --check --diff nui_shared_utils tests || {
|
|
33
|
+
echo "::warning::Code formatting issues found - run 'black nui_shared_utils tests' locally"
|
|
34
34
|
echo "Continuing build despite formatting issues..."
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -41,4 +41,4 @@ jobs:
|
|
|
41
41
|
|
|
42
42
|
- name: Test with pytest
|
|
43
43
|
run: |
|
|
44
|
-
pytest --cov=
|
|
44
|
+
pytest --cov=nui_shared_utils --cov-report=xml
|
|
@@ -129,7 +129,7 @@ source venv/bin/activate # Linux/Mac
|
|
|
129
129
|
pytest
|
|
130
130
|
|
|
131
131
|
# Run with coverage reporting
|
|
132
|
-
pytest --cov=
|
|
132
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
133
133
|
|
|
134
134
|
# Run only unit tests (skip integration tests requiring AWS)
|
|
135
135
|
pytest -m "not integration"
|
|
@@ -147,16 +147,16 @@ pytest tests/test_slack_client.py -v
|
|
|
147
147
|
|
|
148
148
|
```bash
|
|
149
149
|
# Format code with Black (line length: 120)
|
|
150
|
-
black
|
|
150
|
+
black nui_shared_utils/ tests/
|
|
151
151
|
|
|
152
152
|
# Check formatting without changes
|
|
153
|
-
black --check
|
|
153
|
+
black --check nui_shared_utils/
|
|
154
154
|
|
|
155
155
|
# Type checking with MyPy
|
|
156
|
-
mypy
|
|
156
|
+
mypy nui_shared_utils/ --config-file mypy.ini
|
|
157
157
|
|
|
158
158
|
# Run linting (currently configured to use Black)
|
|
159
|
-
black --check
|
|
159
|
+
black --check nui_shared_utils/
|
|
160
160
|
|
|
161
161
|
# Lint markdown documentation
|
|
162
162
|
npx markdownlint-cli2 '**/*.md'
|
|
@@ -227,7 +227,7 @@ Secrets should follow standardized JSON structures:
|
|
|
227
227
|
### Programmatic Configuration
|
|
228
228
|
|
|
229
229
|
```python
|
|
230
|
-
import
|
|
230
|
+
import nui_shared_utils as nui
|
|
231
231
|
|
|
232
232
|
# Pass credentials directly (no Secrets Manager needed)
|
|
233
233
|
slack = nui.SlackClient(credentials={"bot_token": "xoxb-..."})
|
|
@@ -253,7 +253,7 @@ For detailed usage examples and integration patterns, see:
|
|
|
253
253
|
|
|
254
254
|
```python
|
|
255
255
|
# See docs/getting-started/quickstart.md for complete examples
|
|
256
|
-
from
|
|
256
|
+
from nui_shared_utils import SlackClient, MetricsPublisher, with_retry
|
|
257
257
|
|
|
258
258
|
# Slack messaging with rich formatting
|
|
259
259
|
slack = SlackClient()
|
|
@@ -299,7 +299,7 @@ Before submitting PRs, ensure:
|
|
|
299
299
|
- [ ] **No hardcoded organization-specific values** (service names, currencies, business logic)
|
|
300
300
|
- [ ] **Configuration options** provided for any defaults
|
|
301
301
|
- [ ] **Tests pass** with `pytest --cov`
|
|
302
|
-
- [ ] **Code formatted** with Black (`black
|
|
302
|
+
- [ ] **Code formatted** with Black (`black nui_shared_utils/ tests/`)
|
|
303
303
|
- [ ] **Type hints** included for public APIs
|
|
304
304
|
- [ ] **Documentation updated** in docs/ for new features
|
|
305
305
|
- [ ] **Generic naming** - avoid organization-specific terminology in public APIs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Contributing to NUI
|
|
1
|
+
# Contributing to NUI Python Shared Utilities
|
|
2
2
|
|
|
3
|
-
We welcome contributions to the NUI
|
|
3
|
+
We welcome contributions to the NUI Python Shared Utilities project! This document provides guidelines for contributing.
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -16,8 +16,8 @@ We welcome contributions to the NUI Lambda Shared Utilities project! This docume
|
|
|
16
16
|
2. Clone your fork locally:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
git clone https://github.com/your-username/nui-
|
|
20
|
-
cd nui-
|
|
19
|
+
git clone https://github.com/your-username/nui-python-shared-utils.git
|
|
20
|
+
cd nui-python-shared-utils
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
3. Create a virtual environment:
|
|
@@ -42,7 +42,7 @@ We welcome contributions to the NUI Lambda Shared Utilities project! This docume
|
|
|
42
42
|
pytest
|
|
43
43
|
|
|
44
44
|
# Run tests with coverage
|
|
45
|
-
pytest --cov=
|
|
45
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
46
46
|
|
|
47
47
|
# Run specific test categories
|
|
48
48
|
pytest -m unit # Unit tests only
|
|
@@ -55,10 +55,10 @@ We use several tools to maintain code quality:
|
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
# Format code
|
|
58
|
-
black
|
|
58
|
+
black nui_shared_utils tests
|
|
59
59
|
|
|
60
60
|
# Type checking
|
|
61
|
-
mypy
|
|
61
|
+
mypy nui_shared_utils
|
|
62
62
|
|
|
63
63
|
# Run all quality checks
|
|
64
64
|
make lint # If Makefile exists
|
|
@@ -129,7 +129,7 @@ Examples:
|
|
|
129
129
|
|
|
130
130
|
When adding new utilities to the package:
|
|
131
131
|
|
|
132
|
-
1. **Create the module** in the `
|
|
132
|
+
1. **Create the module** in the `nui_shared_utils/` directory
|
|
133
133
|
2. **Add comprehensive tests** in the `tests/` directory
|
|
134
134
|
3. **Update `__init__.py`** to export new functions/classes
|
|
135
135
|
4. **Update documentation** with usage examples
|
|
@@ -139,7 +139,7 @@ When adding new utilities to the package:
|
|
|
139
139
|
### Example New Utility Structure
|
|
140
140
|
|
|
141
141
|
```python
|
|
142
|
-
#
|
|
142
|
+
# nui_shared_utils/my_utility.py
|
|
143
143
|
"""
|
|
144
144
|
My utility for doing something useful.
|
|
145
145
|
"""
|
|
@@ -4,8 +4,9 @@ include README.md
|
|
|
4
4
|
include CHANGELOG.md
|
|
5
5
|
|
|
6
6
|
# Include package data
|
|
7
|
+
recursive-include nui_shared_utils *.py
|
|
8
|
+
recursive-include nui_shared_utils/slack_setup *.yaml
|
|
7
9
|
recursive-include nui_lambda_shared_utils *.py
|
|
8
|
-
recursive-include nui_lambda_shared_utils/slack_setup *.yaml
|
|
9
10
|
|
|
10
11
|
# Exclude development and build files
|
|
11
12
|
exclude .gitignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nui-python-shared-utils
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Shared Python utilities for AWS Lambda, CLI tools, and agents with Slack, Elasticsearch, and monitoring integrations
|
|
5
5
|
Home-page: https://github.com/nuimarkets/nui-python-shared-utils
|
|
6
6
|
Author: NUI Markets
|
|
@@ -169,7 +169,7 @@ pip install nui-python-shared-utils[jwt] # JWT authentication only
|
|
|
169
169
|
### Basic Configuration
|
|
170
170
|
|
|
171
171
|
```python
|
|
172
|
-
import
|
|
172
|
+
import nui_shared_utils as nui
|
|
173
173
|
|
|
174
174
|
# Configure for your environment (optional - uses sensible defaults)
|
|
175
175
|
nui.configure(
|
|
@@ -205,7 +205,7 @@ Below are minimal examples to get you started. **For complete examples and detai
|
|
|
205
205
|
### Secrets Management
|
|
206
206
|
|
|
207
207
|
```python
|
|
208
|
-
from
|
|
208
|
+
from nui_shared_utils import get_secret, get_slack_credentials
|
|
209
209
|
|
|
210
210
|
# Generic secret retrieval
|
|
211
211
|
api_keys = get_secret("my-service/api-keys")
|
|
@@ -219,7 +219,7 @@ slack_creds = get_slack_credentials() # Uses configured secret name
|
|
|
219
219
|
### AWS Powertools Integration
|
|
220
220
|
|
|
221
221
|
```python
|
|
222
|
-
from
|
|
222
|
+
from nui_shared_utils import get_powertools_logger, powertools_handler
|
|
223
223
|
|
|
224
224
|
# Create logger with Elasticsearch-compatible formatting
|
|
225
225
|
logger = get_powertools_logger("my-service", level="INFO")
|
|
@@ -249,7 +249,7 @@ def lambda_handler(event, context):
|
|
|
249
249
|
### Slack Integration
|
|
250
250
|
|
|
251
251
|
```python
|
|
252
|
-
from
|
|
252
|
+
from nui_shared_utils import SlackClient, SlackBlockBuilder
|
|
253
253
|
|
|
254
254
|
slack = SlackClient()
|
|
255
255
|
|
|
@@ -267,7 +267,7 @@ slack.send_message(channel='#incidents', blocks=blocks)
|
|
|
267
267
|
### Elasticsearch Operations
|
|
268
268
|
|
|
269
269
|
```python
|
|
270
|
-
from
|
|
270
|
+
from nui_shared_utils import ElasticsearchClient, ESQueryBuilder
|
|
271
271
|
|
|
272
272
|
es = ElasticsearchClient()
|
|
273
273
|
query_builder = ESQueryBuilder()
|
|
@@ -280,7 +280,7 @@ results = es.search(index="logs-*", body={"query": query})
|
|
|
280
280
|
### Database Connections
|
|
281
281
|
|
|
282
282
|
```python
|
|
283
|
-
from
|
|
283
|
+
from nui_shared_utils import DatabaseClient
|
|
284
284
|
|
|
285
285
|
db = DatabaseClient()
|
|
286
286
|
|
|
@@ -294,7 +294,7 @@ async with db.get_connection() as conn:
|
|
|
294
294
|
### CloudWatch Metrics
|
|
295
295
|
|
|
296
296
|
```python
|
|
297
|
-
from
|
|
297
|
+
from nui_shared_utils import MetricsPublisher, track_lambda_performance
|
|
298
298
|
|
|
299
299
|
metrics = MetricsPublisher(namespace="MyApplication")
|
|
300
300
|
|
|
@@ -309,7 +309,7 @@ def lambda_handler(event, context):
|
|
|
309
309
|
### JWT Authentication
|
|
310
310
|
|
|
311
311
|
```python
|
|
312
|
-
from
|
|
312
|
+
from nui_shared_utils import require_auth, AuthenticationError
|
|
313
313
|
|
|
314
314
|
def lambda_handler(event, context):
|
|
315
315
|
try:
|
|
@@ -326,7 +326,7 @@ def lambda_handler(event, context):
|
|
|
326
326
|
### Error Handling
|
|
327
327
|
|
|
328
328
|
```python
|
|
329
|
-
from
|
|
329
|
+
from nui_shared_utils import with_retry, handle_lambda_error
|
|
330
330
|
|
|
331
331
|
@handle_lambda_error
|
|
332
332
|
@with_retry(max_attempts=3)
|
|
@@ -354,7 +354,7 @@ AWS_REGION=us-east-1 # AWS region
|
|
|
354
354
|
### Programmatic Configuration
|
|
355
355
|
|
|
356
356
|
```python
|
|
357
|
-
import
|
|
357
|
+
import nui_shared_utils as nui
|
|
358
358
|
|
|
359
359
|
nui.configure(
|
|
360
360
|
es_host="localhost:9200",
|
|
@@ -398,7 +398,7 @@ pip install nui-python-shared-utils[dev]
|
|
|
398
398
|
pytest
|
|
399
399
|
|
|
400
400
|
# Run with coverage
|
|
401
|
-
pytest --cov=
|
|
401
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
402
402
|
|
|
403
403
|
# Run specific test categories
|
|
404
404
|
pytest -m unit # Unit tests only
|
|
@@ -76,7 +76,7 @@ pip install nui-python-shared-utils[jwt] # JWT authentication only
|
|
|
76
76
|
### Basic Configuration
|
|
77
77
|
|
|
78
78
|
```python
|
|
79
|
-
import
|
|
79
|
+
import nui_shared_utils as nui
|
|
80
80
|
|
|
81
81
|
# Configure for your environment (optional - uses sensible defaults)
|
|
82
82
|
nui.configure(
|
|
@@ -112,7 +112,7 @@ Below are minimal examples to get you started. **For complete examples and detai
|
|
|
112
112
|
### Secrets Management
|
|
113
113
|
|
|
114
114
|
```python
|
|
115
|
-
from
|
|
115
|
+
from nui_shared_utils import get_secret, get_slack_credentials
|
|
116
116
|
|
|
117
117
|
# Generic secret retrieval
|
|
118
118
|
api_keys = get_secret("my-service/api-keys")
|
|
@@ -126,7 +126,7 @@ slack_creds = get_slack_credentials() # Uses configured secret name
|
|
|
126
126
|
### AWS Powertools Integration
|
|
127
127
|
|
|
128
128
|
```python
|
|
129
|
-
from
|
|
129
|
+
from nui_shared_utils import get_powertools_logger, powertools_handler
|
|
130
130
|
|
|
131
131
|
# Create logger with Elasticsearch-compatible formatting
|
|
132
132
|
logger = get_powertools_logger("my-service", level="INFO")
|
|
@@ -156,7 +156,7 @@ def lambda_handler(event, context):
|
|
|
156
156
|
### Slack Integration
|
|
157
157
|
|
|
158
158
|
```python
|
|
159
|
-
from
|
|
159
|
+
from nui_shared_utils import SlackClient, SlackBlockBuilder
|
|
160
160
|
|
|
161
161
|
slack = SlackClient()
|
|
162
162
|
|
|
@@ -174,7 +174,7 @@ slack.send_message(channel='#incidents', blocks=blocks)
|
|
|
174
174
|
### Elasticsearch Operations
|
|
175
175
|
|
|
176
176
|
```python
|
|
177
|
-
from
|
|
177
|
+
from nui_shared_utils import ElasticsearchClient, ESQueryBuilder
|
|
178
178
|
|
|
179
179
|
es = ElasticsearchClient()
|
|
180
180
|
query_builder = ESQueryBuilder()
|
|
@@ -187,7 +187,7 @@ results = es.search(index="logs-*", body={"query": query})
|
|
|
187
187
|
### Database Connections
|
|
188
188
|
|
|
189
189
|
```python
|
|
190
|
-
from
|
|
190
|
+
from nui_shared_utils import DatabaseClient
|
|
191
191
|
|
|
192
192
|
db = DatabaseClient()
|
|
193
193
|
|
|
@@ -201,7 +201,7 @@ async with db.get_connection() as conn:
|
|
|
201
201
|
### CloudWatch Metrics
|
|
202
202
|
|
|
203
203
|
```python
|
|
204
|
-
from
|
|
204
|
+
from nui_shared_utils import MetricsPublisher, track_lambda_performance
|
|
205
205
|
|
|
206
206
|
metrics = MetricsPublisher(namespace="MyApplication")
|
|
207
207
|
|
|
@@ -216,7 +216,7 @@ def lambda_handler(event, context):
|
|
|
216
216
|
### JWT Authentication
|
|
217
217
|
|
|
218
218
|
```python
|
|
219
|
-
from
|
|
219
|
+
from nui_shared_utils import require_auth, AuthenticationError
|
|
220
220
|
|
|
221
221
|
def lambda_handler(event, context):
|
|
222
222
|
try:
|
|
@@ -233,7 +233,7 @@ def lambda_handler(event, context):
|
|
|
233
233
|
### Error Handling
|
|
234
234
|
|
|
235
235
|
```python
|
|
236
|
-
from
|
|
236
|
+
from nui_shared_utils import with_retry, handle_lambda_error
|
|
237
237
|
|
|
238
238
|
@handle_lambda_error
|
|
239
239
|
@with_retry(max_attempts=3)
|
|
@@ -261,7 +261,7 @@ AWS_REGION=us-east-1 # AWS region
|
|
|
261
261
|
### Programmatic Configuration
|
|
262
262
|
|
|
263
263
|
```python
|
|
264
|
-
import
|
|
264
|
+
import nui_shared_utils as nui
|
|
265
265
|
|
|
266
266
|
nui.configure(
|
|
267
267
|
es_host="localhost:9200",
|
|
@@ -305,7 +305,7 @@ pip install nui-python-shared-utils[dev]
|
|
|
305
305
|
pytest
|
|
306
306
|
|
|
307
307
|
# Run with coverage
|
|
308
|
-
pytest --cov=
|
|
308
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
309
309
|
|
|
310
310
|
# Run specific test categories
|
|
311
311
|
pytest -m unit # Unit tests only
|
|
@@ -15,7 +15,7 @@ The package uses `pytest` as the testing framework with comprehensive test cover
|
|
|
15
15
|
pytest
|
|
16
16
|
|
|
17
17
|
# Run with coverage report
|
|
18
|
-
pytest --cov=
|
|
18
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
19
19
|
|
|
20
20
|
# Run specific test categories
|
|
21
21
|
pytest -m unit # Unit tests only
|
|
@@ -126,17 +126,17 @@ pytest -k "slack" # All tests with "slack" in name
|
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
128
|
# Terminal coverage report
|
|
129
|
-
pytest --cov=
|
|
129
|
+
pytest --cov=nui_shared_utils
|
|
130
130
|
|
|
131
131
|
# HTML coverage report
|
|
132
|
-
pytest --cov=
|
|
132
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
133
133
|
# Opens in: htmlcov/index.html
|
|
134
134
|
|
|
135
135
|
# Coverage with missing lines
|
|
136
|
-
pytest --cov=
|
|
136
|
+
pytest --cov=nui_shared_utils --cov-report=term-missing
|
|
137
137
|
|
|
138
138
|
# Fail if coverage below threshold
|
|
139
|
-
pytest --cov=
|
|
139
|
+
pytest --cov=nui_shared_utils --cov-fail-under=90
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
### Filtering Tests
|
|
@@ -179,7 +179,7 @@ def mock_secrets():
|
|
|
179
179
|
|
|
180
180
|
def test_with_mock_secrets(mock_secrets):
|
|
181
181
|
"""Test using mocked secrets."""
|
|
182
|
-
from
|
|
182
|
+
from nui_shared_utils import get_secret
|
|
183
183
|
secret = get_secret('test-secret')
|
|
184
184
|
assert secret['key'] == 'value'
|
|
185
185
|
```
|
|
@@ -218,7 +218,7 @@ markers =
|
|
|
218
218
|
|
|
219
219
|
```python
|
|
220
220
|
import pytest
|
|
221
|
-
from
|
|
221
|
+
from nui_shared_utils import SlackClient
|
|
222
222
|
|
|
223
223
|
class TestSlackClient:
|
|
224
224
|
"""Test suite for SlackClient."""
|
|
@@ -265,7 +265,7 @@ def test_elasticsearch_search():
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
# Test code
|
|
268
|
-
from
|
|
268
|
+
from nui_shared_utils import ElasticsearchClient
|
|
269
269
|
client = ElasticsearchClient()
|
|
270
270
|
results = client.search(index='test', body={})
|
|
271
271
|
|
|
@@ -280,7 +280,7 @@ def test_elasticsearch_search():
|
|
|
280
280
|
@pytest.mark.unit
|
|
281
281
|
def test_error_retry_logic():
|
|
282
282
|
"""Test retry decorator behavior."""
|
|
283
|
-
from
|
|
283
|
+
from nui_shared_utils import with_retry
|
|
284
284
|
|
|
285
285
|
call_count = 0
|
|
286
286
|
|
|
@@ -323,10 +323,10 @@ def test_uppercase_conversion(input_value, expected):
|
|
|
323
323
|
|
|
324
324
|
```bash
|
|
325
325
|
# Generate coverage report
|
|
326
|
-
pytest --cov=
|
|
326
|
+
pytest --cov=nui_shared_utils --cov-report=term-missing
|
|
327
327
|
|
|
328
328
|
# View detailed HTML report
|
|
329
|
-
pytest --cov=
|
|
329
|
+
pytest --cov=nui_shared_utils --cov-report=html
|
|
330
330
|
open htmlcov/index.html # Mac
|
|
331
331
|
xdg-open htmlcov/index.html # Linux
|
|
332
332
|
```
|
|
@@ -357,7 +357,7 @@ The project uses GitHub Actions for automated testing:
|
|
|
357
357
|
|
|
358
358
|
```bash
|
|
359
359
|
# Simulate CI environment locally
|
|
360
|
-
pytest --cov=
|
|
360
|
+
pytest --cov=nui_shared_utils --cov-fail-under=90 -v
|
|
361
361
|
```
|
|
362
362
|
|
|
363
363
|
## Troubleshooting Tests
|
|
@@ -103,7 +103,7 @@ export DB_DATABASE="mydb"
|
|
|
103
103
|
### Using the Config Class
|
|
104
104
|
|
|
105
105
|
```python
|
|
106
|
-
import
|
|
106
|
+
import nui_shared_utils as nui
|
|
107
107
|
|
|
108
108
|
# Create configuration object
|
|
109
109
|
config = nui.Config(
|
|
@@ -121,7 +121,7 @@ nui.set_config(config)
|
|
|
121
121
|
### Using the Configure Helper
|
|
122
122
|
|
|
123
123
|
```python
|
|
124
|
-
import
|
|
124
|
+
import nui_shared_utils as nui
|
|
125
125
|
|
|
126
126
|
# Convenient one-liner configuration
|
|
127
127
|
nui.configure(
|
|
@@ -134,7 +134,7 @@ nui.configure(
|
|
|
134
134
|
### Getting Current Configuration
|
|
135
135
|
|
|
136
136
|
```python
|
|
137
|
-
import
|
|
137
|
+
import nui_shared_utils as nui
|
|
138
138
|
|
|
139
139
|
# Get current configuration
|
|
140
140
|
config = nui.get_config()
|
|
@@ -321,7 +321,7 @@ nui.configure(
|
|
|
321
321
|
|
|
322
322
|
```python
|
|
323
323
|
import os
|
|
324
|
-
import
|
|
324
|
+
import nui_shared_utils as nui
|
|
325
325
|
|
|
326
326
|
def lambda_handler(event, context):
|
|
327
327
|
# Configure based on Lambda environment variables
|
|
@@ -344,7 +344,7 @@ def lambda_handler(event, context):
|
|
|
344
344
|
### Checking Configuration
|
|
345
345
|
|
|
346
346
|
```python
|
|
347
|
-
import
|
|
347
|
+
import nui_shared_utils as nui
|
|
348
348
|
|
|
349
349
|
# Get configuration and check values
|
|
350
350
|
config = nui.get_config()
|
|
@@ -363,7 +363,7 @@ except Exception as e:
|
|
|
363
363
|
### Configuration Debug Mode
|
|
364
364
|
|
|
365
365
|
```python
|
|
366
|
-
import
|
|
366
|
+
import nui_shared_utils as nui
|
|
367
367
|
import json
|
|
368
368
|
|
|
369
369
|
# Enable debug logging for configuration issues
|
{nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/getting-started/installation.md
RENAMED
|
@@ -193,7 +193,7 @@ aws lambda publish-layer-version \
|
|
|
193
193
|
|
|
194
194
|
```python
|
|
195
195
|
# In your Lambda function code
|
|
196
|
-
import
|
|
196
|
+
import nui_shared_utils as nui
|
|
197
197
|
|
|
198
198
|
# Configure and use
|
|
199
199
|
nui.configure(
|
|
@@ -207,7 +207,7 @@ nui.configure(
|
|
|
207
207
|
Test your installation:
|
|
208
208
|
|
|
209
209
|
```python
|
|
210
|
-
import
|
|
210
|
+
import nui_shared_utils as nui
|
|
211
211
|
|
|
212
212
|
# Check version
|
|
213
213
|
print(nui.__version__) # Should print version number
|
{nui_python_shared_utils-1.3.0 → nui_python_shared_utils-1.3.2}/docs/getting-started/quickstart.md
RENAMED
|
@@ -12,7 +12,7 @@ pip install nui-python-shared-utils[all]
|
|
|
12
12
|
## Basic Configuration
|
|
13
13
|
|
|
14
14
|
```python
|
|
15
|
-
import
|
|
15
|
+
import nui_shared_utils as nui
|
|
16
16
|
|
|
17
17
|
# Configure the package
|
|
18
18
|
nui.configure(
|
|
@@ -29,7 +29,7 @@ nui.configure(
|
|
|
29
29
|
### 1. Simple Lambda Handler with Error Handling
|
|
30
30
|
|
|
31
31
|
```python
|
|
32
|
-
import
|
|
32
|
+
import nui_shared_utils as nui
|
|
33
33
|
|
|
34
34
|
# Configure once at module level
|
|
35
35
|
nui.configure(
|
|
@@ -58,7 +58,7 @@ def lambda_handler(event, context):
|
|
|
58
58
|
### 2. Database Operations
|
|
59
59
|
|
|
60
60
|
```python
|
|
61
|
-
import
|
|
61
|
+
import nui_shared_utils as nui
|
|
62
62
|
|
|
63
63
|
# Configure database
|
|
64
64
|
nui.configure(db_credentials_secret="prod/database")
|
|
@@ -79,7 +79,7 @@ def get_user_data(user_id: int):
|
|
|
79
79
|
### 3. Elasticsearch Search
|
|
80
80
|
|
|
81
81
|
```python
|
|
82
|
-
import
|
|
82
|
+
import nui_shared_utils as nui
|
|
83
83
|
|
|
84
84
|
# Configure Elasticsearch
|
|
85
85
|
nui.configure(
|
|
@@ -107,7 +107,7 @@ def search_logs(service: str, hours: int = 24):
|
|
|
107
107
|
### 4. Rich Slack Messages
|
|
108
108
|
|
|
109
109
|
```python
|
|
110
|
-
import
|
|
110
|
+
import nui_shared_utils as nui
|
|
111
111
|
|
|
112
112
|
def send_report(data: dict):
|
|
113
113
|
"""Send a formatted report to Slack."""
|
|
@@ -133,7 +133,7 @@ def send_report(data: dict):
|
|
|
133
133
|
### 5. CloudWatch Metrics
|
|
134
134
|
|
|
135
135
|
```python
|
|
136
|
-
import
|
|
136
|
+
import nui_shared_utils as nui
|
|
137
137
|
|
|
138
138
|
def track_business_metrics(records_processed: int, processing_time: float):
|
|
139
139
|
"""Publish custom metrics to CloudWatch."""
|
|
@@ -154,7 +154,7 @@ def track_business_metrics(records_processed: int, processing_time: float):
|
|
|
154
154
|
|
|
155
155
|
```python
|
|
156
156
|
import os
|
|
157
|
-
import
|
|
157
|
+
import nui_shared_utils as nui
|
|
158
158
|
|
|
159
159
|
# Configure once at module level
|
|
160
160
|
nui.configure(
|
|
@@ -226,7 +226,7 @@ def lambda_handler(event, context):
|
|
|
226
226
|
### 7. JWT Authentication for API Gateway
|
|
227
227
|
|
|
228
228
|
```python
|
|
229
|
-
import
|
|
229
|
+
import nui_shared_utils as nui
|
|
230
230
|
|
|
231
231
|
def lambda_handler(event, context):
|
|
232
232
|
"""API Gateway Lambda with JWT auth."""
|
|
@@ -263,7 +263,7 @@ pip install nui-python-shared-utils[jwt]
|
|
|
263
263
|
For production Lambda functions, use AWS Powertools for standardized logging, metrics, and error handling:
|
|
264
264
|
|
|
265
265
|
```python
|
|
266
|
-
from
|
|
266
|
+
from nui_shared_utils import get_powertools_logger, powertools_handler
|
|
267
267
|
|
|
268
268
|
# Create logger with ES-compatible formatting
|
|
269
269
|
logger = get_powertools_logger("order-processor", level="INFO")
|
|
@@ -333,7 +333,7 @@ pip install nui-python-shared-utils[powertools]
|
|
|
333
333
|
|
|
334
334
|
```python
|
|
335
335
|
import os
|
|
336
|
-
import
|
|
336
|
+
import nui_shared_utils as nui
|
|
337
337
|
|
|
338
338
|
stage = os.environ.get('STAGE', 'dev')
|
|
339
339
|
|