Skip to content

Commit

Permalink
Merge pull request #177 from nautobot/develop
Browse files Browse the repository at this point in the history
Release v2.1.1
  • Loading branch information
joewesch authored Mar 27, 2024
2 parents f5be779 + e2e64d4 commit 987e1c8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10"]
nautobot-version: ["2.0"]
exclude:
- python-version: 3.10
nautobot-version: 1.2
python-version: ["3.8", "3.9", "3.10", "3.11"]
nautobot-version: ["2.0", "2.1", "stable"]
env:
PYTHON_VER: "${{ matrix.python-version }}"
NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.1.1

- (#173) Fixes for authentication change in Nautobot.

## v2.1.0

### New Features
Expand Down Expand Up @@ -41,6 +45,10 @@ New release for nautobot 2.0
Release Candidate.
New release train for nautobot 2.X

## v1.5.2

- (#174) Fixes for authentication change in Nautobot.

## v1.5.0

### New Features
Expand Down
13 changes: 8 additions & 5 deletions pynautobot/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
This file has been modified by NetworktoCode, LLC.
"""

from packaging import version
import requests
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -140,10 +141,12 @@ def version(self):
'1.0'
>>>
"""
version = Request(
base=self.base_url, http_session=self.http_session, api_version=self.api_version
return Request(
base=self.base_url,
http_session=self.http_session,
api_version=self.api_version,
token=self.token,
).get_version()
return version

def openapi(self):
"""Returns the OpenAPI spec.
Expand All @@ -166,6 +169,7 @@ def openapi(self):
base=self.base_url,
http_session=self.http_session,
api_version=self.api_version,
token=self.token,
).get_openapi()

def status(self):
Expand Down Expand Up @@ -196,10 +200,9 @@ def status(self):
'rq-workers-running': 1}
>>>
"""
status = Request(
return Request(
base=self.base_url,
token=self.token,
http_session=self.http_session,
api_version=self.api_version,
).get_status()
return status
12 changes: 10 additions & 2 deletions pynautobot/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
This file has been modified by NetworktoCode, LLC.
"""

try:
import concurrent.futures as cf
except ImportError:
Expand Down Expand Up @@ -162,6 +163,7 @@ def get_openapi(self):
"""Gets the OpenAPI Spec"""
headers = {
"Content-Type": "application/json;",
"Authorization": f"Token {self.token}",
}

if self.api_version:
Expand Down Expand Up @@ -190,7 +192,10 @@ def get_version(self):
:Returns: Version number as a string. Empty string if version is not
present in the headers.
"""
headers = {"Content-Type": "application/json;"}
headers = {
"Content-Type": "application/json;",
"Authorization": f"Token {self.token}",
}
if self.api_version:
headers["accept"] = f"application/json; version={self.api_version}"

Expand All @@ -213,7 +218,10 @@ def get_status(self):
:Returns: Dictionary as returned by Nautobot.
:Raises: RequestError if request is not successful.
"""
headers = {"Content-Type": "application/json;"}
headers = {
"Content-Type": "application/json;",
"Authorization": f"Token {self.token}",
}
if self.token:
headers["authorization"] = "Token {}".format(self.token)

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[tool.poetry]
name = "pynautobot"
version = "2.1.0"
version = "2.1.1"
description = "Nautobot API client library"
authors = ["Network to Code, LLC <[email protected]>"]
readme = "README.md"
Expand Down Expand Up @@ -62,7 +62,7 @@ exclude = '''
| dist
)/
| settings.py # This is where you define files that should not be stylized by black
# the root of the project
| .devicetype-library/
)
'''

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class RequestTestCase(unittest.TestCase):
def test_get_openapi(self):
test = Request("http://localhost:8080/api", Mock())
test = Request("http://localhost:8080/api", Mock(), token="1234")
test.get_openapi()
test.http_session.get.assert_called_with(
"http://localhost:8080/api/docs/?format=openapi",
headers={"Content-Type": "application/json;"},
headers={"Content-Type": "application/json;", "Authorization": "Token 1234"},
)

0 comments on commit 987e1c8

Please sign in to comment.