nipyapi.nifi.ProcessGroupsApi.upload_process_group_with_http_info() incomplete
matt038 opened this issue · 1 comments
- Nipyapi version: 0.18.0
- NiFi version: 1.14.0
- NiFi-Registry version: NA
- Python version: 3.8
- Operating System: NA
Description
I noticed nipyapi.nifi.ProcessGroupsApi.upload_process_group_with_http_info()
(seems to have been removed in Nipyapi 0.19.0) had no argument for the JSON flow definition path. By taking a deeper dive I also discovered that arguments body
, body2
, body3
, body4
and body5
are never actually included or used in the function in addition to the file argument missing.
What I Did
I fixed it myself! An argument that will contain the JSON file path obviously needs to be added;
all_params = ['id', 'body', 'body2', 'body3', 'body4', 'body5', 'file']
Furthermore, all body arguments need to be appended to the form_params
list as tuples like so;
form_params = []
if 'body' in params:
form_params.append(tuple(["groupName", params['body']]))
if 'body2' in params:
form_params.append(tuple(["positionX", int(params['body2'])]))
if 'body3' in params:
form_params.append(tuple(["positionY", int(params['body3'])]))
if 'body4' in params:
form_params.append(tuple(["clientId", params['body4']]))
if 'body5' in params:
form_params.append(tuple(["disconnectedNodeAcknowledged",params['body5']]))
The JSON flow definiton path also needs to be added to the local_var_files
dictionary;
local_var_files = {}
if 'file' in params:
local_var_files['file'] = params['file']
Once all of these things are fixed, the function should look something like this:
def upload_process_group_with_http_info(self, id, body, body2, body3, body4, **kwargs):
"""
Uploads a versioned flow definition and creates a process group
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.upload_process_group_with_http_info(id, body, body2, body3, body4, callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str id: The process group id. (required)
:param str body: The process group name. (required)
:param float body2: The process group X position. (required)
:param float body3: The process group Y position. (required)
:param str body4: The client id. (required)
:param bool body5: Acknowledges that this node is disconnected to allow for mutable requests to proceed.
:param str file: Path to JSON flow definition.
:return: ProcessGroupEntity
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['id', 'body', 'body2', 'body3', 'body4', 'body5', 'file']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method upload_process_group" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'id' is set
if ('id' not in params) or (params['id'] is None):
raise ValueError("Missing the required parameter `id` when calling `upload_process_group`")
# verify the required parameter 'body' is set
if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `upload_process_group`")
# verify the required parameter 'body2' is set
if ('body2' not in params) or (params['body2'] is None):
raise ValueError("Missing the required parameter `body2` when calling `upload_process_group`")
# verify the required parameter 'body3' is set
if ('body3' not in params) or (params['body3'] is None):
raise ValueError("Missing the required parameter `body3` when calling `upload_process_group`")
# verify the required parameter 'body4' is set
if ('body4' not in params) or (params['body4'] is None):
raise ValueError("Missing the required parameter `body4` when calling `upload_process_group`")
collection_formats = {}
path_params = {}
if 'id' in params:
path_params['id'] = params['id']
query_params = []
header_params = {}
form_params = []
if 'body' in params:
form_params.append(tuple(["groupName", params['body']]))
if 'body2' in params:
form_params.append(tuple(["positionX", int(params['body2'])]))
if 'body3' in params:
form_params.append(tuple(["positionY", int(params['body3'])]))
if 'body4' in params:
form_params.append(tuple(["clientId", params['body4']]))
if 'body5' in params:
form_params.append(tuple(["disconnectedNodeAcknowledged",params['body5']]))
local_var_files = {}
if 'file' in params:
local_var_files['file'] = params['file']
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json'])
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['multipart/form-data'])
# Authentication setting
auth_settings = ['tokenAuth']
return self.api_client.call_api('/process-groups/{id}/process-groups/upload', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ProcessGroupEntity',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
Urgency
As evident above, I resolved this myself but it would be nice to patch up for others at some point.