Skip to content

Commit

Permalink
Merge pull request #24 from demisto/remove-user-auth
Browse files Browse the repository at this point in the history
Remove user/pass auth
  • Loading branch information
glicht authored Oct 22, 2019
2 parents 2224d88 + 79c010a commit 0b93513
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 31 deletions.
1 change: 1 addition & 0 deletions .swagger-codegen-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
tox.ini
test-requirements.txt
setup.py
requirements.txt
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

[1]: https://pypi.org/project/demisto-py/#history

## 2.0.5
Remove unsupported user/password authentication option.

## 2.0.4
Fix missing dependency (tzlocal).

Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ api_instance = demisto_client.configure(base_url=host, api_key=api_key)

```

**Alternatively, you can login with username and password:**

```python
import demisto_client

host = 'https://YOUR_DEMISTO_HOST'
username = 'YOUR_USERNAME'
password = 'YOUR_PASSWORD'

api_instance = demisto_client.configure(base_url=host, username=username, password=password)

```


### 3. Create incidents

```python
Expand Down
17 changes: 5 additions & 12 deletions demisto_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,20 @@
__version__ = 'dev'


def configure(base_url=None, api_key=None, username=None, password=None, verify_ssl=True, proxy=None,
def configure(base_url=None, api_key=None, verify_ssl=True, proxy=None,
debug=False):
"""
This wrapper provides an easier to use method of configuring the API client. The base
Configuration method is still exposed if you wish to further configure the API Client.
To avoid hard coding configurations in your code, it is also possible to specify api_key, username, password
To avoid hard coding configurations in your code, it is also possible to specify api_key
and base_url as the following environment variables (env variables will be used if parameters are not specified):
* DEMISTO_BASE_URL
* DEMISTO_API_KEY
* DEMISTO_USERNAME
* DEMISTO_PASSWORD
:param base_url: str - Base url of your Demisto instance.
:param api_key: str - API key generated by your instance.
:param username: str - If using credentials to authenticate, provide username of account.
:param password: str - If using credentials to authenticate, provide password for the account.
Please note: headers are not encrypted.
:param verify_ssl: bool - Indicates if valid SSLs are required for connection.
:param proxy: dict - Dict object of your proxy settings.
:param debug: bool - Include verbose logging.
Expand All @@ -43,15 +38,13 @@ def configure(base_url=None, api_key=None, username=None, password=None, verify_
configuration = Configuration()
configuration.api_key['Authorization'] = api_key or os.getenv('DEMISTO_API_KEY', None)
configuration.host = base_url or os.getenv('DEMISTO_BASE_URL', None)
configuration.username = username or os.getenv('DEMISTO_USERNAME', None)
configuration.password = password or os.getenv('DEMISTO_PASSWORD', None)
configuration.verify_ssl = verify_ssl
configuration.proxy = proxy
configuration.debug = debug
if not configuration.host:
raise ValueError('You must specify base_url either as a parameter or via env variable: DEMISTO_BASE_URL')
if not configuration.api_key.get('Authorization', None) and not (configuration.username and configuration.password):
raise ValueError('You must specify either api_key or username/password either as parameters or env variables')
if not configuration.api_key.get('Authorization', None):
raise ValueError('You must specify either api_key as parameters or via env variable: DEMISTO_API_KEY')
api_client = ApiClient(configuration)
api_client.user_agent = 'demisto-py/' + __version__
api_instance = demisto_api.DefaultApi(api_client)
Expand Down
4 changes: 2 additions & 2 deletions demisto_client/demisto_api/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,7 @@ def incident_file_upload(self, id, file, **kwargs): # noqa: E501
:param file file: file (required)
:param str file_name: file name
:param str file_comment: file comment
:param str field: field name to hold the attachment details. If not sepcified `attachment` will be used.
:param str field: field name to hold the attachment details. If not specified, `attachment` will be used.
:param bool show_media_file: show media file
:param bool last: If set to true will create an investigation. Used for uploading after creating incident.
:return: IncidentWrapper
Expand Down Expand Up @@ -3834,7 +3834,7 @@ def incident_file_upload_with_http_info(self, id, file, **kwargs): # noqa: E501
:param file file: file (required)
:param str file_name: file name
:param str file_comment: file comment
:param str field: field name to hold the attachment details. If not sepcified `attachment` will be used.
:param str field: field name to hold the attachment details. If not specified, `attachment` will be used.
:param bool show_media_file: show media file
:param bool last: If set to true will create an investigation. Used for uploading after creating incident.
:return: IncidentWrapper
Expand Down
4 changes: 2 additions & 2 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ id = 'id_example' # str | Incident id to update
file = '/path/to/file.txt' # file | file
file_name = 'file_name_example' # str | file name (optional)
file_comment = 'file_comment_example' # str | file comment (optional)
field = 'field_example' # str | field name to hold the attachment details. If not sepcified `attachment` will be used. (optional)
field = 'field_example' # str | field name to hold the attachment details. If not specified, `attachment` will be used. (optional)
show_media_file = true # bool | show media file (optional)
last = true # bool | If set to true will create an investigation. Used for uploading after creating incident. (optional)

Expand All @@ -1936,7 +1936,7 @@ Name | Type | Description | Notes
**file** | **file**| file |
**file_name** | **str**| file name | [optional]
**file_comment** | **str**| file comment | [optional]
**field** | **str**| field name to hold the attachment details. If not sepcified `attachment` will be used. | [optional]
**field** | **str**| field name to hold the attachment details. If not specified, `attachment` will be used. | [optional]
**show_media_file** | **bool**| show media file | [optional]
**last** | **bool**| If set to true will create an investigation. Used for uploading after creating incident. | [optional]

Expand Down
2 changes: 1 addition & 1 deletion gen-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sed -i '' -e 's/^## Author//g' docs/README.md
# add ability for generic requests
sed -i '' -e 's/import six/import six\
import demisto_client/g' demisto_client/demisto_api/api/default_api.py
echo -e "\n def generic_request(self, path, method, body=None, **kwargs): # noqa: E501\n return demisto_client.generic_request_func(self, path, method, body=None, **kwargs)" >> demisto_client/demisto_api/api/default_api.py
echo -e "\n def generic_request(self, path, method, body=None, **kwargs): # noqa: E501\n return demisto_client.generic_request_func(self, path, method, body, **kwargs)" >> demisto_client/demisto_api/api/default_api.py

# remove files not used
rm .travis.yml
Expand Down

0 comments on commit 0b93513

Please sign in to comment.