notifications Package

models Module

class lemur.notifications.models.Notification(**kwargs)

Bases: flask_sqlalchemy.Model

active
certificates
description
id
label
options
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

:rtype : Notification :return:

lemur.notifications.service.create_default_expiration_notifications(name, recipients)

Will create standard 30, 10 and 2 day notifications for a given owner. 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

:rtype : Notification :return:

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, options, description, active, certificates)

Updates an existing notification.

Parameters:
  • notification_id
  • label – Notification label
  • options
  • description
  • active
  • certificates

:rtype : Notification :return:

views Module

class lemur.notifications.views.CertificateNotifications

Bases: lemur.auth.service.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:
 
Status Codes:
mediatypes(resource_cls)
methods = ['GET']
class lemur.notifications.views.Notifications

Bases: lemur.auth.service.AuthenticatedResource

delete(notification_id)
endpoint = 'notification'
get(notification_id)
GET /notifications/1

Get a specific account

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:
 
Status Codes:
mediatypes(resource_cls)
methods = ['DELETE', 'GET', 'PUT']
put(notification_id, data=None)
PUT /notifications/1

Updates an account

Example request:

POST /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

{
  "id": 1,
  "accountNumber": 11111111111,
  "label": "labelChanged",
  "comments": "this is a thing"
}
Parameters:
  • accountNumber – aws account number
  • label – human readable account label
  • comments – some description about the account
Request Headers:
 
Status Codes:
class lemur.notifications.views.NotificationsList

Bases: lemur.auth.service.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:
 
Status Codes:
mediatypes(resource_cls)
methods = ['GET', 'POST']
post(data=None)
POST /notifications

Creates a new account

Example request:

POST /notifications HTTP/1.1
Host: example.com
Accept: application/json, 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
}

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
}
Parameters:
  • accountNumber – aws account number
  • label – human readable account label
  • comments – some description about the account
Request Headers:
 
Status Codes: