async def deactivate_origin(self, trustedOriginId): """ Args: trusted_origin_id {str} Returns: TrustedOrigin """ http_method = "post".upper() api_url = format_url(f""" {self._base_url} /api/v1/trustedOrigins/{trustedOriginId}/lifecycle /deactivate """) 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, TrustedOrigin) if error: return (None, response, error) try: result = TrustedOrigin(self.form_response_body( response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def update_origin(self, trustedOriginId, trusted_origin, keep_empty_params=False): """ Args: trusted_origin_id {str} {trusted_origin} Returns: TrustedOrigin """ http_method = "put".upper() api_url = format_url(f""" {self._base_url} /api/v1/trustedOrigins/{trustedOriginId} """) if isinstance(trusted_origin, dict): body = trusted_origin else: body = trusted_origin.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, TrustedOrigin) if error: return (None, response, error) try: result = TrustedOrigin(self.form_response_body( response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def list_origins(self, query_params={}, keep_empty_params=False): """ Args: query_params {dict}: Map of query parameters for request [query_params.q] {str} [query_params.filter] {str} [query_params.after] {str} [query_params.limit] {str} Returns: list: Collection of TrustedOrigin instances. """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/trustedOrigins """) if query_params: encoded_query_params = urlencode(query_params) api_url += f"/?{encoded_query_params}" 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, TrustedOrigin) if error: return (None, response, error) try: result = [] for item in response.get_body(): result.append(TrustedOrigin(self.form_response_body(item))) except Exception as error: return (None, response, error) return (result, response, None)
async def get_origin(self, trustedOriginId, keep_empty_params=False): """ Args: trusted_origin_id {str} Returns: TrustedOrigin """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/trustedOrigins/{trustedOriginId} """) 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, TrustedOrigin) if error: return (None, response, error) try: result = TrustedOrigin(self.form_response_body( response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)