def get(self): """ .. http:get:: /plugins The current plugin list **Example request**: .. sourcecode:: http GET /plugins HTTP/1.1 Host: example.com Accept: application/json, text/javascript **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "items": [ { "id": 2, "accountNumber": 222222222, "label": "account2", "description": "this is a thing" }, { "id": 1, "accountNumber": 11111111111, "label": "account1", "description": "this is a thing" }, ] "total": 2 } :reqheader Authorization: OAuth token to authenticate :statuscode 200: no error """ self.reqparse.add_argument('type', type=str, location='args') args = self.reqparse.parse_args() if args['type']: return list(plugins.all(plugin_type=args['type'])) return list(plugins.all())
def send_expiration_notifications(): """ This function will check for upcoming certificate expiration, and send out notification emails at given intervals. """ sent = 0 for plugin in plugins.all(plugin_type='notification'): notifications = database.db.session.query(Notification)\ .filter(Notification.plugin_name == plugin.slug)\ .filter(Notification.active == True).all() # noqa messages = [] for n in notifications: for c in n.certificates: if _is_eligible_for_notifications(c): messages.append((_get_message_data(c), n.options)) messages = _deduplicate(messages) for data, targets, options in messages: sent += 1 plugin.send('expiration', data, targets, options) current_app.logger.info("Lemur has sent {0} certification notifications".format(sent)) return sent