Esempio n. 1
0
 def _create_check(name, source_id, type='Threshold', parameters={}):
     with app.app_context():
         return CheckController.create({
             'source_id': source_id,
             'name': name,
             'type': type,
             'parameters': parameters
         })
Esempio n. 2
0
def post_source_check(team_id, source_id):
    """Add a new check.

    .. :quickref: POST; Add a new check.

    **Example request**:

    .. sourcecode:: http

      POST /v1/teams/66859c4a-3e0a-4968-a5a4-4c3b8662acb7/sources/e2c1c635-2d7c-4881-83d1-e4e7027ac7a2/checks HTTP/1.1
      Host: example.com
      Accept: application/json

      {
        "name": "My check",
        "type": "Threshold",
        "parameters": {
          "metric": "foo",
          "threshold": 100
        }
      }

    **Example response**:

    .. sourcecode:: http

      HTTP/1.1 201 CREATED

      {
        'name': 'My check',
        'parameters': {
          'metric': 'foo',
          'threshold': 100
        },
        'type': 'Threshold'
      }

    :resheader Content-Type: application/json
    :status 201: the created check
    """
    if not TeamPermission.is_manager_or_editor(team_id):
        abort(403)

    payload = get_payload()
    payload["source_id"] = source_id

    source = CheckController.create(payload)
    return jsonify(format_check(source)), 201