Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload custom pack #139

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

[PyPI History](https://pypi.org/project/demisto-py/#history)

## 3.2.16
* Added support `upload_custom_packs` to upload zipped custom packs to the marketplace.

Note: `upload_content_packs` will be deprecated from XSOAR 8.9 and XSIAM 2.5.

## 3.2.14
* Added support for Python versions 3.11 and 3.12.

Expand Down
103 changes: 101 additions & 2 deletions demisto_client/demisto_api/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7265,7 +7265,7 @@ def update_entry_tags_op_with_http_info(self, **kwargs): # noqa: E501
def upload_content_packs(self, file, **kwargs): # noqa: E501
"""Upload a Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips) # noqa: E501

Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. # noqa: E501
Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. (will be deprecated from XSOAR 8.9 and XSIAM 2.5) # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_content_packs(file, async_req=True)
Expand All @@ -7289,7 +7289,7 @@ def upload_content_packs(self, file, **kwargs): # noqa: E501
def upload_content_packs_with_http_info(self, file, **kwargs): # noqa: E501
"""Upload a Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips) # noqa: E501

Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. # noqa: E501
Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. (will be deprecated from XSOAR 8.9 and XSIAM 2.5) # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_content_packs_with_http_info(file, async_req=True)
Expand Down Expand Up @@ -7369,6 +7369,105 @@ def upload_content_packs_with_http_info(self, file, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def upload_custom_packs(self, file, **kwargs): # noqa: E501
"""Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips) # noqa: E501

Upload a Custom Pack to the marketplace in the Server. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_custom_packs(file, async_req=True)
>>> result = thread.get()

:param async_req bool
:param file file: file (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.upload_custom_packs_with_http_info(file, **kwargs) # noqa: E501
else:
(data) = self.upload_custom_packs_with_http_info(file, **kwargs) # noqa: E501
return data

def upload_custom_packs_with_http_info(self, file, **kwargs): # noqa: E501
"""Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips) # noqa: E501

Upload a Custom Pack to the marketplace in the Server. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_custom_packs_with_http_info(file, async_req=True)
>>> result = thread.get()

:param async_req bool
:param file file: file (required)
:return: None
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['file'] # 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 upload_custom_packs" % key
)
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 `upload_custom_packs`") # noqa: E501

collection_formats = {}

path_params = {}

query_params = []

header_params = {}

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

body_params = None
# 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
['multipart/form-data']) # noqa: E501

# Authentication setting
auth_settings = ['api_key', 'csrf_token', 'x-xdr-auth-id'] # noqa: E501

return self.api_client.call_api(
'/contentpacks/installed/upload/custom', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # 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 upload_report(self, file, **kwargs): # noqa: E501
"""Upload report file to Demisto # noqa: E501

Expand Down
50 changes: 49 additions & 1 deletion docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Method | HTTP request | Description
[**update_entry_note**](DefaultApi.md#update_entry_note) | **POST** /entry/note | Mark entry as note
[**update_entry_tags_op**](DefaultApi.md#update_entry_tags_op) | **POST** /entry/tags | Set entry tags
[**upload_content_packs**](DefaultApi.md#upload_content_packs) | **POST** /contentpacks/installed/upload | Upload a Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)
[**upload_custom_packs**](DefaultApi.md#upload_custom_packs) | **POST** /contentpacks/installed/upload/custom | Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)
[**upload_report**](DefaultApi.md#upload_report) | **POST** /reports/upload | Upload report file to Demisto


Expand Down Expand Up @@ -3615,7 +3616,7 @@ Name | Type | Description | Notes

Upload a Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)

Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released.
Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. (will be deprecated from XSOAR 8.9 and XSIAM 2.5)

### Example
```python
Expand Down Expand Up @@ -3661,6 +3662,53 @@ void (empty response body)

[[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)

# **upload_custom_packs**
> upload_custom_packs(file)

Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)

Upload a Custom Pack to the marketplace in the Server.

### 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")
file = '/path/to/file.txt' # file | file

try:
# Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)
api_instance.upload_custom_packs(file)
except ApiException as e:
print("Exception when calling DefaultApi->upload_custom_packs: %s\n" % e)
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file** | **file**| file |

### Return type

void (empty response body)

### Authorization

[api_key](README.md#api_key), [csrf_token](README.md#csrf_token), [x-xdr-auth-id](README.md#x-xdr-auth-id)

### HTTP request headers

- **Content-Type**: multipart/form-data
- **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)

# **upload_report**
> list[Report] upload_report(file)

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Method | HTTP request | Description
[**update_entry_note**](DefaultApi.md#update_entry_note) | **POST** /entry/note | Mark entry as note
[**update_entry_tags_op**](DefaultApi.md#update_entry_tags_op) | **POST** /entry/tags | Set entry tags
[**upload_content_packs**](DefaultApi.md#upload_content_packs) | **POST** /contentpacks/installed/upload | Upload a Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)
[**upload_custom_packs**](DefaultApi.md#upload_custom_packs) | **POST** /contentpacks/installed/upload/custom | Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)
[**upload_report**](DefaultApi.md#upload_report) | **POST** /reports/upload | Upload report file to Demisto


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "demisto-py"
version = "3.2.15"
version = "3.2.16"
description = "\"A Python library for the Demisto API\""
authors = ["Demisto"]
license = "Apache-2.0"
Expand Down
29 changes: 28 additions & 1 deletion server_api_swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@
},
"/contentpacks/installed/upload": {
"post": {
"description": "Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released.",
"description": "Upload a Pack to the marketplace in the Server. Can be used to upload a Pack for an offline scenario or a Pack that hasn't been released. (will be deprecated from XSOAR 8.9 and XSIAM 2.5)",
moishce marked this conversation as resolved.
Show resolved Hide resolved
"consumes": [
"multipart/form-data"
],
Expand Down Expand Up @@ -1822,6 +1822,33 @@
}
}
},
"/contentpacks/installed/upload/custom": {
"post": {
"description": "Upload a Custom Pack to the marketplace in the Server.",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"summary": "Upload a Custom Pack as zip file. The zip file maybe a single Pack or a zip containing multiple zipped Packs (a zip of zips)",
"operationId": "uploadCustomPacks",
"parameters": [
{
"type": "file",
"description": "file",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "The pack was successfully uploaded"
}
}
}
},
"/statistics/dashboards/query": {
"post": {
"description": "Get a given dashboard statistics result.",
Expand Down
Loading