Skip to content

Commit

Permalink
Move JSS._url and JSS.base_url to @properties.
Browse files Browse the repository at this point in the history
- rstrip URL's with a trailing slash. This is a common mistake and
  barrier to use.
  • Loading branch information
Shea Craig committed Jul 21, 2015
1 parent 2720b66 commit 16ad465
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ All notable changes to this project will be documented in this file. This projec
- ndg-httpsclient
- Previous two required for cipher change support.
- TODO: Updated documentation to describe this requirement for developer (i.e. anyone who does not use the egg or wheel files to install).
- `JSS.base_url` (Get and Set) and `JSS._url` (Read only) are now proper properties.

### Fixed

- Changes the default cipher list for requests/urllib3 to work with recommended changes in JSS >= v9.73.
- `jss.JSS.verify_ssl` is now a computed property and will properly update the requests session if changed after instantiation.
- `jss.JSS.ssl_verify` is now a computed property and will properly update the requests session if changed after instantiation.
- casper package's `Casper` class did not use the requests session on the JSS object passed to it.
- JSS URL's with a trailing slash will be sanitized to remove that slash upon JSS instantiation or `base_url` update.

## [1.1.0] - 2015-06-10 - Velvet Nachos

Expand Down
2 changes: 1 addition & 1 deletion jss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
JSSUnsupportedFileType, JSSError)
from tools import is_osx, is_linux

__version__ = "1.2.0"
__version__ = "1.2.0rc2"
19 changes: 17 additions & 2 deletions jss/jss.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import copy
import subprocess
import ssl
import urlparse

from .exceptions import (
JSSPrefsMissingFileError, JSSPrefsMissingKeyError, JSSGetError,
Expand Down Expand Up @@ -147,8 +148,6 @@ def __init__(self, jss_prefs=None, url=None, user=None, password=None,

# Used by some non-API methods.
self.base_url = url
# Used for all API calls.
self._url = '%s/JSSResource' % url
self.user = user
self.password = password
self.repo_prefs = repo_prefs
Expand Down Expand Up @@ -185,6 +184,22 @@ def _error_handler(self, exception_cls, response):
exception.status_code = response.status_code
raise exception

@property
def _url(self):
"""The URL to the Casper JSS API endpoints. Get only."""
return urlparse.urljoin(self.base_url, "JSSResource")

@property
def base_url(self):
"""The URL to the Casper JSS, including port if needed."""
return self._base_url

@base_url.setter
def base_url(self, url):
"""The URL to the Casper JSS, including port if needed."""
# Remove the frequently included yet incorrect trailing slash.
self._base_url = url.rstrip("/")

@property
def ssl_verify(self):
"""Boolean value for whether to verify SSL traffic."""
Expand Down

0 comments on commit 16ad465

Please sign in to comment.