Skip to content

Commit

Permalink
Merge pull request #181 from lumapps/chore/add-haussman-cells
Browse files Browse the repository at this point in the history
chore(jwt): add haussman address when decoding jwt
  • Loading branch information
Aliai3aiai authored Sep 26, 2022
2 parents 3aefa34 + 2afef67 commit bc00870
Show file tree
Hide file tree
Showing 107 changed files with 3,244 additions and 2,309 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.7.12
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ pytest_args?=-xv
check: check-docs check-code-quality check-types ## Check it all!

check-code-quality: ## Check the code quality.
@$(POETRY) run failprint -t "Checking code quality" -- flake8 --config config/flake8.ini $(PY_SRC)
@$(POETRY) run flake8 --config config/flake8.ini $(PY_SRC)

check-docs: ## Check if the documentation builds correctly.
@$(POETRY) run failprint -t "Building documentation" -- mkdocs build -s
@$(POETRY) run -- mkdocs build

check-types: ## Check that the code is correctly typed.
@$(POETRY) run failprint -t "Type-checking" -- mypy --config-file config/mypy.ini $(PY_SRC)
@$(POETRY) run -- mypy --config-file config/mypy.ini $(PY_SRC)

clean: ## Delete temporary files.
@rm -rf build 2>/dev/null
Expand Down Expand Up @@ -50,8 +50,8 @@ help: ## Print this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

format: ## Run formatting tools on the code.
@$(POETRY) run failprint -t "Formatting code" -- black $(PY_SRC)
@$(POETRY) run failprint -t "Ordering imports" -- isort -y -rc $(PY_SRC)
@$(POETRY) run -- black $(PY_SRC)
@$(POETRY) run -- isort -y -rc $(PY_SRC)

setup: .venv ## Setup the development environment (install dependencies).
$(POETRY) config virtualenvs.in-project true
Expand Down
87 changes: 43 additions & 44 deletions lumapps/api/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def __init__(
proxy_info: Optional[Dict[str, Any]] = None,
):
"""
Args:
auth_info: When specified, a service account or a web auth JSON dict.
api_info: When specified, a JSON dict containing the description of your
api. Defaults to LumApps API.
user: Email of user on behalf of whom to authenticate using domain-wide
delegation.
token: A bearer access token.
token_getter: A bearer access token getter function.
prune: Whether or not to use FILTERS to prune LumApps API responses.
no_verify: Disables SSL verification.
proxy_info: When specified, a JSON dict with proxy parameters.
Args:
auth_info: When specified, a service account or a web auth JSON dict.
api_info: When specified, a JSON dict containing the description of your
api. Defaults to LumApps API.
user: Email of user on behalf of whom to authenticate using domain-wide
delegation.
token: A bearer access token.
token_getter: A bearer access token getter function.
prune: Whether or not to use FILTERS to prune LumApps API responses.
no_verify: Disables SSL verification.
proxy_info: When specified, a JSON dict with proxy parameters.
"""
self._token_expiry = 0
self.no_verify = no_verify
Expand Down Expand Up @@ -200,8 +200,7 @@ def _check_access_token(self):
self.token, self._token_expiry = self.token_getter()

def _prune(self, name_parts, content):
"""Prune the api response.
"""
"""Prune the api response."""
if not self.prune:
return content
for ep_filter in FILTERS:
Expand All @@ -221,7 +220,7 @@ def _prune(self, name_parts, content):
return content

def get_new_client_as_using_dwd(self, user_email: str) -> "BaseClient":
""" Get a new BaseClient using domain-wide delegation """
"""Get a new BaseClient using domain-wide delegation"""
return BaseClient(
auth_info=self._auth_info,
api_info=self.api_info,
Expand All @@ -234,15 +233,15 @@ def get_new_client_as_using_dwd(self, user_email: str) -> "BaseClient":
def get_new_client_as(
self, user_email: str, customer_id: Optional[str] = None
) -> "BaseClient":
""" Get a new BaseClient using an authorized client account by obtaining a
token using the user/getToken endpoint.
"""Get a new BaseClient using an authorized client account by obtaining a
token using the user/getToken endpoint.
Args:
user_email (str): User you want to authenticate on behalf of
customer_id (str): Id of the LumApps customer the user belong to
Args:
user_email (str): User you want to authenticate on behalf of
customer_id (str): Id of the LumApps customer the user belong to
Returns:
BaseClient: A new instance of the BaseClient correctly authenticated.
Returns:
BaseClient: A new instance of the BaseClient correctly authenticated.
"""
client = BaseClient(
auth_info=self._auth_info,
Expand Down Expand Up @@ -353,7 +352,7 @@ def _get_verb_path_params(self, name_parts, params: dict):
return verb, path, params

def _call(self, name_parts: Sequence[str], params: dict, json=None):
""" Construct the call """
"""Construct the call"""
verb, path, params = self._get_verb_path_params(name_parts, params)
resp = self.client.request(verb, path, params=params, json=json)
resp.raise_for_status()
Expand Down Expand Up @@ -398,21 +397,21 @@ def get_call(
) -> Union[Dict[str, Any], List[Dict[str, Any]], None]:
"""Generic function to call a lumapps endpoint
Args:
*name_parts: Endpoint, eg user/get or "user", "get"
**params: Parameters of the call
Args:
*name_parts: Endpoint, eg user/get or "user", "get"
**params: Parameters of the call
Returns:
Object or objects returned by the endpoint call.
Returns:
Object or objects returned by the endpoint call.
Example:
List feedtypes in LumApps:
-> GET https://.../_ah/api/lumsites/v1/feedtype/list
Example:
List feedtypes in LumApps:
-> GET https://.../_ah/api/lumsites/v1/feedtype/list
With this endpoint:
With this endpoint:
>>> feedtypes = get_call("feedtype/list")
>>> print(feedtypes)
>>> feedtypes = get_call("feedtype/list")
>>> print(feedtypes)
"""
name_parts = _parse_endpoint_parts(name_parts)
items: List[dict] = []
Expand Down Expand Up @@ -459,22 +458,22 @@ def iter_call(
None,
]:
"""
Args:
*name_parts: Endpoint, eg user/get or "user", "get"
**params: Parameters of the call
Args:
*name_parts: Endpoint, eg user/get or "user", "get"
**params: Parameters of the call
Yields:
Objects returned by the endpoint call
Yields:
Objects returned by the endpoint call
Example:
List feedtypes in LumApps:
-> GET https://.../_ah/api/lumsites/v1/feedtype/list
Example:
List feedtypes in LumApps:
-> GET https://.../_ah/api/lumsites/v1/feedtype/list
With this endpoint:
With this endpoint:
>>> feedtypes = iter_call("feedtype/list")
>>> for feedtype in feedtypes: print(feedtype)
>>> feedtypes = iter_call("feedtype/list")
>>> for feedtype in feedtypes: print(feedtype)
"""
name_parts = _parse_endpoint_parts(name_parts)
self.cursor = cursor = params.pop("cursor", None)
Expand Down
Loading

0 comments on commit bc00870

Please sign in to comment.