class TelnetServerConfig(Transport.CONFIG_CLASS): """ Telnet transport configuration. """ twisted_endpoint = ConfigServerEndpoint( "The endpoint the Telnet server will listen on.", fallbacks=[ServerEndpointFallback('telnet_host', 'telnet_port')], required=True, static=True) to_addr = ConfigText( "The to_addr to use for inbound messages. The default is to use" " the host:port of the telnet server.", default=None, static=True) transport_type = ConfigText( "The transport_type to use for inbound messages.", default='telnet', static=True) # TODO: Deprecate these fields when confmodel#5 is done. telnet_host = ConfigText( "*DEPRECATED* 'telnet_host' and 'telnet_port' fields may be used in" "place of the 'twisted_endpoint' field.", static=True) telnet_port = ConfigInt( "*DEPRECATED* 'telnet_host' and 'telnet_port' fields may be used in" " place of the 'twisted_endpoint' field.", static=True)
class MessageForwardingConfig(ApplicationConfig): '''Config for MessageForwardingWorker application worker''' mo_message_url = ConfigText( "The URL to send HTTP POST requests to for MO messages", default=None, static=True) message_queue = ConfigText("The AMQP queue to forward messages on", default=None, static=True) redis_manager = ConfigDict("Redis config.", required=True, static=True) inbound_ttl = ConfigInt( "Maximum time (in seconds) allowed to reply to messages", required=True, static=True) outbound_ttl = ConfigInt( "Maximum time (in seconds) allowed for events to arrive for messages", required=True, static=True) metric_window = ConfigFloat( "Size of the buckets to use (in seconds) for metrics", required=True, static=True)
class CONFIG_CLASS(BaseWorker.CONFIG_CLASS): worker_name = ConfigText( 'Name of the this message store resource worker', required=True, static=True) twisted_endpoint = ConfigServerEndpoint( 'Twisted endpoint to listen on.', required=True, static=True, fallbacks=[ServerEndpointFallback()]) web_path = ConfigText('The path to serve this resource on.', required=True, static=True) health_path = ConfigText('The path to serve the health resource on.', default='/health/', static=True) riak_manager = ConfigDict('Riak client configuration.', default={}, static=True) redis_manager = ConfigDict('Redis client configuration.', default={}, static=True) # TODO: Deprecate these fields when confmodel#5 is done. host = ConfigText( "*DEPRECATED* 'host' and 'port' fields may be used in place of" " the 'twisted_endpoint' field.", static=True) port = ConfigInt( "*DEPRECATED* 'host' and 'port' fields may be used in place of" " the 'twisted_endpoint' field.", static=True)
class TruteqTransportConfig(Transport.CONFIG_CLASS): username = ConfigText( 'Username of the TruTeq account to connect to.', static=True) password = ConfigText( 'Password for the TruTeq account.', static=True) twisted_endpoint = ConfigClientEndpoint( 'The endpoint to connect to.', default='tcp:host=sms.truteq.com:port=50008', static=True, fallbacks=[ClientEndpointFallback()]) link_check_period = ConfigInt( 'Number of seconds between link checks sent to the server.', default=60, static=True) ussd_session_lifetime = ConfigInt( 'Maximum number of seconds to retain USSD session information.', default=300, static=True) debug = ConfigBool( 'Print verbose log output.', default=False, static=True) redis_manager = ConfigDict( 'How to connect to Redis.', default={}, static=True) # TODO: Deprecate these fields when confmodel#5 is done. host = ConfigText( "*DEPRECATED* 'host' and 'port' fields may be used in place of the" " 'twisted_endpoint' field.", static=True) port = ConfigInt( "*DEPRECATED* 'host' and 'port' fields may be used in place of the" " 'twisted_endpoint' field.", static=True)
class MxitTransportConfig(HttpRpcTransport.CONFIG_CLASS): client_id = ConfigText('The OAuth2 ClientID assigned to this transport.', required=True, static=True) client_secret = ConfigText( 'The OAuth2 ClientSecret assigned to this transport.', required=True, static=True) timeout = ConfigInt('Timeout for outbound Mxit HTTP API calls.', required=False, default=30, static=True) redis_manager = ConfigDict('How to connect to Redis', required=True, static=True) api_send_url = ConfigText('The URL for the Mxit message sending API.', required=False, default="https://api.mxit.com/message/send/", static=True) api_auth_url = ConfigText('The URL for the Mxit authentication API.', required=False, default='https://auth.mxit.com', static=True) api_auth_scopes = ConfigList('The list of scopes to request access to.', required=False, static=True, default=['message/send'])
class NetcoreTransportConfig(Transport.CONFIG_CLASS): twisted_endpoint = ConfigServerEndpoint( 'The endpoint to listen on.', required=True, static=True, fallbacks=[ServerEndpointFallback()]) web_path = ConfigText("The path to serve this resource on.", default='/api/v1/netcore/', static=True) health_path = ConfigText("The path to serve the health resource on.", default='/health/', static=True) reject_none = ConfigBool( "Reject messages where the content parameter equals 'None'", required=False, default=True, static=True) # TODO: Deprecate these fields when confmodel#5 is done. host = ConfigText( "*DEPRECATED* 'host' and 'port' fields may be used in place of the" " 'twisted_endpoint' field.", static=True) port = ConfigInt( "*DEPRECATED* 'host' and 'port' fields may be used in place of the" " 'twisted_endpoint' field.", static=True)
class MTechKenyaTransportConfig(HttpRpcTransport.CONFIG_CLASS): outbound_url = ConfigText('The URL to send outbound messages to.', required=True, static=True) mt_username = ConfigText('The username sent with outbound messages', required=True, static=True) mt_password = ConfigText('The password sent with outbound messages', required=True, static=True)
class GoRouterConfigMixin(GoWorkerConfigMixin): ri_connector_name = ConfigText( "The name of the receive_inbound connector.", required=True, static=True) ro_connector_name = ConfigText( "The name of the receive_outbound connector.", required=True, static=True) router = ConfigRouter("Router instance for this message", required=False)
class HangmanConfig(ApplicationWorker.CONFIG_CLASS): "Hangman worker config." worker_name = ConfigText("Name of this hangman worker.", required=True, static=True) redis_manager = ConfigDict("Redis client configuration.", default={}, static=True) random_word_url = ConfigText("URL to GET a random word from.", required=True)
class JsSandboxConfig(SandboxConfig): "JavaScript sandbox configuration." javascript = ConfigText("JavaScript code to run.", required=True) app_context = ConfigText("Custom context to execute JS with.") logging_resource = ConfigText( "Name of the logging resource to use to report errors detected" " in sandboxed code (e.g. lines written to stderr, unexpected" " process termination). Set to null to disable and report" " these directly using Twisted logging instead.", default='log')
class ChannelStatusConfig(BaseConfig): '''Config for the ChannelStatusWorker''' redis_manager = ConfigDict("Redis config.", required=True, static=True) channel_id = ConfigText( "The channel id which this worker is consuming statuses for", required=True, static=True) status_url = ConfigText("Optional url to POST status events to", default=None, static=True)
class ConversationApiWorkerConfig(BaseWorker.CONFIG_CLASS): worker_name = ConfigText( "Name of this tagpool API worker.", required=True, static=True) web_path = ConfigText( "The path to serve this resource on.", required=True, static=True) web_port = ConfigInt( "The port to server this resource on.", required=True, static=True) health_path = ConfigText( "The path to server the health resource on.", default='/health/', static=True) redis_manager = ConfigDict( "Redis client configuration.", default={}, static=True) riak_manager = ConfigDict( "Riak client configuration.", default={}, static=True)
class CONFIG_CLASS(BaseWorker.CONFIG_CLASS): worker_name = ConfigText( "Name of this Go API worker.", required=True, static=True) twisted_endpoint = ConfigServerEndpoint( "Twisted endpoint to listen on.", required=True, static=True) web_path = ConfigText( "The path to serve this resource on.", required=True, static=True) health_path = ConfigText( "The path to server the health resource on.", default='/health/', static=True) redis_manager = ConfigDict( "Redis client configuration.", default={}, static=True) riak_manager = ConfigDict( "Riak client configuration.", default={}, static=True)
class AfricasTalkingTransportConfig(HttpRpcTransportConfig): api_key = ConfigText('API key', static=True, required=True) username = ConfigText('User name', static=True, required=True) send_sms_api_endpoint = ConfigText('API endpoint', static=True, default='/version1/messaging') outbound_sandbox_url = ConfigText( 'Sandbox URL', static=True, default='https://api.sandbox.africastalking.com') outbound_production_url = ConfigText( 'Production URL', static=True, default='https://api.africastalking.com')
class HTTPRelayConfig(ApplicationWorker.CONFIG_CLASS): # TODO: Make these less static? url = ConfigUrl( "URL to submit incoming message to.", required=True, static=True) event_url = ConfigUrl( "URL to submit incoming events to. (Defaults to the same as 'url').", static=True) http_method = ConfigText( "HTTP method for submitting messages.", default='POST', static=True) auth_method = ConfigText( "HTTP authentication method.", default='basic', static=True) username = ConfigText("Username for HTTP authentication.", default='') password = ConfigText("Password for HTTP authentication.", default='')
class MessageForwardingConfig(ApplicationConfig): '''Config for MessageForwardingWorker application worker''' mo_message_url = ConfigUrl( "The URL to send HTTP POST requests to for MO messages", default=None, static=True) mo_message_url_auth_token = ConfigText( "Authorization Token to use for the mo_message_url", default=None, static=True) mo_message_url_timeout = ConfigInt( "Maximum time (in seconds) a mo_message_url is allowed to take " "to process a message", default=10, static=True) event_url_timeout = ConfigInt( "Maximum time (in seconds) an event_url is allowed to take " "to process an event", default=10, static=True) message_queue = ConfigText("The AMQP queue to forward messages on", default=None, static=True) redis_manager = ConfigDict("Redis config.", required=True, static=True) inbound_ttl = ConfigInt( "Maximum time (in seconds) allowed to reply to messages", required=True, static=True) outbound_ttl = ConfigInt( "Maximum time (in seconds) allowed for events to arrive for messages", required=True, static=True) metric_window = ConfigFloat( "Size of the buckets to use (in seconds) for metrics", required=True, static=True)
class ChannelStatusConfig(BaseConfig): '''Config for the ChannelStatusWorker''' redis_manager = ConfigDict( "Redis config.", required=True, static=True) channel_id = ConfigText( "The channel id which this worker is consuming statuses for", required=True, static=True) status_url = ConfigText( "Optional url to POST status events to", default=None, static=True) status_url_timeout = ConfigInt( "Maximum time (in seconds) a status_url is allowed to take " "to process a status update", default=10, static=True)
class VumiBridgeServerTransportConfig(VumiBridgeClientTransportConfig): # Most of this copied wholesale from vumi.transports.httprpc. web_port = ConfigInt( "The port to listen for requests on, defaults to `0`.", default=0, static=True) message_path = ConfigText("The path to listen for message requests on.", required=True, static=True) event_path = ConfigText("The path to listen for event requests on.", required=True, static=True) health_path = ConfigText( "The path to listen for downstream health checks on" " (useful with HAProxy)", default='health', static=True)
class TransportConfig(BaseWorker.CONFIG_CLASS): """Base config definition for transports. You should subclass this and add transport-specific fields. """ transport_name = ConfigText( "The name this transport instance will use to create its queues.", required=True, static=True)
class MessengerTransportConfig(HttpRpcTransport.CONFIG_CLASS): access_token = ConfigText( "The access_token for the Messenger API", required=True) page_id = ConfigText( "The page id for the Messenger API", required=False, fallbacks=[SingleFieldFallback("app_id")]) app_id = ConfigText( "DEPRECATED The page app id for the Messenger API", required=False) welcome_message = ConfigDict( ("The payload for setting up a welcome message. " "Requires a page_id to be set"), required=False) retrieve_profile = ConfigBool( "Set to true to include the user profile details in " "the helper_metadata", required=False, default=False)
class VumiBridgeClientTransportConfig(Transport.CONFIG_CLASS): account_key = ConfigText('The account key to connect with.', static=True, required=True) conversation_key = ConfigText('The conversation key to use.', static=True, required=True) access_token = ConfigText('The access token for the conversation key.', static=True, required=True) base_url = ConfigText('The base URL for the API', static=True, default='https://go.vumi.org/api/v1/go/http_api/') message_life_time = ConfigInt('How long to keep message_ids around for.', static=True, default=48 * 60 * 60) # default is 48 hours. redis_manager = ConfigDict("Redis client configuration.", default={}, static=True) max_reconnect_delay = ConfigInt( 'Maximum number of seconds between connection attempts', default=3600, static=True) max_retries = ConfigInt( 'Maximum number of consecutive unsuccessful connection attempts ' 'after which no further connection attempts will be made. If this is ' 'not explicitly set, no maximum is applied', static=True) initial_delay = ConfigFloat('Initial delay for first reconnection attempt', default=0.1, static=True) factor = ConfigFloat( 'A multiplicitive factor by which the delay grows', # (math.e) default=2.7182818284590451, static=True) jitter = ConfigFloat( 'Percentage of randomness to introduce into the delay length' 'to prevent stampeding.', # molar Planck constant times c, joule meter/mole default=0.11962656472, static=True)
class AppositTransportConfig(HttpRpcTransport.CONFIG_CLASS): """Apposit transport config.""" credentials = ConfigDict( "A dictionary where the `from_addr` is used for the key lookup and " "the returned value should be a dictionary containing the " "corresponding username, password and service id.", required=True, static=True) outbound_url = ConfigText("The URL to send outbound messages to.", required=True, static=True)
class SandboxConfig(ApplicationWorker.CONFIG_CLASS): sandbox = ConfigDict( "Dictionary of resources to provide to the sandbox." " Keys are the names of resources (as seen inside the sandbox)." " Values are dictionaries which must contain a `cls` key that" " gives the full name of the class that provides the resource." " Other keys are additional configuration for that resource.", default={}, static=True) executable = ConfigText( "Full path to the executable to run in the sandbox.") args = ConfigList( "List of arguments to pass to the executable (not including" " the path of the executable itself).", default=[]) path = ConfigText("Current working directory to run the executable in.") env = ConfigDict("Custom environment variables for the sandboxed process.", default={}) timeout = ConfigInt( "Length of time the subprocess is given to process a message.", default=60) recv_limit = ConfigInt( "Maximum number of bytes that will be read from a sandboxed" " process' stdout and stderr combined.", default=1024 * 1024) rlimits = ConfigDict( "Dictionary of resource limits to be applied to sandboxed" " processes. Defaults are fairly restricted. Keys maybe" " names or values of the RLIMIT constants in" " Python `resource` module. Values should be appropriate integers.", default={}) logging_resource = ConfigText( "Name of the logging resource to use to report errors detected" " in sandboxed code (e.g. lines written to stderr, unexpected" " process termination). Set to null to disable and report" " these directly using Twisted logging instead.", default=None) sandbox_id = ConfigText("This is set based on individual messages.")
class MtnNigeriaUssdTransportConfig(Transport.CONFIG_CLASS): """MTN Nigeria USSD transport configuration.""" server_hostname = ConfigText( "Hostname of the server the transport's client should connect to.", required=True, static=True) server_port = ConfigInt("Port that the server is listening on.", required=True, static=True) username = ConfigText("The username for this transport.", required=True, static=True) password = ConfigText("The password for this transport.", required=True, static=True) application_id = ConfigText( "An application ID required by MTN Nigeria for client authentication.", required=True, static=True) enquire_link_interval = ConfigInt( "The interval (in seconds) between enquire links sent to the server " "to check whether the connection is alive and well.", default=30, static=True) timeout_period = ConfigInt( "How long (in seconds) after sending an enquire link request the " "client should wait for a response before timing out. NOTE: The " "timeout period should not be longer than the enquire link interval", default=30, static=True) user_termination_response = ConfigText( "Response given back to the user if the user terminated the session.", default='Session Ended', static=True) redis_manager = ConfigDict("Parameters to connect to Redis with", default={}, static=True) session_timeout_period = ConfigInt( "Max length (in seconds) of a USSD session", default=600, static=True)
class HTTPWorkerConfig(GoApplicationWorker.CONFIG_CLASS): """Configuration options for StreamingHTTPWorker.""" web_path = ConfigText("The path the HTTP worker should expose the API on.", required=True, static=True) web_port = ConfigInt("The port the HTTP worker should open for the API.", required=True, static=True) health_path = ConfigText( "The path the resource should receive health checks on.", default='/health/', static=True) concurrency_limit = ConfigInt( "Maximum number of clients per account. A value less than " "zero disables the limit", default=10) timeout = ConfigInt( "How long to wait for a response from a server when posting " "messages or events", default=5, static=True)
class CellulantSmsTransportConfig(HttpRpcTransport.CONFIG_CLASS): """Cellulant transport config. """ credentials = ConfigDict( "A dictionary where the `from_addr` is used for the key lookup and the" " returned value should be a dictionary containing the username and" " password.", required=True, static=True) outbound_url = ConfigText("The URL to send outbound messages to.", required=True, static=True)
class DeliverShortMessageProcessorConfig( default.DeliverShortMessageProcessorConfig): max_session_length = ConfigInt( 'Maximum length a USSD sessions data is to be kept for in seconds.', default=60 * 3, static=True) ussd_code_pdu_field = ConfigText( 'PDU field to read the message `to_addr` (USSD code) from. Possible' ' options are "short_message" (the default) and "destination_addr".', default='short_message', static=True)
class ApplicationConfig(BaseWorker.CONFIG_CLASS): """Base config definition for applications. You should subclass this and add application-specific fields. """ transport_name = ConfigText( "The name this application instance will use to create its queues.", required=True, static=True) send_to = ConfigDict("'send_to' configuration dict.", default={}, static=True)
class AirtelUSSDTransportConfig(HttpRpcTransport.CONFIG_CLASS): airtel_username = ConfigText('The username for this transport', default=None, static=True) airtel_password = ConfigText('The password for this transport', default=None, static=True) airtel_charge = ConfigBool( 'Whether or not to charge for the responses sent.', required=False, default=False, static=True) airtel_charge_amount = ConfigInt('How much to charge', default=0, required=False, static=True) redis_manager = ConfigDict('Parameters to connect to Redis with.', default={}, required=False, static=True) session_key_prefix = ConfigText( 'The prefix to use for session key management. Specify this' 'if you are using more than 1 worker in a load-balanced' 'fashion.', default=None, static=True) ussd_session_timeout = ConfigInt('Max length of a USSD session', default=60 * 10, required=False, static=True) to_addr_pattern = ConfigText( 'A regular expression that to_addr values in messages that start a' ' new USSD session must match. Initial messages with invalid' ' to_addr values are rejected.', default=None, required=False, static=True, )
class RapidSMSRelayConfig(ApplicationWorker.CONFIG_CLASS): """RapidSMS relay configuration.""" web_path = ConfigText( "Path to listen for outbound messages from RapidSMS on.", static=True) web_port = ConfigInt( "Port to listen for outbound messages from RapidSMS on.", static=True) redis_manager = ConfigDict( "Redis manager configuration (only required if" " `allow_replies` is true)", default={}, static=True) allow_replies = ConfigBool( "Whether to support replies via the `in_reply_to` argument" " from RapidSMS.", default=True, static=True) vumi_username = ConfigText( "Username required when calling `web_path` (default: no" " authentication)", default=None) vumi_password = ConfigText("Password required when calling `web_path`", default=None) vumi_auth_method = ConfigText( "Authentication method required when calling `web_path`." "The 'basic' method is currently the only available method", default='basic') vumi_reply_timeout = ConfigInt( "Number of seconds to keep original messages in redis so that" " replies may be sent via `in_reply_to`.", default=10 * 60) allowed_endpoints = ConfigList('List of allowed endpoints to send from.', required=True, default=("default", )) rapidsms_url = ConfigUrl("URL of the rapidsms http backend.") rapidsms_username = ConfigText( "Username to use for the `rapidsms_url` (default: no authentication)", default=None) rapidsms_password = ConfigText("Password to use for the `rapidsms_url`", default=None) rapidsms_auth_method = ConfigText( "Authentication method to use with `rapidsms_url`." " The 'basic' method is currently the only available method.", default='basic') rapidsms_http_method = ConfigText( "HTTP request method to use for the `rapidsms_url`", default='POST')