1.0.0
This commit is contained in:
74
src/dynamix_sdk/decs3o.py
Normal file
74
src/dynamix_sdk/decs3o.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from dynamix_sdk import base, config
|
||||
|
||||
|
||||
class DECS3OAuth(config.AuthenticatorProtocol):
|
||||
_config: config.Config
|
||||
client_id: str
|
||||
client_secret: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
url: str,
|
||||
client_id: str,
|
||||
client_secret: str,
|
||||
verify_ssl: bool = True,
|
||||
http503_attempts: int = 10,
|
||||
http503_attempts_interval: int = 5,
|
||||
result_extra_allow: bool = True,
|
||||
):
|
||||
self._config = config.Config(
|
||||
base_api_path='/v1',
|
||||
url=url,
|
||||
verify_ssl=verify_ssl,
|
||||
http503_attempts=http503_attempts,
|
||||
http503_attempts_interval=http503_attempts_interval,
|
||||
result_extra_allow=result_extra_allow,
|
||||
)
|
||||
|
||||
self.client_id = client_id
|
||||
self.client_secret = client_secret
|
||||
|
||||
@property
|
||||
def api(self):
|
||||
return DECS3OAPI(config=self._config)
|
||||
|
||||
def get_jwt(self):
|
||||
return self.api.oauth__access_token(
|
||||
client_id=self.client_id,
|
||||
client_secret=self.client_secret,
|
||||
grant_type='client_credentials',
|
||||
response_type='id_token',
|
||||
)
|
||||
|
||||
|
||||
class DECS3OOauthAccesstokenResultStr(base.BaseAPIResultStr):
|
||||
pass
|
||||
|
||||
|
||||
class DECS3OOauthAccesstokenProtocol(base.BasePostAPIFunctionProtocol):
|
||||
def oauth__access_token(
|
||||
self,
|
||||
*,
|
||||
client_id: str,
|
||||
client_secret: str,
|
||||
grant_type: None | str = None,
|
||||
response_type: None | str = None,
|
||||
validity: None | int = None,
|
||||
) -> DECS3OOauthAccesstokenResultStr:
|
||||
...
|
||||
|
||||
|
||||
class DECS3OAPI(
|
||||
base.BaseAPI,
|
||||
DECS3OOauthAccesstokenProtocol,
|
||||
path_mapping_dict={'oauth__access_token': 'oauth/access_token'},
|
||||
name_mapping_dict={
|
||||
'client_id': 'client_id',
|
||||
'client_secret': 'client_secret',
|
||||
'grant_type': 'grant_type',
|
||||
'response_type': 'response_type',
|
||||
'validity': 'validity',
|
||||
},
|
||||
post_json=False,
|
||||
):
|
||||
pass
|
||||
Reference in New Issue
Block a user