def __build_isolines_quota_service(self, username, provider, orgname=None, soft_limit=False, quota=100, end_date=datetime.today()): self.__prepare_quota_service(username, 'isolines', quota, provider, orgname, soft_limit, end_date) isolines_config = IsolinesRoutingConfig(self.redis_conn, plpy_mock, username, orgname) return QuotaService(isolines_config, redis_connection=self.redis_conn)
def __build_geocoder_quota_service(self, username, quota=100, provider='heremaps', orgname=None, soft_limit=False, end_date=datetime.today()): self.__prepare_quota_service(username, 'geocoding', quota, provider, orgname, soft_limit, end_date) geocoder_config = GeocoderConfig(self.redis_conn, plpy_mock, username, orgname) return QuotaService(geocoder_config, redis_connection=self.redis_conn)
def __build_obs_quota_service(self, username, quota=100, provider='obs_general', orgname=None, soft_limit=False, end_date=datetime.today()): self.__prepare_quota_service(username, 'data_observatory', quota, None, orgname, soft_limit, end_date) do_config = ObservatoryConfig(self.redis_conn, plpy_mock, username, orgname) return QuotaService(do_config, redis_connection=self.redis_conn)
def __build_routing_quota_service(self, username, provider='mapzen', orgname=None, soft_limit=False, quota=100, end_date=datetime.today()): self.__prepare_quota_service(username, 'routing', quota, provider, orgname, soft_limit, end_date) routing_config = RoutingConfig(self.redis_conn, plpy_mock, username, orgname) return QuotaService(routing_config, redis_connection=self.redis_conn)
def __build_obs_snapshot_quota_service(self, username, quota=100, service='obs_snapshot', orgname=None, soft_limit=False, end_date=datetime.today()): self.__prepare_quota_service(username, 0, service, orgname, False, quota, soft_limit, end_date) do_config = ObservatorySnapshotConfig(self.redis_conn, plpy_mock, username, orgname) return QuotaService(do_config, redis_connection=self.redis_conn)
def __init__(self, service, config_builder, username, orgname): service_config = ServiceConfiguration(service, username, orgname) logger_config = LoggerConfigBuilder(service_config.environment, service_config.server).get() self.logger = Logger(logger_config) self.config = config_builder(service_config.server, service_config.user, service_config.org, username, orgname).get() rate_limit_config = RateLimitsConfigBuilder(service_config.server, service_config.user, service_config.org, service=service, username=username, orgname=orgname).get() redis_metrics_connection = RedisMetricsConnectionFactory(service_config.environment, service_config.server).get() self.rate_limiter = RateLimiter(rate_limit_config, redis_metrics_connection) self.quota_service = QuotaService(self.config, redis_metrics_connection)
def __init__(self, service, username, orgname, gd): redis_conn = gd["redis_connection_{0}".format( username)]['redis_metrics_connection'] self.config = gd["user_{0}_config_{1}".format(service, username)] logger_config = gd["logger_config"] self.logger = Logger(logger_config) self.quota_service = QuotaService(self.config, redis_conn) rate_limit_config = RateLimitsConfigLegacyBuilder( redis_conn, plpy, service=service, username=username, orgname=orgname).get() self.rate_limiter = RateLimiter(rate_limit_config, redis_conn)