Skip to content

Commit

Permalink
Merge pull request #30 from demisto/downloadfile_entryexecute
Browse files Browse the repository at this point in the history
integration_upload and investigation_add_entries_sync commands
  • Loading branch information
dantavori authored Dec 27, 2019
2 parents a685298 + 07103c7 commit c8c4552
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[1]: https://pypi.org/project/demisto-py/#history

## 2.0.7
* Added `investigation_add_entries_sync` method creating a new entry in existing investigation.
* Added `download_file` method for downloading files by entry id.
* Added `integration_upload` method for uploading integrations to Demisto.

Expand Down
119 changes: 109 additions & 10 deletions demisto_client/demisto_api/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4501,39 +4501,39 @@ def indicators_search_with_http_info(self, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def integration_upload(self, **kwargs): # noqa: E501
def integration_upload(self, file, **kwargs): # noqa: E501
"""Upload an integration # noqa: E501
Upload an integration to Demisto # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.integration_upload(async_req=True)
>>> thread = api.integration_upload(file, async_req=True)
>>> result = thread.get()
:param async_req bool
:param ModuleConfiguration file:
:param file file: file (required)
:return: ModuleConfiguration
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.integration_upload_with_http_info(**kwargs) # noqa: E501
return self.integration_upload_with_http_info(file, **kwargs) # noqa: E501
else:
(data) = self.integration_upload_with_http_info(**kwargs) # noqa: E501
(data) = self.integration_upload_with_http_info(file, **kwargs) # noqa: E501
return data

def integration_upload_with_http_info(self, **kwargs): # noqa: E501
def integration_upload_with_http_info(self, file, **kwargs): # noqa: E501
"""Upload an integration # noqa: E501
Upload an integration to Demisto # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.integration_upload_with_http_info(async_req=True)
>>> thread = api.integration_upload_with_http_info(file, async_req=True)
>>> result = thread.get()
:param async_req bool
:param ModuleConfiguration file:
:param file file: file (required)
:return: ModuleConfiguration
If the method is called asynchronously,
returns the request thread.
Expand All @@ -4554,6 +4554,10 @@ def integration_upload_with_http_info(self, **kwargs): # noqa: E501
)
params[key] = val
del params['kwargs']
# verify the required parameter 'file' is set
if ('file' not in params or
params['file'] is None):
raise ValueError("Missing the required parameter `file` when calling `integration_upload`") # noqa: E501

collection_formats = {}

Expand All @@ -4565,10 +4569,10 @@ def integration_upload_with_http_info(self, **kwargs): # noqa: E501

form_params = []
local_var_files = {}
if 'file' in params:
local_var_files['file'] = params['file'] # noqa: E501

body_params = None
if 'file' in params:
body_params = params['file']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
Expand Down Expand Up @@ -4596,6 +4600,101 @@ def integration_upload_with_http_info(self, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def investigation_add_entries_sync(self, **kwargs): # noqa: E501
"""Create new entry in existing investigation # noqa: E501
API to create an entry (markdown format) in existing investigation Body example: {\"investigationId\":\"1234\",\"data\":\"entry content…\"} # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.investigation_add_entries_sync(async_req=True)
>>> result = thread.get()
:param async_req bool
:param UpdateEntry update_entry:
:return: list[Entry]
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.investigation_add_entries_sync_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.investigation_add_entries_sync_with_http_info(**kwargs) # noqa: E501
return data

def investigation_add_entries_sync_with_http_info(self, **kwargs): # noqa: E501
"""Create new entry in existing investigation # noqa: E501
API to create an entry (markdown format) in existing investigation Body example: {\"investigationId\":\"1234\",\"data\":\"entry content…\"} # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.investigation_add_entries_sync_with_http_info(async_req=True)
>>> result = thread.get()
:param async_req bool
:param UpdateEntry update_entry:
:return: list[Entry]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['update_entry'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method investigation_add_entries_sync" % key
)
params[key] = val
del params['kwargs']

collection_formats = {}

path_params = {}

query_params = []

header_params = {}

form_params = []
local_var_files = {}

body_params = None
if 'update_entry' in params:
body_params = params['update_entry']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json', 'application/xml']) # noqa: E501

# Authentication setting
auth_settings = ['api_key', 'csrf_token'] # noqa: E501

return self.api_client.call_api(
'/entry/execute/sync', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[Entry]', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_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)

def investigation_add_entry_handler(self, **kwargs): # noqa: E501
"""Create new entry in existing investigation # noqa: E501
Expand Down
57 changes: 53 additions & 4 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Method | HTTP request | Description
[**indicators_edit**](DefaultApi.md#indicators_edit) | **POST** /indicator/edit | Edit Indicator
[**indicators_search**](DefaultApi.md#indicators_search) | **POST** /indicators/search | Search indicators
[**integration_upload**](DefaultApi.md#integration_upload) | **POST** /settings/integration-conf/upload | Upload an integration
[**investigation_add_entries_sync**](DefaultApi.md#investigation_add_entries_sync) | **POST** /entry/execute/sync | Create new entry in existing investigation
[**investigation_add_entry_handler**](DefaultApi.md#investigation_add_entry_handler) | **POST** /entry | Create new entry in existing investigation
[**investigation_add_formatted_entry_handler**](DefaultApi.md#investigation_add_formatted_entry_handler) | **POST** /entry/formatted | Create new formatted entry in existing investigation
[**revoke_user_api_key**](DefaultApi.md#revoke_user_api_key) | **POST** /apikeys/revoke/user/{username} |
Expand Down Expand Up @@ -2248,7 +2249,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)

# **integration_upload**
> ModuleConfiguration integration_upload(file=file)
> ModuleConfiguration integration_upload(file)
Upload an integration

Expand All @@ -2264,11 +2265,11 @@ from demisto_client.demisto_api.rest import ApiException
from pprint import pprint

api_instance = demisto_client.configure(base_url="https://YOUR_DEMISTO_SERVER", api_key="YOUR_API_KEY")
file = demisto_client.demisto_api.ModuleConfiguration() # ModuleConfiguration | (optional)
file = '/path/to/file.txt' # file | file

try:
# Upload an integration
api_response = api_instance.integration_upload(file=file)
api_response = api_instance.integration_upload(file)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->integration_upload: %s\n" % e)
Expand All @@ -2278,7 +2279,7 @@ except ApiException as e:

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file** | [**ModuleConfiguration**](ModuleConfiguration.md)| | [optional]
**file** | **file**| file |

### Return type

Expand All @@ -2295,6 +2296,54 @@ Name | Type | Description | Notes

[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)

# **investigation_add_entries_sync**
> list[Entry] investigation_add_entries_sync(update_entry=update_entry)
Create new entry in existing investigation

API to create an entry (markdown format) in existing investigation Body example: {\"investigationId\":\"1234\",\"data\":\"entry content…\"}

### Example
```python
from __future__ import print_function
import time
import demisto_client
import demisto_client.demisto_api
from demisto_client.demisto_api.rest import ApiException
from pprint import pprint

api_instance = demisto_client.configure(base_url="https://YOUR_DEMISTO_SERVER", api_key="YOUR_API_KEY")
update_entry = demisto_client.demisto_api.UpdateEntry() # UpdateEntry | (optional)

try:
# Create new entry in existing investigation
api_response = api_instance.investigation_add_entries_sync(update_entry=update_entry)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->investigation_add_entries_sync: %s\n" % e)
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**update_entry** | [**UpdateEntry**](UpdateEntry.md)| | [optional]

### Return type

[**list[Entry]**](Entry.md)

### Authorization

[api_key](README.md#api_key), [csrf_token](README.md#csrf_token)

### HTTP request headers

- **Content-Type**: application/json, application/xml
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)

# **investigation_add_entry_handler**
> Entry investigation_add_entry_handler(update_entry=update_entry)
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Method | HTTP request | Description
[**indicators_edit**](DefaultApi.md#indicators_edit) | **POST** /indicator/edit | Edit Indicator
[**indicators_search**](DefaultApi.md#indicators_search) | **POST** /indicators/search | Search indicators
[**integration_upload**](DefaultApi.md#integration_upload) | **POST** /settings/integration-conf/upload | Upload an integration
[**investigation_add_entries_sync**](DefaultApi.md#investigation_add_entries_sync) | **POST** /entry/execute/sync | Create new entry in existing investigation
[**investigation_add_entry_handler**](DefaultApi.md#investigation_add_entry_handler) | **POST** /entry | Create new entry in existing investigation
[**investigation_add_formatted_entry_handler**](DefaultApi.md#investigation_add_formatted_entry_handler) | **POST** /entry/formatted | Create new formatted entry in existing investigation
[**revoke_user_api_key**](DefaultApi.md#revoke_user_api_key) | **POST** /apikeys/revoke/user/{username} |
Expand Down
41 changes: 36 additions & 5 deletions server_api_swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,36 @@
}
}
},
"/entry/execute/sync": {
"post": {
"description": "API to create an entry (markdown format) in existing investigation\nBody example: {\"investigationId\":\"1234\",\"data\":\"entry content…\"}",
"summary": "Create new entry in existing investigation",
"operationId": "investigationAddEntriesSync",
"parameters": [
{
"name": "updateEntry",
"in": "body",
"schema": {
"$ref": "#/definitions/updateEntry"
}
}
],
"responses": {
"200": {
"description": "An array of the children entries of the executed entry.",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Entry"
}
}
},
"412": {
"description": "In case of closed investigation"
}
}
}
},
"/entry/exportArtifact": {
"post": {
"description": "Export an entry artifact",
Expand Down Expand Up @@ -1421,11 +1451,11 @@
"operationId": "integrationUpload",
"parameters": [
{
"type": "file",
"description": "file",
"name": "file",
"in": "body",
"schema": {
"$ref": "#/definitions/ModuleConfiguration"
}
"in": "formData",
"required": true
}
],
"responses": {
Expand Down Expand Up @@ -8520,4 +8550,5 @@
"csrf_token": []
}
]
}
}

0 comments on commit c8c4552

Please sign in to comment.