/* * (c) Copyright, Real-Time Innovations, 2022. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef SERVICE_PROPERTY_H #define SERVICE_PROPERTY_H #define SERVICE_DEFAULT_VERBOSITY 1 #define WEBSERVER_DEFAULT_PORT_STR "8080" #include #include #include namespace rti { namespace webdds { // Forward declaration class AccessController; class LoggerDevice; /** * \ingroup RTI_WebIntegrationServiceLibModule * * @brief Configuration properties for a @product object. */ class WSDDSDllExport ServiceProperty { public: /** * @brief Construct a new Service Property object * */ ServiceProperty(); ServiceProperty(const ServiceProperty&) = delete; ServiceProperty& operator=(const ServiceProperty&) = delete; ServiceProperty(ServiceProperty&&) = default; ServiceProperty& operator=(ServiceProperty&&) = default; /** * @brief Destroy the Service Property object * */ ~ServiceProperty(); /** * @brief Set it to true to enable the Builtin Topics REST API. * * Allows clients to read discovery information through the Builtin Topics. * * @default false */ ServiceProperty& enable_builtin_topics(bool value); /** * @brief Getter (see setter with the same name). */ bool enable_builtin_topics() const; /** * @brief Set it to true to enable the WebSockets REST API. * * Allows clients to read/write data through WebSockets. * * @default false */ ServiceProperty& enable_websockets(bool value); /** * @brief Getter (see setter with the same name). */ bool enable_websockets() const; /** * @brief Getter (see setter with the same name). */ bool list_api_keys() const; /** * @brief Caches entities thread-specific storage. * * Caches WaitSet, Sample Buffer, and DynamicData objects in the * thread-specific storage of the worker threads that handle HTTP requests. * * You can limit the allocated resources by reducing the number of worker * threads via the set_webserver_option() method and setting the option * "num_threads" * * @default false */ ServiceProperty& enable_resource_caching(bool value); /** * @brief Getter (see setter with the same name). */ bool enable_resource_caching() const; /** * @brief Enables the use of a custom logger. * * @default false */ ServiceProperty& use_custom_logger(bool value); /** * @brief Getter (see setter with the same name). */ bool use_custom_logger() const; /*i * @brief Set the Access Control List. * * @default nullptr */ ServiceProperty& acl(std::unique_ptr acl); /*i * @brief Getter (see setter with the same name). */ AccessController *acl() const; /*i * This method enters a key-value pair into the webserver_options_ array. * * @param key Name of the option to be set. * @param value Value of the option. */ ServiceProperty& webserver_option( const std::string& option, const std::string& value); /** * @brief Get the value of the webserver option. * * @param option Option name of the value to get. * @return Pointer to the value if it exists. nullptr otherwise. */ const std::string *webserver_option(const std::string& option) const; /** * @brief This method return the webserver_options_ array. * the values are used as pairs of key-value each 2 values. * * @return const std::vector& */ const std::vector& webserver_options() const; /** * @brief Specifies a configuration file to be loaded. * * @default Empty string */ ServiceProperty& cfgfile(const std::string& cfgfile); /** * @brief Getter (see setter with the same name). */ const std::string& cfgfile() const; /** * @brief The name of the RTI Web Integration Service configuration to run. * * Web Integration Service will look for a matching * \ tag in the configuration file specified via * the cfg_file() method and in the default configuration files. * * @default Empty string */ ServiceProperty& cfgname(const std::string& cfgname); /** * @brief Getter (see setter with the same name). */ const std::string& cfgname() const; /** * @brief The name of the Access Control List file. * * This parameter loads an Access Control List file, which enables access * control in all the HTTP requests and WebSocket (WS) connections. It is * recommended to use this parameter with a secured connection; i.e., it is * important to enable HTTPS and Secure WebSocket (WSS) in every single * listening_ports and provide an -sslCertificate. * * @default Empty string */ ServiceProperty& acl_file(const std::string& acl_file); /** * @brief Getter (see setter with the same name). */ const std::string& acl_file() const; /** * @brief Add a new api key to the list of api keys. * * @default Empty string */ ServiceProperty& create_api_key(const std::string& api_key); /** * @brief Getter (see setter with the same name). */ const std::string& create_api_key() const; /** * @brief Set it to true to list all the API keys available in an Access * Control List file. * * This method must be used in combination with the acl_file method to * specify the file from which API keys should be listed. * * @default false */ ServiceProperty& list_api_keys(bool value); /** * @brief Delete an api key from the list of api keys. * * @default Empty string */ ServiceProperty& delete_api_key(const std::string& api_key); /** * @brief Getter (see setter with the same name). */ const std::string& delete_api_key() const; /*i * @brief Set the verbosity level param, must be used with * setup_verbosity_level() to apply the passed value. */ ServiceProperty& param_verbosity(int verbosity); /*i * @brief Getter (see setter with the same name). */ int param_verbosity(); /*i * @brief Getter (see setter with the same name). */ int dds_verbosity(); /*i * @brief Getter (see setter with the same name). */ int wsdds_verbosity(); /** * @brief Use this attribute to increase the maximum number of objects per * thread of RTI Data Distribution Service. * * @default 1024 */ ServiceProperty& max_objects_per_thread(int max_objects_per_thread); /** * @brief Getter (see setter with the same name). */ int max_objects_per_thread(); /** * @brief Controls what type of messages are logged. * * The available levels are: * * 0. Silent * 1. Exceptions (Connext DDS and Web Integration Service) * 2. Warnings (Web Integration Service) * 3. Information (Web Integration Service) * 4. Warnings (Connext DDS and Web Integration Service) * 5. Tracing (Web Integration Service) * 6. Tracing (Connext DDS and Web Integration Service) * * Each verbosity level includes all the previous levels. * * @default false */ ServiceProperty& setup_verbosity_level(int verbosity_level); /** * @brief Set the up verbosity level that is in verbosity_ atributte. */ ServiceProperty& setup_verbosity_level(); /** * This method installs the custom logger, which enables the user to * store logging messages in the thread-specific storage to be able to * send them in HTTP responses. */ void install_logger(); /** * This method uninstalls the custom logger. */ void uninstall_logger(); private: // Arguments flags bool list_api_keys_; bool enable_resource_caching_; bool enable_builtin_topics_; bool enable_websockets_; // DDS Options std::string cfgfile_; std::string cfgname_; std::string acl_file_; std::string create_api_key_; std::string delete_api_key_; std::string heap_snapshot_dir_; int verbosity_; int dds_verbosity_; int wsdds_verbosity_; int max_objects_per_thread_; // WebServer options std::vector webserver_options_; // Logger device bool use_custom_logger_; std::unique_ptr logger_device_; // Access Controller std::unique_ptr acl_; }; }} // namespace rti::webdds #endif // SERVICE_PROPERTY_H