async def get_csr_for_identity_provider(self, idpId, csrId): """ Gets a specific Certificate Signing Request model by id Args: idp_id {str} csr_id {str} Returns: Csr """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/idps/{idpId}/credentials/csrs/{csrId} """) body = {} headers = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Csr) if error: return (None, response, error) try: result = Csr(self.form_response_body(response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def generate_csr_for_identity_provider(self, idpId, csr_metadata, keep_empty_params=False): """ Generates a new key pair and returns a Certificate Sign ing Request for it. Args: idp_id {str} {csr_metadata} Returns: Csr """ http_method = "post".upper() api_url = format_url(f""" {self._base_url} /api/v1/idps/{idpId}/credentials/csrs """) if isinstance(csr_metadata, dict): body = csr_metadata else: body = csr_metadata.as_dict() headers = { "Accept": "application/json", "Content-Type": "application/json" } form = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers, form, keep_empty_params=keep_empty_params) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Csr) if error: return (None, response, error) try: result = Csr(self.form_response_body(response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def list_csrs_for_identity_provider(self, idpId, keep_empty_params=False): """ Enumerates Certificate Signing Requests for an IdP Args: idp_id {str} Returns: list: Collection of Csr instances. """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/idps/{idpId}/credentials/csrs """) body = {} headers = {} form = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers, form, keep_empty_params=keep_empty_params) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Csr) if error: return (None, response, error) try: result = [] for item in response.get_body(): result.append(Csr(self.form_response_body(item))) except Exception as error: return (None, response, error) return (result, response, None)
async def get_csr_for_application( self, appId, csrId ): """ Method for /api/v1/apps/{appId}/credentials/csrs/{csrId} Args: app_id {str} csr_id {str} Returns: Csr """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/apps/{appId}/credentials/csrs/{csrId} """) body = {} headers = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers ) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Csr) if error: return (None, response, error) try: result = Csr( self.form_response_body(response.get_body()) ) except Exception as error: return (None, response, error) return (result, response, None)