def _parse_client(self, values, conn): application_apikey = values.get('client') if not application_apikey: raise errors.MissingParameterError('client') self.application_id = lookup_application_id_by_apikey(conn, application_apikey) if not self.application_id: raise errors.InvalidAPIKeyError()
def parse(self, values, conn): super(LookupStatsHandlerParams, self).parse(values, conn) self.secret = values.get('secret') apikeys = values.getlist('client') if not apikeys: raise errors.InvalidAPIKeyError() self.applications = find_applications_by_apikeys(conn, apikeys) if not self.applications: raise errors.InvalidAPIKeyError() self.from_date = values.get('from') if self.from_date is not None: self.from_date = datetime.datetime.strptime(self.from_date, '%Y-%m-%d').date() self.to_date = values.get('to') if self.to_date is not None: self.to_date = datetime.datetime.strptime(self.to_date, '%Y-%m-%d').date() self.days = values.get('days', type=int)
def _parse_client(self, values, db): application_apikey = values.get('client') if not application_apikey: raise errors.MissingParameterError('client') self.application_id = check_app_api_key(self.config, db, application_apikey) if not self.application_id: logger.warning("Invalid API key %s", application_apikey) raise errors.InvalidAPIKeyError() self.application_version = values.get('clientversion')
def _handle_internal(self, params): if self.ctx.config.cluster.secret != params.secret: logger.warning('Invalid cluster secret') raise errors.NotAllowedError() application_id = check_app_api_key(self.ctx.config, self.ctx.db.get_app_db(), params.api_key) if not application_id: raise errors.InvalidAPIKeyError() return {'id': application_id}
def _parse_client(self, values, conn): application_apikey = values.get('client') if not application_apikey: raise errors.MissingParameterError('client') self.application_id = lookup_application_id_by_apikey( conn, application_apikey, only_active=True) if not self.application_id: if check_demo_client_api_key(self.config.website.secret, application_apikey): self.application_id = DEMO_APPLICATION_ID else: logger.error("Invalid API key %s", application_apikey) raise errors.InvalidAPIKeyError() self.application_version = values.get('clientversion')
def _handle_internal(self, params): raise errors.InvalidAPIKeyError()