notifications Package¶
models
Module¶
- class lemur.notifications.models.Notification(**kwargs)
Bases:
Model
- active
- certificate
- certificates
- description
- id
- label
- options
- pending_cert
- pending_certificates
- property plugin
- plugin_name
service
Module¶
- lemur.notifications.service.create(label, plugin_name, options, description, certificates)
Creates a new notification.
- Parameters:
label – Notification label
plugin_name –
options –
description –
certificates –
- Return type:
Notification
- Returns:
- lemur.notifications.service.create_default_expiration_notifications(name, recipients, intervals=None)
Will create standard 30, 10 and 2 day notifications for a given owner unless an alternate set of intervals is supplied. If standard notifications already exist these will be returned instead of new notifications.
- Parameters:
name –
recipients –
- Returns:
- lemur.notifications.service.delete(notification_id)
Deletes an notification.
- Parameters:
notification_id – Lemur assigned ID
- lemur.notifications.service.get(notification_id)
Retrieves an notification by its lemur assigned ID.
- Parameters:
notification_id – Lemur assigned ID
- Return type:
Notification
- Returns:
- lemur.notifications.service.get_all()
Retrieves all notification currently known by Lemur.
- Returns:
- lemur.notifications.service.get_by_label(label)
Retrieves a notification by its label
- Parameters:
label –
- Returns:
- lemur.notifications.service.render(args)
- lemur.notifications.service.update(notification_id, label, plugin_name, options, description, active, added_certificates, removed_certificates)
Updates an existing notification.
- Parameters:
notification_id –
label – Notification label
plugin_name –
options –
description –
active –
added_certificates –
removed_certificates –
- Return type:
Notification
- Returns:
views
Module¶
- class lemur.notifications.views.CertificateNotifications
Bases:
AuthenticatedResource
Defines the ‘certificate/<int:certificate_id/notifications’’ endpoint
- endpoint = 'certificateNotifications'
- get(certificate_id)
- GET /certificates/1/notifications¶
The current account list for a given certificates
Example request:
GET /certificates/1/notifications HTTP/1.1 Host: example.com Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "items": [ { "description": "An example", "options": [ { "name": "interval", "required": true, "value": 555, "helpMessage": "Number of days to be alert before expiration.", "validation": "^\d+$", "type": "int" }, { "available": [ "days", "weeks", "months" ], "name": "unit", "required": true, "value": "weeks", "helpMessage": "Interval unit", "validation": "", "type": "select" }, { "name": "recipients", "required": true, "value": "kglisson@netflix.com,example@netflix.com", "helpMessage": "Comma delimited list of email addresses", "validation": "^([\w+-.%]+@[-\w.]+\.[A-Za-z]{2,4},?)+$", "type": "str" } ], "label": "example", "pluginName": "email-notification", "active": true, "id": 2 } ], "total": 1 }
- Query Parameters:
sortBy – field to sort on
sortDir – asc or desc
page – int default is 1
filter – key value pair format is k;v
count – count number default is 10
- Request Headers:
Authorization – OAuth token to authenticate
- Status Codes:
200 OK – no error
- mediatypes()
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class lemur.notifications.views.Notifications
Bases:
AuthenticatedResource
- delete(notification_id)
- endpoint = 'notification'
- get(notification_id)
- GET /notifications/1¶
Get a specific notification
Example request:
GET /notifications/1 HTTP/1.1 Host: example.com Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "description": "a test", "options": [ { "name": "interval", "required": true, "value": 5, "helpMessage": "Number of days to be alert before expiration.", "validation": "^\d+$", "type": "int" }, { "available": [ "days", "weeks", "months" ], "name": "unit", "required": true, "value": "weeks", "helpMessage": "Interval unit", "validation": "", "type": "select" }, { "name": "recipients", "required": true, "value": "kglisson@netflix.com,example@netflix.com", "helpMessage": "Comma delimited list of email addresses", "validation": "^([\w+-.%]+@[-\w.]+\.[A-Za-z]{2,4},?)+$", "type": "str" } ], "label": "test", "pluginName": "email-notification", "active": true, "id": 2 }
- Request Headers:
Authorization – OAuth token to authenticate
- Status Codes:
200 OK – no error
- mediatypes()
- methods: t.ClassVar[t.Collection[str] | None] = {'DELETE', 'GET', 'PUT'}
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- put(notification_id, data=None)
- PUT /notifications/1¶
Updates a notification
Example request:
PUT /notifications/1 HTTP/1.1 Host: example.com Accept: application/json, text/javascript Content-Type: application/json;charset=UTF-8 { "label": "labelChanged", "plugin": { "slug": "email-notification", "plugin_options": "???" }, "description": "Sample notification", "active": "true", "added_certificates": "???", "removed_certificates": "???" }
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 1, "label": "labelChanged", "plugin": { "slug": "email-notification", "plugin_options": "???" }, "description": "Sample notification", "active": "true", "added_certificates": "???", "removed_certificates": "???" }
- Label label:
notification name
- Label slug:
notification plugin slug
- Label plugin_options:
notification plugin options
- Label description:
notification description
- Label active:
whether or not the notification is active/enabled
- Label added_certificates:
certificates to add
- Label removed_certificates:
certificates to remove
- Request Headers:
Authorization – OAuth token to authenticate
- Status Codes:
200 OK – no error
- class lemur.notifications.views.NotificationsList
Bases:
AuthenticatedResource
Defines the ‘notifications’ endpoint
- endpoint = 'notifications'
- get()
- GET /notifications¶
The current account list
Example request:
GET /notifications HTTP/1.1 Host: example.com Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "items": [ { "description": "An example", "options": [ { "name": "interval", "required": true, "value": 5, "helpMessage": "Number of days to be alert before expiration.", "validation": "^\d+$", "type": "int" }, { "available": [ "days", "weeks", "months" ], "name": "unit", "required": true, "value": "weeks", "helpMessage": "Interval unit", "validation": "", "type": "select" }, { "name": "recipients", "required": true, "value": "kglisson@netflix.com,example@netflix.com", "helpMessage": "Comma delimited list of email addresses", "validation": "^([\w+-.%]+@[-\w.]+\.[A-Za-z]{2,4},?)+$", "type": "str" } ], "label": "example", "pluginName": "email-notification", "active": true, "id": 2 } ], "total": 1 }
- Query Parameters:
sortBy – field to sort on
sortDir – asc or desc
page – int default is 1
filter – key value pair format is k;v
count – count number default is 10
- Request Headers:
Authorization – OAuth token to authenticate
- Status Codes:
200 OK – no error
- mediatypes()
- methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'POST'}
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- post(data=None)
- POST /notifications¶
Creates a new notification
Example request:
POST /notifications HTTP/1.1 Host: example.com Accept: application/json, text/javascript Content-Type: application/json;charset=UTF-8 { "description": "a test", "options": [ { "name": "interval", "required": true, "value": 5, "helpMessage": "Number of days to be alert before expiration.", "validation": "^\d+$", "type": "int" }, { "available": [ "days", "weeks", "months" ], "name": "unit", "required": true, "value": "weeks", "helpMessage": "Interval unit", "validation": "", "type": "select" }, { "name": "recipients", "required": true, "value": "kglisson@netflix.com,example@netflix.com", "helpMessage": "Comma delimited list of email addresses", "validation": "^([\w+-.%]+@[-\w.]+\.[A-Za-z]{2,4},?)+$", "type": "str" } ], "label": "test", "pluginName": "email-notification", "active": true, "id": 2 }
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "description": "a test", "options": [ { "name": "interval", "required": true, "value": 5, "helpMessage": "Number of days to be alert before expiration.", "validation": "^\d+$", "type": "int" }, { "available": [ "days", "weeks", "months" ], "name": "unit", "required": true, "value": "weeks", "helpMessage": "Interval unit", "validation": "", "type": "select" }, { "name": "recipients", "required": true, "value": "kglisson@netflix.com,example@netflix.com", "helpMessage": "Comma delimited list of email addresses", "validation": "^([\w+-.%]+@[-\w.]+\.[A-Za-z]{2,4},?)+$", "type": "str" } ], "label": "test", "pluginName": "email-notification", "active": true, "id": 2 }
- Label label:
notification name
- Label slug:
notification plugin slug
- Label plugin_options:
notification plugin options
- Label description:
notification description
- Label active:
whether or not the notification is active/enabled
- Label certificates:
certificates to attach to notification
- Request Headers:
Authorization – OAuth token to authenticate
- Status Codes:
200 OK – no error