aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/repair/RepairTicketReport.java
blob: fe5d2c47117159b4c59ddfacc484cfe28096ff71 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.repair;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import static com.yahoo.yolean.Exceptions.uncheck;

/**
 * @author olaa
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class RepairTicketReport {

    private static final String REPORT_ID = "repairTicket";
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public String status;
    public String ticketNumber;
    public long createdMillis;
    public long updatedMillis;

    public RepairTicketReport(@JsonProperty("status") String status,
                              @JsonProperty("ticketNumber") String ticketNumber,
                              @JsonProperty("createdMillis") long createdMillis,
                              @JsonProperty("updatedMillis") long updatedMillis) {
        this.status = status;
        this.ticketNumber = ticketNumber;
        this.createdMillis = createdMillis;
        this.updatedMillis = updatedMillis;
    }

    public String getStatus() {
        return status;
    }

    public String getTicketNumber() {
        return ticketNumber;
    }

    public long getCreatedMillis() {
        return createdMillis;
    }

    public long getUpdatedMillis() {
        return updatedMillis;
    }

    public static String getReportId() {
        return REPORT_ID;
    }

    public static RepairTicketReport fromJsonNode(String jsonReport) {
        return uncheck(() -> objectMapper.readValue(jsonReport, RepairTicketReport.class));
    }

    public JsonNode toJsonNode() {
        return uncheck(() -> objectMapper.valueToTree(this));
    }
}