Skip to content

Commit 88e3937

Browse files
authored
Merge pull request #666 from ucfopen/develop
Release Version 3.3.0
2 parents 524bfd7 + e03ae0f commit 88e3937

File tree

8 files changed

+69
-15
lines changed

8 files changed

+69
-15
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Check for missing kwargs
4141
run: python scripts/find_missing_kwargs.py
4242
- name: Upload coverage to Codecov
43-
uses: codecov/codecov-action@v3
43+
uses: codecov/codecov-action@v4
4444
with:
4545
fail_ci_if_error: true
4646
token: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
## [Unreleased]
44

5+
## [3.3.0] - 2023-08-27
6+
7+
### General
8+
9+
- Added documentation for PaginatedList
10+
- Rework requester URLs to accomodate graphql and new quizzes endpoints (Thanks, [@bennettscience](https://github.com/bennettscience))
11+
12+
### Bugfixes
13+
14+
- Fixed PaginatedList not respecting new quizzes endpoints (Thanks, [@matthewf-ucsd](https://github.com/matthewf-ucsd))
15+
16+
### Backstage
17+
18+
- Updated codecov action
19+
520
## [3.2.0] - 2023-05-25
621

722
### New Endpoint Coverage
@@ -621,7 +636,8 @@ Huge thanks to [@liblit](https://github.com/liblit) for lots of issues, suggesti
621636
- Fixed some incorrectly defined parameters
622637
- Fixed an issue where tests would fail due to an improperly configured requires block
623638

624-
[Unreleased]: https://github.com/ucfopen/canvasapi/compare/v3.2.0...develop
639+
[Unreleased]: https://github.com/ucfopen/canvasapi/compare/v3.3.0...develop
640+
[3.3.0]: https://github.com/ucfopen/canvasapi/compare/v3.2.0...v3.3.0
625641
[3.2.0]: https://github.com/ucfopen/canvasapi/compare/v3.1.0...v3.2.0
626642
[3.1.0]: https://github.com/ucfopen/canvasapi/compare/v3.0.0...v3.1.0
627643
[3.0.0]: https://github.com/ucfopen/canvasapi/compare/v2.2.0...v3.0.0

canvasapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__all__ = ["Canvas"]
66

7-
__version__ = "3.2.0"
7+
__version__ = "3.3.0"

canvasapi/canvas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ def graphql(self, query, variables=None, **kwargs):
12791279
_kwargs=combine_kwargs(**kwargs)
12801280
+ [("query", query), ("variables", variables)],
12811281
# Needs to call special endpoint without api/v1
1282-
_url=self.__requester.original_url + "/api/graphql",
1282+
_url="graphql",
12831283
json=True,
12841284
)
12851285

canvasapi/course.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def create_new_quiz(self, **kwargs):
480480
response = self._requester.request(
481481
"POST",
482482
endpoint,
483-
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
483+
_url="new_quizzes",
484484
_kwargs=combine_kwargs(**kwargs),
485485
)
486486
response_json = response.json()
@@ -1758,7 +1758,7 @@ def get_new_quiz(self, assignment, **kwargs):
17581758
response = self._requester.request(
17591759
"GET",
17601760
endpoint,
1761-
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
1761+
_url="new_quizzes",
17621762
_kwargs=combine_kwargs(**kwargs),
17631763
)
17641764
response_json = response.json()
@@ -1783,7 +1783,7 @@ def get_new_quizzes(self, **kwargs):
17831783
self._requester,
17841784
"GET",
17851785
endpoint,
1786-
_url_override=self._requester.original_url + "/api/quiz/v1/" + endpoint,
1786+
_url_override="new_quizzes",
17871787
_kwargs=combine_kwargs(**kwargs),
17881788
)
17891789

canvasapi/new_quiz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def delete(self, **kwargs):
2121
response = self._requester.request(
2222
"DELETE",
2323
endpoint,
24-
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
24+
_url="new_quizzes",
2525
_kwargs=combine_kwargs(**kwargs),
2626
)
2727
response_json = response.json()
@@ -44,7 +44,7 @@ def update(self, **kwargs):
4444
response = self._requester.request(
4545
"PATCH",
4646
endpoint,
47-
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
47+
_url="new_quizzes",
4848
_kwargs=combine_kwargs(**kwargs),
4949
)
5050
response_json = response.json()

canvasapi/paginated_list.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ def __init__(
2828
_url_override=None,
2929
**kwargs
3030
):
31+
"""
32+
:param content_class: The expected type to return in the list.
33+
:type content_class: class
34+
:param requester: The requester to pass HTTP requests through.
35+
:type requester: :class:`canvasapi.requester.Requester`
36+
:param request_method: HTTP request method
37+
:type request_method: str
38+
:param first_url: Canvas endpoint for the initial request
39+
:type first_url: str
40+
:param extra_attribs: Extra data to include in the request
41+
:type extra_attribs: dict
42+
:param _root: Specify a nested property from Canvas to use for the resulting list.
43+
:type _root: str
44+
:param _url_override: "new_quizzes" or "graphql" for specific Canvas endpoints.
45+
Other URLs may be specified for third-party requests.
46+
:type _url_override: str
47+
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of type content_class
48+
"""
3149
self._elements = list()
3250

3351
self._requester = requester
@@ -78,7 +96,10 @@ def _get_next_page(self):
7896
else:
7997
next_link = None
8098

81-
regex = r"{}(.*)".format(re.escape(self._requester.base_url))
99+
regex = r"(?:{}|{})(.*)".format(
100+
re.escape(self._requester.base_url),
101+
re.escape(self._requester.new_quizzes_url),
102+
)
82103

83104
self._next_url = (
84105
re.search(regex, next_link["url"]).group(1) if next_link else None

canvasapi/requester.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def __init__(self, base_url, access_token):
3535
# Preserve the original base url and add "/api/v1" to it
3636
self.original_url = base_url
3737
self.base_url = base_url + "/api/v1/"
38+
self.new_quizzes_url = base_url + "/api/quiz/v1/"
39+
self.graphql = base_url + "/api/graphql"
3840
self.access_token = access_token
3941
self._session = requests.Session()
4042
self._cache = []
@@ -145,10 +147,16 @@ def request(
145147
:param use_auth: Optional flag to remove the authentication
146148
header from the request.
147149
:type use_auth: bool
148-
:param _url: Optional argument to send a request to a URL
149-
outside of the Canvas API. If this is selected and an
150-
endpoint is provided, the endpoint will be ignored and
151-
only the _url argument will be used.
150+
:param _url: Optional argument to specify a request type to Canvas
151+
or to send a request to a URL outside of the Canvas API.
152+
If set to "new_quizzes", the new quizzes endpoint will be used.
153+
If set to "graphql", a graphql POST request will be sent.
154+
If any string URL is provided, it will be used instead of the
155+
base REST URL.
156+
If omitted or set to None, the base_url for the instance REST
157+
endpoint will be used.
158+
If this is selected and an endpoint is provided, the endpoint
159+
will be ignored and only the `_url` argument will be used..
152160
:type _url: str
153161
:param _kwargs: A list of 2-tuples representing processed
154162
keyword arguments to be sent to Canvas as params or data.
@@ -159,7 +167,16 @@ def request(
159167
:type json: `bool`
160168
:rtype: :class:`requests.Response`
161169
"""
162-
full_url = _url if _url else "{}{}".format(self.base_url, endpoint)
170+
# Check for specific URL endpoints available from Canvas. If not
171+
# specified, pass the given URL and move on.
172+
if not _url:
173+
full_url = "{}{}".format(self.base_url, endpoint)
174+
elif _url == "new_quizzes":
175+
full_url = "{}{}".format(self.new_quizzes_url, endpoint)
176+
elif _url == "graphql":
177+
full_url = self.graphql
178+
else:
179+
full_url = _url
163180

164181
if not headers:
165182
headers = {}

0 commit comments

Comments
 (0)