Example #1
0
    def put(self, notification_id):
        """
        .. http:put:: /notifications/1

           Updates an account

           **Example request**:

           .. sourcecode:: http

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

              {
                "id": 1,
                "accountNumber": 11111111111,
                "label": "labelChanged",
                "comments": "this is a thing"
              }

           :arg accountNumber: aws account number
           :arg label: human readable account label
           :arg comments: some description about the account
           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
        """
        self.reqparse.add_argument('label',
                                   type=str,
                                   location='json',
                                   required=True)
        self.reqparse.add_argument('plugin',
                                   type=dict,
                                   location='json',
                                   required=True)
        self.reqparse.add_argument('active', type=bool, location='json')
        self.reqparse.add_argument('certificates',
                                   type=list,
                                   default=[],
                                   location='json')
        self.reqparse.add_argument('description', type=str, location='json')

        args = self.reqparse.parse_args()
        return service.update(notification_id, args['label'],
                              args['plugin']['pluginOptions'],
                              args['description'], args['active'],
                              args['certificates'])
Example #2
0
def prepare_test():
    verify_sender_email()  # emails are sent to owner and security; SNS only used for configured notification

    # set all existing notifications to disabled so we don't have multiple conflicting in the tests
    for prior_notification in service.get_all():
        service.update(prior_notification.id, prior_notification.label, prior_notification.plugin_name,
                       prior_notification.options, prior_notification.description, False, [], [])

    notification = NotificationFactory(plugin_name="aws-sns")
    notification.options = get_options()

    now = arrow.utcnow()
    in_ten_days = now + timedelta(days=10, hours=1)  # a bit more than 10 days since we'll check in the future

    certificate = CertificateFactory()
    certificate.not_after = in_ten_days
    certificate.notifications.append(notification)

    return notification, certificate
Example #3
0
    def put(self, notification_id):
        """
        .. http:put:: /notifications/1

           Updates an account

           **Example request**:

           .. sourcecode:: http

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

              {
                "id": 1,
                "accountNumber": 11111111111,
                "label": "labelChanged",
                "comments": "this is a thing"
              }

           :arg accountNumber: aws account number
           :arg label: human readable account label
           :arg comments: some description about the account
           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
        """
        self.reqparse.add_argument('label', type=str, location='json', required=True)
        self.reqparse.add_argument('plugin', type=dict, location='json', required=True)
        self.reqparse.add_argument('active', type=bool, location='json')
        self.reqparse.add_argument('certificates', type=list, default=[], location='json')
        self.reqparse.add_argument('description', type=str, location='json')

        args = self.reqparse.parse_args()
        return service.update(
            notification_id,
            args['label'],
            args['plugin']['pluginOptions'],
            args['description'],
            args['active'],
            args['certificates']
        )
Example #4
0
    def put(self, notification_id, data=None):
        """
        .. http:put:: /notifications/1

           Updates an account

           **Example request**:

           .. sourcecode:: http

              POST /notifications/1 HTTP/1.1
              Host: example.com
              Accept: application/json, text/javascript
              Content-Type: application/json;charset=UTF-8


           **Example response**:

           .. sourcecode:: http

              HTTP/1.1 200 OK
              Vary: Accept
              Content-Type: text/javascript

              {
                "id": 1,
                "accountNumber": 11111111111,
                "label": "labelChanged",
                "comments": "this is a thing"
              }

           :arg accountNumber: aws account number
           :arg label: human readable account label
           :arg comments: some description about the account
           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
        """
        return service.update(
            notification_id,
            data["label"],
            data["plugin"]["slug"],
            data["plugin"]["plugin_options"],
            data["description"],
            data["active"],
            data["certificates"],
        )
Example #5
0
File: views.py Project: harmw/lemur
    def put(self, notification_id, data=None):
        """
        .. http:put:: /notifications/1

           Updates an account

           **Example request**:

           .. sourcecode:: http

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

              {
                "id": 1,
                "accountNumber": 11111111111,
                "label": "labelChanged",
                "comments": "this is a thing"
              }

           :arg accountNumber: aws account number
           :arg label: human readable account label
           :arg comments: some description about the account
           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
        """
        return service.update(
            notification_id,
            data['label'],
            data['plugin']['plugin_options'],
            data['description'],
            data['active'],
            data['certificates']
        )
Example #6
0
    def put(self, notification_id, data=None):
        """
        .. http:put:: /notifications/1

           Updates a notification

           **Example request**:

           .. sourcecode:: http

              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**:

           .. sourcecode:: http

              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
           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
        """
        return service.update(
            notification_id,
            data["label"],
            data["plugin"]["slug"],
            data["plugin"]["plugin_options"],
            data["description"],
            data["active"],
            data["added_certificates"],
            data["removed_certificates"],
        )