How to use the klein.route function in klein

To help you get started, we’ve selected a few klein examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route(('//autoscale//policy'),
       methods=['POST'])
@fails_with(exception_codes)
@succeeds_with(201)
@validate_body(sg_schema.policy)
def create_policy(request, tenantId, groupId, data):
    """
    Create a new scaling policy. Scaling policies must include a name, type,
    adjustment, and cooldown.
    The response header will point to the newly created policy.
    This data provided in the request body in JSON format.

    Example request::

        {
            "name": "scale up by one server",
            "change": 1,
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route(('//autoscale//launch'),
       methods=['PUT'])
@fails_with(exception_codes)
@succeeds_with(204)
@validate_body(sg_schema.launch_config)
def edit_launch_config(request, tenantId, groupId, data):
    """
    Edit the launch configuration for a scaling group, which includes the
    details of how to create a server, from what image, which load balancers to
    join it to, and what networks to add it to, and other metadata.
    This data provided in the request body in JSON format.
    If successful, no response body will be returned.

    Example request::

        {
            "type": "launch_server",
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route('//autoscale/', methods=['GET'])
@fails_with(exception_codes)
@succeeds_with(200)
def view_manifest_config_for_scaling_group(request, tenantId, groupId):
    """
    View manifested view of the scaling group configuration, including the
    launch configuration, and the scaling policies.  This data is returned in
    the body of the response in JSON format.

    Example response::

        {
            "groupConfiguration": {
                "name": "workers",
                "cooldown": 60,
                "minEntities": 5,
                "maxEntities": 100,
github squeaky-pl / zenchmarks / zenhttp_klein.py View on Github external
@route("/", methods=["GET"])
def resource(request):
    letter = request.args.get("q", [None])[0]
    if not letter:
        request.setResponseCode(BAD_REQUEST)
        return "Bad Request"

    try:
        zenline = zenlines[letter]
    except KeyError:
        request.setResponseCode(NOT_FOUND)
        return "Not Found"

    return zenline
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route(('//autoscale/'
        '/policy//webhook'),
       methods=['GET'])
@fails_with(exception_codes)
@succeeds_with(200)
def view_all_webhooks(request, tenantId, groupId, policyId):
    """
    Get a mapping of IDs to their respective scaling policy webhooks.
    Each webhook has a name, url, and cooldown.
    This data is returned in the body of the response in JSON format.

    Example response::

        {
            "42fa3cb-bfb0-44c0-85fa-3cfbcbe5c257": {
                "name": "pagerduty",
                "URL":
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route('//autoscale', methods=['POST'])
@fails_with(exception_codes)
@succeeds_with(201)
@validate_body(sg_schema.create_group)
def create_new_scaling_group(request, tenantId, data):
    """
    Create a new scaling group, given the general scaling group configuration,
    launch configuration, and optional scaling policies.  This data provided
    in the request body in JSON format. If successful, no response body will
    be returned.

    Example request body containing some scaling policies::

        {
            "groupConfiguration": {
                "name": "workers",
                "cooldown": 60,
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route('//autoscale',  methods=['GET'])
@fails_with(exception_codes)
@succeeds_with(200)
def list_all_scaling_groups(request, tenantId):
    """
    Lists all the autoscaling groups per for a given tenant ID.

    Example response::

        [
          {
            "id": "{groupId1}"
            "links": [
              {
                "href": "https://dfw.autoscale.api.rackspacecloud.com/v1.0/010101/autoscale/{groupId1}"
                "rel": "self"
              },
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route('//autoscale//state', methods=['GET'])
@fails_with(exception_codes)
@succeeds_with(200)
def get_scaling_group_state(request, tenantId, coloId, groupId):
    """
    Get the current state of the scaling group, including the current set of
    active entities, the current set of pending entities, the desired number
    of entities, the current desired number of steady state servers.  This
    data is returned in the body of the response in JSON format.

    Example response::

        {
            "active": [
                {
                    "id": "{instance_id}",
                    "link": "https://dfw.servers.api.rackspacecloud.com/v2/203515/servers/{instance_id}"
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route('//autoscale//policy/',
       methods=['DELETE'])
@fails_with(exception_codes)
@succeeds_with(204)
def delete_policy(request, tenantId, groupId, policyId):
    """
    Delete a scaling policy. If successful, no response body will be returned.
    """
    deferred = defer.maybeDeferred(get_store().delete_policy,
                                   tenantId, groupId, policyId)
    return deferred
github rackerlabs / otter / otter / _scaling_groups_rest.py View on Github external
@route(('//autoscale/'
        '/policy//webhook/'),
       methods=['GET'])
@fails_with(exception_codes)
@succeeds_with(200)
def view_webhook(request, tenantId, groupId, policyId, webhookId):
    """
    Get information about a specific scaling policy webhook.
    Each webhook has a name, url, and cooldown.
    This data is returned in the body of the response in JSON format.

    Example response::

        {
            "name": "pagerduty",
            "URL":
                "autoscale.api.rackspacecloud.com/v1.0/action/