Skip to content

Commit

Permalink
Merge pull request #53 from sserrata/release-1.2.0
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
sserrata authored Jun 20, 2018
2 parents 487b860 + 1e41eca commit 8b140fd
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 86 deletions.
16 changes: 16 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
History
=======

1.2.0 (2018-06-20)
------------------

* Updated README.rst
* Updated RTD API Reference.
* Added `pancloud` to requirements_dev.txt
* Added docstrings to `Credentials` property methods.
* Changed logging xpoll() to return entire log entry instead of just `_source` dictionary.
* Added `Credentials` Storage Adapter feature and moved `TinyDB` code to `tinydb_adapter.py`, the default storage adapter.
* Automatically carry `queryId` from `logging --query` response to `--id` in subsequent `--poll`, `--xpoll` and `--delete` in `summit.py`.
* Various bug fixes and improvements to `summit.py`.
* Added support for caching `access_token` in credentials store.
* Added `write()` method to `LoggingService` class to support writing logs.
* Fixed issues with `Credentials` `get_authorization_url` and `fetch_tokens` methods.
* Added `logging_write.py` to examples.

1.1.0 (2018-05-08)
------------------

Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Sphinx = ">=\"1.4.8\""
PyYAML = ">=\"3.11\""
pytest = ">=\"2.9.2\""
pytest-runner = ">=\"2.11.1\""
sphinxcontrib-napoleon = "*"

[packages]
requests = "*"
Expand Down
164 changes: 89 additions & 75 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pancloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from .credentials import Credentials

__author__ = 'Palo Alto Networks'
__version__ = '1.1.0'
__version__ = '1.2.0'
26 changes: 18 additions & 8 deletions pancloud/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,32 @@ def _resolve_credential(self, credential):
credential=credential, profile=self.profile
)

def fetch_tokens(self, code=None, redirect_uri=None):
def fetch_tokens(self, client_id=None, client_secret=None, code=None,
redirect_uri=None):
"""Fetch tokens from token URL.
Args:
client_id (str): OAuth2 client ID. Defaults to ``None``.
client_secret (str): OAuth2 client secret. Defaults to ``None``.
code (str): Authorization code. Defaults to ``None``.
redirect_uri (str): Redirect URI. Defaults to ``None``.
Returns:
dict: Response from token URL.
"""
client_id = client_id or self.client_id
client_secret = client_secret or self.client_secret
redirect_uri = redirect_uri or self.redirect_uri
c = self.get_credentials()
r = requests.post(
self.token_url,
headers={
'Content-Type': 'application/x-www-form-urlencoded'
},
data={
'client_id': c.client_id,
'client_secret': c.client_secret,
'grant_type': 'authorization_code',
'client_id': client_id,
'client_secret': client_secret,
'code': code,
'redirect_uri': redirect_uri
},
Expand All @@ -202,11 +210,13 @@ def fetch_tokens(self, code=None, redirect_uri=None):
raise PanCloudError(r.text)
return r.json()

def get_authorization_url(self, instance_id=None, redirect_uri=None,
region=None, scope=None, state=None):
def get_authorization_url(self, client_id=None, instance_id=None,
redirect_uri=None, region=None, scope=None,
state=None):
"""Generate authorization URL.
Args:
client_id (str): OAuth2 client ID. Defaults to ``None``.
instance_id (str): App Instance ID. Defaults to ``None``.
redirect_uri (str): Redirect URI. Defaults to ``None``.
region (str): App Region. Defaults to ``None``.
Expand All @@ -217,17 +227,17 @@ def get_authorization_url(self, instance_id=None, redirect_uri=None,
str, str: Auth URL, state
"""
client_id = client_id or self.client_id
instance_id = instance_id or self.instance_id
redirect_uri = redirect_uri or self.redirect_uri
region = region or self.region
scope = scope or self.scope
state = state or self.state
c = self.get_credentials()
return requests.Request(
'GET',
self.auth_base_url,
params={
'client_id': c.client_id,
'client_id': client_id,
'instance_id': instance_id,
'redirect_uri': redirect_uri,
'region': region,
Expand Down
Loading

0 comments on commit 8b140fd

Please sign in to comment.