-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from fgcz/main
bfabric-scripts 1.13.23
- Loading branch information
Showing
66 changed files
with
891 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
changelog.md merge=manual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build" | |
[project] | ||
name = "bfabric" | ||
description = "Python client for the B-Fabric API" | ||
version = "1.13.20" | ||
version = "1.13.21" | ||
license = { text = "GPL-3.0" } | ||
authors = [ | ||
{ name = "Christian Panse", email = "[email protected]" }, | ||
|
@@ -29,6 +29,7 @@ dependencies = [ | |
"eval_type_backport; python_version < '3.10'", | ||
"python-dateutil >= 2.9.0", | ||
"cyclopts >= 2.9.9", | ||
"requests >= 2.26.0", | ||
#"platformdirs >= 4.3", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from __future__ import annotations | ||
|
||
from datetime import datetime | ||
from typing import TYPE_CHECKING | ||
|
||
import requests | ||
from pydantic import BaseModel, Field, SecretStr, ConfigDict | ||
|
||
if TYPE_CHECKING: | ||
from bfabric import BfabricClientConfig | ||
|
||
|
||
class TokenData(BaseModel): | ||
"""Parsed token data from the B-Fabric token validation endpoint.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, str_strip_whitespace=True, json_encoders={datetime: lambda v: v.isoformat()} | ||
) | ||
|
||
job_id: int = Field(alias="jobId") | ||
application_id: int = Field(alias="applicationId") | ||
|
||
entity_class: str = Field(alias="entityClassName") | ||
entity_id: int = Field(alias="entityId") | ||
|
||
user: str = Field(alias="user") | ||
user_ws_password: SecretStr = Field(alias="userWsPassword") | ||
|
||
token_expires: datetime = Field(alias="expiryDateTime") | ||
environment: str | ||
|
||
|
||
def get_token_data(client_config: BfabricClientConfig, token: str) -> TokenData: | ||
"""Returns the token data for the provided token. | ||
If the request fails, an exception is raised. | ||
""" | ||
url = f"{client_config.base_url}/rest/token/validate" | ||
response = requests.get(url, params={"token": token}) | ||
if not response.ok: | ||
response.raise_for_status() | ||
parsed = response.json() | ||
return TokenData.model_validate(parsed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.