summaryrefslogtreecommitdiffstats
path: root/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/requests/SetUnitStateRequest.java
blob: 972b0c4b82a93625480e617bff2fc34eb7a838b8 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.staterestapi.requests;

import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState;

import java.util.Map;

public interface SetUnitStateRequest extends UnitRequest {

    Map<String, UnitState> getNewState();

    enum Condition {
        FORCE(1), // Don't check for any condition before setting unit state
        SAFE(2); // Only set condition if it is deemed safe (e.g. redundancy is still ok during upgrade)

        public final int value;

        private Condition(int value) {
            this.value = value;
        }

        public static Condition fromString(String value) throws InvalidContentException {
            try {
                return Condition.valueOf(value.toUpperCase());
            } catch (IllegalArgumentException e) {
                throw new InvalidContentException("Invalid value for my enum Condition: " + value);
            }
        }
    }
    Condition getCondition();
}