Ignore submitted certificates
This commit is contained in:
parent
1918b911b3
commit
85b053ed98
|
@ -20,7 +20,6 @@ class NotificationInputSchema(LemurInputSchema):
|
||||||
description = fields.String()
|
description = fields.String()
|
||||||
active = fields.Boolean()
|
active = fields.Boolean()
|
||||||
plugin = fields.Nested(PluginInputSchema, required=True)
|
plugin = fields.Nested(PluginInputSchema, required=True)
|
||||||
certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
|
||||||
added_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
added_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
||||||
removed_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
removed_certificates = fields.Nested(AssociatedCertificateSchema, many=True, missing=[])
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ def create(label, plugin_name, options, description, certificates):
|
||||||
return database.create(notification)
|
return database.create(notification)
|
||||||
|
|
||||||
|
|
||||||
def update(notification_id, label, plugin_name, options, description, active, certificates, added_certificates, removed_certificates):
|
def update(notification_id, label, plugin_name, options, description, active, added_certificates, removed_certificates):
|
||||||
"""
|
"""
|
||||||
Updates an existing notification.
|
Updates an existing notification.
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@ def update(notification_id, label, plugin_name, options, description, active, ce
|
||||||
:param options:
|
:param options:
|
||||||
:param description:
|
:param description:
|
||||||
:param active:
|
:param active:
|
||||||
:param certificates:
|
|
||||||
:param added_certificates:
|
:param added_certificates:
|
||||||
:param removed_certificates:
|
:param removed_certificates:
|
||||||
:rtype: Notification
|
:rtype: Notification
|
||||||
|
@ -127,11 +126,8 @@ def update(notification_id, label, plugin_name, options, description, active, ce
|
||||||
notification.options = options
|
notification.options = options
|
||||||
notification.description = description
|
notification.description = description
|
||||||
notification.active = active
|
notification.active = active
|
||||||
if certificates:
|
notification.certificates = notification.certificates + added_certificates
|
||||||
notification.certificates = certificates
|
notification.certificates = [c for c in notification.certificates if c not in removed_certificates]
|
||||||
else:
|
|
||||||
notification.certificates = notification.certificates + added_certificates
|
|
||||||
notification.certificates = [c for c in notification.certificates if c not in removed_certificates]
|
|
||||||
|
|
||||||
return database.update(notification)
|
return database.update(notification)
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ class NotificationsList(AuthenticatedResource):
|
||||||
"""
|
"""
|
||||||
.. http:post:: /notifications
|
.. http:post:: /notifications
|
||||||
|
|
||||||
Creates a new account
|
Creates a new notification
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -214,9 +214,12 @@ class NotificationsList(AuthenticatedResource):
|
||||||
"id": 2
|
"id": 2
|
||||||
}
|
}
|
||||||
|
|
||||||
:arg accountNumber: aws account number
|
:label label: notification name
|
||||||
:arg label: human readable account label
|
:label slug: notification plugin slug
|
||||||
:arg comments: some description about the account
|
: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
|
||||||
:reqheader Authorization: OAuth token to authenticate
|
:reqheader Authorization: OAuth token to authenticate
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
"""
|
"""
|
||||||
|
@ -306,17 +309,29 @@ class Notifications(AuthenticatedResource):
|
||||||
"""
|
"""
|
||||||
.. http:put:: /notifications/1
|
.. http:put:: /notifications/1
|
||||||
|
|
||||||
Updates an account
|
Updates a notification
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
POST /notifications/1 HTTP/1.1
|
PUT /notifications/1 HTTP/1.1
|
||||||
Host: example.com
|
Host: example.com
|
||||||
Accept: application/json, text/javascript
|
Accept: application/json, text/javascript
|
||||||
Content-Type: application/json;charset=UTF-8
|
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**:
|
**Example response**:
|
||||||
|
|
||||||
|
@ -328,14 +343,24 @@ class Notifications(AuthenticatedResource):
|
||||||
|
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"accountNumber": 11111111111,
|
|
||||||
"label": "labelChanged",
|
"label": "labelChanged",
|
||||||
"comments": "this is a thing"
|
"plugin": {
|
||||||
|
"slug": "email-notification",
|
||||||
|
"plugin_options": "???"
|
||||||
|
},
|
||||||
|
"description": "Sample notification",
|
||||||
|
"active": "true",
|
||||||
|
"added_certificates": "???",
|
||||||
|
"removed_certificates": "???"
|
||||||
}
|
}
|
||||||
|
|
||||||
:arg accountNumber: aws account number
|
:label label: notification name
|
||||||
:arg label: human readable account label
|
:label slug: notification plugin slug
|
||||||
:arg comments: some description about the account
|
: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
|
||||||
:reqheader Authorization: OAuth token to authenticate
|
:reqheader Authorization: OAuth token to authenticate
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
"""
|
"""
|
||||||
|
@ -346,7 +371,6 @@ class Notifications(AuthenticatedResource):
|
||||||
data["plugin"]["plugin_options"],
|
data["plugin"]["plugin_options"],
|
||||||
data["description"],
|
data["description"],
|
||||||
data["active"],
|
data["active"],
|
||||||
data["certificates"],
|
|
||||||
data["added_certificates"],
|
data["added_certificates"],
|
||||||
data["removed_certificates"],
|
data["removed_certificates"],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue