aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java
blob: ad0f3e094eba747392521e76566f9dc3a551fe93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.restapi;

import com.yahoo.vespa.jaxrs.annotation.PATCH;
import com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse;
import com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest;
import com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse;
import com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;

/**
 * Definition of Orchestrator's REST API for hosts.
 *
 * Implementing classes must not put any JAX-RS annotation on the overridden methods. Doing so will cause all
 * method annotations in this interface to be ignored by the JAX-RS container (see section 3.6 of JSR-339).
 *
 * @author bakksjo
 */
public interface HostApi {
    /**
     * Path prefix for this api. Resources implementing this API should use this with a @Path annotation.
     */
    String PATH_PREFIX = "/v1/hosts";

    /**
     * Shows the Orchestrator state of a host.
     * 
     * @param hostNameString the fully qualified host name
     */
    @GET
    @Path("/{hostname}")
    @Produces(MediaType.APPLICATION_JSON)
    GetHostResponse getHost(@PathParam("hostname") String hostNameString);

    /**
     * Tweak internal Orchestrator state for host.
     */
    @PATCH
    @Path("/{hostname}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    PatchHostResponse patch(@PathParam("hostname") String hostNameString, PatchHostRequest request);

    /**
     * Ask for permission to temporarily suspend all services on a host.
     *
     * On success, none, some, or all services on the host may already have been effectively suspended,
     * e.g. as of Feb 2015, a content node would already be set in the maintenance state.
     *
     * Once the host is ready to resume normal operations, it must finish with resume() (see below).
     *
     * If the host has already been granted permission to suspend all services, requesting
     * suspension again is idempotent and will succeed.
     *
     * @param hostNameString the fully qualified host name.
     */
    @PUT
    @Path("/{hostname}/suspended")
    @Produces(MediaType.APPLICATION_JSON)
    UpdateHostResponse suspend(@PathParam("hostname") String hostNameString);

    /**
     * Resume normal operations for all services on a host that has previously been allowed suspension.
     *
     * If the host is already registered as running normal operations, then resume() is idempotent
     * and will succeed.
     *
     * @param hostNameString the fully qualified host name.
     */
    @DELETE
    @Path("/{hostname}/suspended")
    @Produces(MediaType.APPLICATION_JSON)
    UpdateHostResponse resume(@PathParam("hostname") String hostNameString);
}