def list_topics(token, app_id=None): """ :param token: The token to be queried :param app_id: application ID """ try: response = push_admin.get_app(app_id).query_subscribe_list(token) return TopicQueryResponse(response) except Exception as e: raise ApiCallError(repr(e))
def unsubscribe_topic(topic, token_list, app_id=None): """ :param topic: The specific topic :param token_list: The token list to be deleted :param app_id: application ID """ try: response = push_admin.get_app(app_id).unsubscribe_topic(topic, token_list) return TopicSubscribeResponse(response) except Exception as e: raise ApiCallError(repr(e))
def send_message(message, validate_only=False, app_id=None): """ Sends the given message Huawei Cloud Messaging (HCM) :param message: An instance of ``messaging.Message``. :param validate_only: A boolean indicating whether to run the operation in dry run mode (optional). :param app_id: app id parameters obtained by developer alliance applying for Push service (optional). :return: SendResponse Raises: ApiCallError: If an error occurs while sending the message to the HCM service. """ try: response = push_admin.get_app(app_id).send(message, validate_only) return SendResponse(response) except Exception as e: raise ApiCallError(repr(e))
def send_message(message, validate_only=False, app_id=None, verify_peer=False): """ Sends the given message Huawei Cloud Messaging (HCM) :param message: An instance of ``messaging.Message``. :param validate_only: A boolean indicating whether to run the operation in dry run mode (optional). :param app_id: app id parameters obtained by developer alliance applying for Push service (optional). :param verify_peer: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``. :return: SendResponse Raises: ApiCallError: If an error occurs while sending the message to the HCM service. """ try: response = push_admin.get_app(app_id).send(message, validate_only, verify_peer=verify_peer) return SendResponse(response) except Exception as e: raise ApiCallError(repr(e))