def get_pubsub_request()

in src/pubsub/pubsub_messages.py [0:0]


    def get_pubsub_request(self, command, reply_topic, reply_sdk='ipc', params=None):
        '''
        
        Returns a well formatted PubSub REQUEST Message.
        
        Parameters
        ----------
        message-id: str
            Timestamp or other unique identifier for message tracking across request / response.
        reply-topic : str
            IPC / MQTT Topic that the receiving component will respond with as per the request type.
        reply-sdk : str, default='ipc' valid=['ipc','mqtt']
            The AWS Greengrass SDK that a response is routed to. 
            Valid options are:
                * 'ipc' : route the response via the IPC Component to Component PubSub SDK or 
                * 'mqtt' : route the response via the IoT Core PubSub SDK.
        command : str
            Name of the command, request or action to execute on the receiving component.
        params: any (preferred dict), default=None
                Dict, Array or any object able to be JSON serialised with specific parameters of the requested command to execute. 
        '''
        
        # Return a well formatted PubSub REQUEST
        return {
            'message-id' : datetime.now().strftime("%Y%m%d%H%M%S%f"), # Generated Timestamp / ID to track the request flow.
            'reply-sdk' : reply_sdk,                    # Reply SDK (MQTT Core or IPC topic between Greengrass components.)
            'reply-topic' : reply_topic,                # IPC / MQTT Topic the response should be published to.
            'reqres' : 'request',                       # Indicates is a REQUEST message type to aid application routing.
            'command' : command,                        # Command indicating the data or action that is being requested.
            'params' : params                           # Optional params specific to the request type (Use None instead of removing the field).
        }