Skip to content

Commit 855869b

Browse files
authored
Updated client for NiFI-2.6.0. Fixed augmentation system to correctly pass env vars. Updated contributing guide to explain common issues and how nifi and registry differ on security. Fixed mustache templates for new NiFi security schemes.Fixed make file passing through env vars to client generator (#391)
1 parent f05687d commit 855869b

File tree

535 files changed

+1279
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+1279
-687
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.DEFAULT_GOAL := help
33

44
# Default NiFi/Registry version for docker compose profiles
5-
NIFI_VERSION ?= 2.5.0
5+
NIFI_VERSION ?= 2.6.0
66

77
# Python command for cross-platform compatibility
88
# Defaults to 'python' for conda/venv users, override with PYTHON=python3 for system installs
@@ -245,8 +245,8 @@ wait-ready: ## wait for readiness using profile configuration; requires NIPYAPI_
245245
# API & Client generation
246246
fetch-openapi-base: ## refresh base OpenAPI specs for current NIFI_VERSION (always overwrite base)
247247
@echo "Refreshing base specs for NIFI_VERSION=$(NIFI_VERSION)"
248-
bash resources/client_gen/fetch_nifi_openapi.sh nifi-single || exit 1
249-
bash resources/client_gen/fetch_registry_openapi.sh registry-single || exit 1
248+
NIFI_VERSION=$(NIFI_VERSION) bash resources/client_gen/fetch_nifi_openapi.sh nifi-single || exit 1
249+
NIFI_VERSION=$(NIFI_VERSION) bash resources/client_gen/fetch_registry_openapi.sh registry-single || exit 1
250250
@echo "Base specs refreshed."
251251

252252
augment-openapi: ## generate augmented OpenAPI specs from base (always overwrite augmented)
@@ -263,8 +263,8 @@ augment-openapi: ## generate augmented OpenAPI specs from base (always overwrite
263263

264264
fetch-openapi: fetch-openapi-base augment-openapi ## convenience: fetch base then augment
265265

266-
gen-clients: ## generate NiFi and Registry clients from specs (use wv_spec_variant=augmented|base)
267-
WV_SPEC_VARIANT=augmented bash resources/client_gen/generate_api_client.sh
266+
gen-clients: ## generate NiFi and Registry clients from specs (use wv_spec_variant=base|augmented)
267+
wv_spec_variant=$${wv_spec_variant:-augmented} bash resources/client_gen/generate_api_client.sh
268268

269269
# Individual testing
270270

docs/contributing.rst

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,178 @@ Ready to contribute? Here's how to set up `nipyapi` for local development.
112112

113113
8. Submit a pull request through the GitHub website.
114114

115+
Common Mistakes to Avoid
116+
------------------------
117+
118+
When contributing to NiPyAPI, watch out for these frequent pitfalls:
119+
120+
**Installation & Environment**
121+
122+
* **Bracket quoting in zsh**: Running ``pip install -e .[dev]`` fails in zsh due to glob expansion. Always use quotes: ``pip install -e ".[dev]"`` or use ``make dev-install``.
123+
* **Wrong Python version**: Project supports Python 3.9-3.12. Using 3.8 (end of life) or 3.13+ (untested) may cause compatibility issues.
124+
* **Missing virtual environment**: Always activate a virtual environment before installing dependencies to avoid polluting system Python.
125+
126+
**Testing**
127+
128+
* **Missing NIPYAPI_PROFILE**: Never run ``pytest`` without setting ``NIPYAPI_PROFILE`` environment variable. Always use ``make test NIPYAPI_PROFILE=single-user`` or equivalent.
129+
* **Services not ready**: Never assume Docker services are immediately ready after ``make up``. Always run ``make wait-ready NIPYAPI_PROFILE=<profile>`` before testing.
130+
* **Stale certificates**: If you encounter certificate errors, run ``make down`` then ``make certs`` to regenerate fresh certificates. Never run ``make certs`` while containers are running.
131+
132+
**Code Quality**
133+
134+
* **Modifying generated code**: Never edit files in ``nipyapi/nifi/``, ``nipyapi/registry/``, or ``nipyapi/_version.py``. These are auto-generated and your changes will be overwritten.
135+
* **Skipping lint checks**: Always run ``make lint`` before committing. Both flake8 and pylint must pass.
136+
* **Incorrect line length**: Project uses 100-character line limit consistently across all tools (flake8, pylint, black, isort).
137+
138+
**NiFi vs Registry Security Differences**
139+
140+
**Important:** NiFi and Registry have different security implementations in their OpenAPI specifications:
141+
142+
* **NiFi 2.6.0+**: Includes native security schemes (``HTTPBearerJWT``, ``CookieSecureAuthorizationBearer``) in base OpenAPI spec
143+
* **Registry 2.6.0+**: Has NO security schemes in base OpenAPI spec - requires augmentation
144+
145+
**Key implications:**
146+
147+
* Registry augmentation scripts (``resources/client_gen/augmentations/registry_security.py``) remain necessary even though NiFi 2.6.0 has native security
148+
* Both services use the same authentication flow: username/password → JWT token → Bearer auth
149+
* The template (``configuration.mustache``) handles both cases via hardcoded ``bearerAuth`` fallback plus native scheme aliases
150+
* Always use ``augmented`` variant when regenerating clients (default) to support both NiFi and Registry
151+
* NiFi can work without augmentation using the ``base`` variant (2.6.0+), but Registry cannot
152+
153+
**Docker & Infrastructure**
154+
155+
* **Docker volume caching**: If you experience persistent issues, run ``make clean-docker`` to remove all containers and volumes, then restart the setup process.
156+
* **Wrong profile for test**: Ensure your ``NIPYAPI_PROFILE`` matches the profile you started with ``make up``. Mixing profiles causes authentication failures.
157+
158+
Make Targets Quick Reference
159+
-----------------------------
160+
161+
NiPyAPI uses Makefile targets as the primary automation interface. Run ``make help`` to see all available targets organized by category.
162+
163+
**Setup & Installation**
164+
::
165+
166+
make dev-install # Install package with dev dependencies (recommended)
167+
make docs-install # Install documentation dependencies
168+
make clean # Remove build, pyc, and temp artifacts
169+
make clean-all # Nuclear clean: removes ALL including generated code
170+
171+
**Testing Workflow**
172+
::
173+
174+
# Basic test workflow
175+
make certs # Generate certificates (once)
176+
make up NIPYAPI_PROFILE=single-user # Start Docker services
177+
make wait-ready NIPYAPI_PROFILE=single-user # Wait for readiness
178+
make test NIPYAPI_PROFILE=single-user # Run tests
179+
make down # Stop services
180+
181+
# Shortcuts for specific profiles
182+
make test-su # single-user profile
183+
make test-ldap # secure-ldap profile
184+
make test-mtls # secure-mtls profile
185+
186+
# Comprehensive testing
187+
make test-all # Run all automated profiles (single-user, ldap, mtls)
188+
make coverage # Run tests with coverage report
189+
190+
**Code Quality**
191+
::
192+
193+
make lint # Run flake8 + pylint (excludes generated code)
194+
make flake8 # Run flake8 only
195+
make pylint # Run pylint only
196+
make pre-commit # Run pre-commit hooks on all files
197+
198+
# Formatting (manual)
199+
black nipyapi/ && isort nipyapi/ # Auto-format code
200+
201+
**Docker Operations**
202+
::
203+
204+
make certs # Generate PKCS12 certificates for secure profiles
205+
make up NIPYAPI_PROFILE=<profile> # Start specific profile
206+
make down # Stop all Docker services
207+
make wait-ready NIPYAPI_PROFILE=<profile> # Wait for services to be ready
208+
make clean-docker # Comprehensive Docker cleanup
209+
210+
# Available profiles: single-user, secure-ldap, secure-mtls, secure-oidc
211+
212+
**Build & Documentation**
213+
::
214+
215+
make dist # Build wheel and source distribution
216+
make check-dist # Validate distribution files
217+
make test-dist # Test that distribution can be imported
218+
make docs # Generate Sphinx documentation
219+
220+
**Complete Workflows**
221+
::
222+
223+
make sandbox NIPYAPI_PROFILE=single-user # Create sandbox with sample objects
224+
make rebuild-all # Comprehensive rebuild: clean → certs → APIs → clients → test → build → docs
225+
226+
Generated vs Maintained Code
227+
-----------------------------
228+
229+
Understanding which code is generated vs maintained is crucial for contributing:
230+
231+
**Generated Code (DO NOT MODIFY)**
232+
233+
These files are automatically generated from OpenAPI specifications and should never be edited directly:
234+
235+
* ``nipyapi/nifi/`` - NiFi API client
236+
* ``nipyapi/registry/`` - Registry API client
237+
* ``nipyapi/_version.py`` - Git version via setuptools-scm
238+
239+
**Why this matters:**
240+
241+
1. Your changes will be overwritten during the next client generation
242+
2. These files are excluded from linting (flake8, pylint, black, isort)
243+
3. Test coverage doesn't include generated code
244+
4. Pull requests should not modify these paths
245+
246+
**Maintained Code (Where to Contribute)**
247+
248+
Focus your contributions on these core modules:
249+
250+
* ``nipyapi/canvas.py`` - Canvas management functions
251+
* ``nipyapi/config.py`` - Configuration and endpoints
252+
* ``nipyapi/parameters.py`` - Parameter context operations
253+
* ``nipyapi/profiles.py`` - Profile management system
254+
* ``nipyapi/security.py`` - Authentication and security
255+
* ``nipyapi/system.py`` - System-level operations
256+
* ``nipyapi/utils.py`` - Utility functions
257+
* ``nipyapi/versioning.py`` - Version control operations
258+
* ``tests/`` - Test suite (always add tests for new features)
259+
* ``examples/`` - Example scripts and usage patterns
260+
* ``docs/`` - Documentation (RST files)
261+
262+
**Regenerating Clients**
263+
264+
If you need to update the generated clients (e.g., for a new NiFi version):
265+
::
266+
267+
# Set target NiFi version
268+
export NIFI_VERSION=2.5.0
269+
270+
# Fetch and generate
271+
make fetch-openapi # Fetch specs from running NiFi
272+
make gen-clients # Generate Python clients
273+
274+
# Test with new clients
275+
make test-all
276+
277+
**Augmentation System**
278+
279+
The project includes an augmentation system for fixing OpenAPI spec issues:
280+
281+
* Base specs: ``resources/client_gen/api_defs/nifi-<version>.json``
282+
* Augmentations: ``resources/client_gen/augmentations/*.py``
283+
* Augmented specs: ``resources/client_gen/api_defs/*-<version>.augmented.json``
284+
285+
If you find spec issues, contribute fixes to the augmentation scripts rather than modifying generated code.
286+
115287
Pull Request Guidelines
116288
-----------------------
117289

nipyapi/nifi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""

nipyapi/nifi/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""

nipyapi/nifi/apis/access_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""

nipyapi/nifi/apis/authentication_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""
@@ -98,7 +98,7 @@ def get_authentication_configuration_with_http_info(self, **kwargs):
9898
select_header_accept(['application/json'])
9999

100100
# Authentication setting
101-
auth_settings = ['bearerAuth']
101+
auth_settings = []
102102

103103
return self.api_client.call_api('/authentication/configuration', 'GET',
104104
path_params,

nipyapi/nifi/apis/connections_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""

nipyapi/nifi/apis/controller_api.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""
@@ -149,6 +149,8 @@ def clear_state(self, id, **kwargs):
149149
Args:
150150
id (str):
151151
The flow analysis rule id. (required)
152+
body (:class:`~nipyapi.nifi.models.ComponentStateEntity`):
153+
Optional component state to perform a selective key removal. If omitted, clears all state.
152154
153155
Returns:
154156
:class:`~nipyapi.nifi.models.ComponentStateEntity`: The response data.
@@ -171,12 +173,14 @@ def clear_state_with_http_info(self, id, **kwargs):
171173
Args:
172174
id (str):
173175
The flow analysis rule id. (required)
176+
body (:class:`~nipyapi.nifi.models.ComponentStateEntity`):
177+
Optional component state to perform a selective key removal. If omitted, clears all state.
174178
175179
Returns:
176180
tuple: (:class:`~nipyapi.nifi.models.ComponentStateEntity`, status_code, headers) - Response data with HTTP details.
177181
"""
178182

179-
all_params = ['id']
183+
all_params = ['id', 'body']
180184
all_params.append('_return_http_data_only')
181185
all_params.append('_preload_content')
182186
all_params.append('_request_timeout')
@@ -195,6 +199,7 @@ def clear_state_with_http_info(self, id, **kwargs):
195199
raise ValueError("Missing the required parameter `id` when calling `clear_state`")
196200

197201

202+
198203
collection_formats = {}
199204

200205
path_params = {}
@@ -209,10 +214,16 @@ def clear_state_with_http_info(self, id, **kwargs):
209214
local_var_files = {}
210215

211216
body_params = None
217+
if 'body' in params:
218+
body_params = params['body']
212219
# HTTP header `Accept`
213220
header_params['Accept'] = self.api_client.\
214221
select_header_accept(['application/json'])
215222

223+
# HTTP header `Content-Type`
224+
header_params['Content-Type'] = self.api_client.\
225+
select_header_content_type(['*/*', 'application/json'])
226+
216227
# Authentication setting
217228
auth_settings = ['bearerAuth']
218229

nipyapi/nifi/apis/controller_services_api.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
REST API definition for Apache NiFi web services
55
6-
OpenAPI spec version: 2.5.0
6+
OpenAPI spec version: 2.6.0
77
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
99
"""
@@ -149,6 +149,8 @@ def clear_state1(self, id, **kwargs):
149149
Args:
150150
id (str):
151151
The controller service id. (required)
152+
body (:class:`~nipyapi.nifi.models.ComponentStateEntity`):
153+
Optional component state to perform a selective key removal. If omitted, clears all state.
152154
153155
Returns:
154156
:class:`~nipyapi.nifi.models.ComponentStateEntity`: The response data.
@@ -171,12 +173,14 @@ def clear_state1_with_http_info(self, id, **kwargs):
171173
Args:
172174
id (str):
173175
The controller service id. (required)
176+
body (:class:`~nipyapi.nifi.models.ComponentStateEntity`):
177+
Optional component state to perform a selective key removal. If omitted, clears all state.
174178
175179
Returns:
176180
tuple: (:class:`~nipyapi.nifi.models.ComponentStateEntity`, status_code, headers) - Response data with HTTP details.
177181
"""
178182

179-
all_params = ['id']
183+
all_params = ['id', 'body']
180184
all_params.append('_return_http_data_only')
181185
all_params.append('_preload_content')
182186
all_params.append('_request_timeout')
@@ -195,6 +199,7 @@ def clear_state1_with_http_info(self, id, **kwargs):
195199
raise ValueError("Missing the required parameter `id` when calling `clear_state1`")
196200

197201

202+
198203
collection_formats = {}
199204

200205
path_params = {}
@@ -209,10 +214,16 @@ def clear_state1_with_http_info(self, id, **kwargs):
209214
local_var_files = {}
210215

211216
body_params = None
217+
if 'body' in params:
218+
body_params = params['body']
212219
# HTTP header `Accept`
213220
header_params['Accept'] = self.api_client.\
214221
select_header_accept(['application/json'])
215222

223+
# HTTP header `Content-Type`
224+
header_params['Content-Type'] = self.api_client.\
225+
select_header_content_type(['*/*', 'application/json'])
226+
216227
# Authentication setting
217228
auth_settings = ['bearerAuth']
218229

0 commit comments

Comments
 (0)