当前位置: 首页>>代码示例>>Python>>正文


Python Check.timeout方法代码示例

本文整理汇总了Python中hc.api.models.Check.timeout方法的典型用法代码示例。如果您正苦于以下问题:Python Check.timeout方法的具体用法?Python Check.timeout怎么用?Python Check.timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hc.api.models.Check的用法示例。


在下文中一共展示了Check.timeout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checks

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import timeout [as 别名]
def checks(request):
    if request.method == "GET":
        q = Check.objects.filter(user=request.user)
        doc = {"checks": [check.to_dict() for check in q]}
        return JsonResponse(doc)

    elif request.method == "POST":
        check = Check(user=request.user)
        check.name = str(request.json.get("name", ""))
        check.tags = str(request.json.get("tags", ""))
        if "timeout" in request.json:
            check.timeout = td(seconds=request.json["timeout"])
        if "grace" in request.json:
            check.grace = td(seconds=request.json["grace"])

        check.save()

        # This needs to be done after saving the check, because of
        # the M2M relation between checks and channels:
        if request.json.get("channels") == "*":
            check.assign_all_channels()

        return JsonResponse(check.to_dict(), status=201)

    # If request is neither GET nor POST, return "405 Method not allowed"
    return HttpResponse(status=405)
开发者ID:Persistent13,项目名称:healthchecks,代码行数:28,代码来源:views.py

示例2: create_check

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import timeout [as 别名]
def create_check(request):
    if request.method != "POST":
        return HttpResponse(status=405)

    check = Check(user=request.user)
    check.name = str(request.json.get("name", ""))
    check.tags = str(request.json.get("tags", ""))
    if "timeout" in request.json:
        check.timeout = td(seconds=request.json["timeout"])
    if "grace" in request.json:
        check.grace = td(seconds=request.json["grace"])

    check.save()

    response = {
        "ping_url": check.url()
    }

    return JsonResponse(response, status=201)
开发者ID:deliangyang,项目名称:healthchecks,代码行数:21,代码来源:views.py

示例3: create_check

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import timeout [as 别名]
def create_check(request):
    if request.method == "GET":
        code = 200
        response = {
            "checks": [
                {
                    "name": check.name,
                    "ping_url": check.url(),
                    "tags": check.tags,
                    "timeout": int(check.timeout.total_seconds()),
                    "grace": int(check.grace.total_seconds()),
                    # "channels": check.channels,
                }
                for check in Check.objects.filter(user=request.user)
            ]
        }
    elif request.method == "POST":
        check = Check(user=request.user)
        check.name = str(request.json.get("name", ""))
        check.tags = str(request.json.get("tags", ""))
        if "timeout" in request.json:
            check.timeout = td(seconds=request.json["timeout"])
        if "grace" in request.json:
            check.grace = td(seconds=request.json["grace"])

        check.save()

        # This needs to be done after saving the check, because of
        # the M2M relation between checks and channels:
        if request.json.get("channels") == "*":
            check.assign_all_channels()

        code = 201
        response = {"ping_url": check.url()}
    else:
        return HttpResponse(status=405)

    return JsonResponse(response, status=code)
开发者ID:agaridata,项目名称:healthchecks,代码行数:40,代码来源:views.py

示例4: create_check

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import timeout [as 别名]
def create_check(request):
    if request.method != "POST":
        return HttpResponse(status=405)

    check = Check(user=request.user)
    check.name = str(request.json.get("name", ""))
    check.tags = str(request.json.get("tags", ""))
    if "timeout" in request.json:
        check.timeout = td(seconds=request.json["timeout"])
    if "grace" in request.json:
        check.grace = td(seconds=request.json["grace"])

    check.save()

    # This needs to be done after saving the check, because of
    # the M2M relation between checks and channels:
    if request.json.get("channels") == "*":
        check.assign_all_channels()

    response = {
        "ping_url": check.url()
    }

    return JsonResponse(response, status=201)
开发者ID:510908220,项目名称:healthchecks,代码行数:26,代码来源:views.py


注:本文中的hc.api.models.Check.timeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。