Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
brianaydemir committed Mar 25, 2024
1 parent 55a4ef2 commit 4e8d6b5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
25 changes: 15 additions & 10 deletions registry/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import logging
from typing import Optional, Tuple
from typing import Optional

import requests

Expand All @@ -21,10 +21,10 @@ class GenericAPI:
def __init__(
self,
api_base_url: str,
basic_auth: Optional[Tuple[str, str]] = None,
basic_auth: Optional[tuple[str, str]] = None,
):
"""
Constructs a wrapper that uses the provided credentials.
Construct a wrapper that uses the provided credentials.
If a username and password are provided via `basic_auth`, API calls
will be made using Basic authentication.
Expand All @@ -47,7 +47,7 @@ def _renew_session(self) -> None:

def _request(self, method: str, url: str, **kwargs) -> requests.Response:
"""
Logs and sends an HTTP request.
Log and send an HTTP request.
Keyword arguments are passed through unmodified to the `requests`
library's `request` method. If the response contains an error
Expand Down Expand Up @@ -78,28 +78,33 @@ def _request(self, method: str, url: str, **kwargs) -> requests.Response:

def _delete(self, route: str, **kwargs) -> requests.Response:
"""
Logs and sends an HTTP DELETE request for the given route.
Log and send an HTTP DELETE request for the given route.
"""
self._renew_session()

return self._request("DELETE", f"{self._api_base_url}{route}", **kwargs)

def _get(self, route: str, **kwargs) -> requests.Response:
"""
Logs and sends an HTTP GET request for the given route.
Log and send an HTTP GET request for the given route.
"""
return self._request("GET", f"{self._api_base_url}{route}", **kwargs)

def _head(self, route: str, **kwargs) -> requests.Response:
"""
Logs and sends an HTTP HEAD request for the given route.
Log and send an HTTP HEAD request for the given route.
"""
return self._request("HEAD", f"{self._api_base_url}{route}", **kwargs)

def _post(self, route: str, **kwargs) -> requests.Response:
def _patch(self, route: str, **kwargs) -> requests.Response:
"""
Logs and sends an HTTP POST request for the given route.
Log and send an HTTP PATCH request for the given route.
"""
self._renew_session()
return self._request("PATCH", f"{self._api_base_url}{route}", **kwargs)

def _post(self, route: str, **kwargs) -> requests.Response:
"""
Log and send an HTTP POST request for the given route.
"""
self._renew_session()
return self._request("POST", f"{self._api_base_url}{route}", **kwargs)
10 changes: 8 additions & 2 deletions registry/cache.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from flask_caching import Cache
"""
Use a local Python dictionary as a cache.
"""

cache = Cache(config={"CACHE_TYPE": "SimpleCache"})
import flask_caching

__all__ = ["cache"]

cache = flask_caching.Cache(config={"CACHE_TYPE": "SimpleCache"})
4 changes: 3 additions & 1 deletion templates/mock_data.py → templates/mock_oidc_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
# Values set under `MOCK_OIDC_CLAIM` will override environment variables of
# the same name. For example, setting `OIDC_CLAIM_iss` and `OIDC_CLAIM_sub`
# will cause the application to behave as if mod_auth_openidc authenticated
# the user.
# the specified user.
#
# This is primarily useful when testing the web application locally, where
# it is unlikely to have an externally reachable hostname that can be used
# to configure an OIDC client and its callback.
#
# NOTE: CILogon does allow you to register `localhost` URLs as callbacks.
#
MOCK_OIDC_CLAIM = {
"OIDC_CLAIM_iss": "https://cilogon.org",
"OIDC_CLAIM_sub": "http://cilogon.org/<id>",
Expand Down

0 comments on commit 4e8d6b5

Please sign in to comment.