You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					75 lines
				
				1.9 KiB
			
		
		
			
		
	
	
					75 lines
				
				1.9 KiB
			| 
								 
											8 months ago
										 
									 | 
							
								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
							 |