package com.hubspot.singularity;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

public class SingularityLoadBalancerResponse extends SingularityJsonObject {

  private final String loadBalancerRequestId;
  private final LoadBalancerState loadBalancerState;
  
  public static SingularityLoadBalancerResponse fromBytes(byte[] bytes, ObjectMapper objectMapper) {
    try {
      return objectMapper.readValue(bytes, SingularityLoadBalancerResponse.class);
    } catch (IOException e) {
      throw new SingularityJsonException(e);
    }
  }
  
  @JsonCreator
  public SingularityLoadBalancerResponse(@JsonProperty("loadBalancerRequestId") String loadBalancerRequestId, @JsonProperty("loadBalancerState") LoadBalancerState loadBalancerState) {
    this.loadBalancerRequestId = loadBalancerRequestId;
    this.loadBalancerState = loadBalancerState;
  }

  public String getLoadBalancerRequestId() {
    return loadBalancerRequestId;
  }

  public LoadBalancerState getLoadBalancerState() {
    return loadBalancerState;
  }
  
  @Override
  public String toString() {
    return "SingularityLoadBalancerResponse [loadBalancerRequestId=" + loadBalancerRequestId + ", loadBalancerState=" + loadBalancerState + "]";
  }
    
}

@@ -31,37 +31,8 @@
 y;%0A%0A
-import java.io.IOException;%0A%0A
 impo
@@ -185,16 +185,85 @@
 tMapper;
+%0Aimport com.google.common.base.Optional;%0A%0Aimport java.io.IOException;
 %0A%0Apublic
@@ -433,16 +433,58 @@
 rState;%0A
+  private final Optional%3CString%3E message;%0A
   %0A  pub
@@ -955,16 +955,67 @@
 cerState
+, @JsonProperty(%22message%22) Optional%3CString%3E message
 ) %7B%0A    
@@ -1110,24 +1110,52 @@
 ancerState;%0A
+    this.message = message;%0A
   %7D%0A%0A  publi
@@ -1313,26 +1313,90 @@
 rState;%0A  %7D%0A
+%0A
   
+public Optional%3CString%3E getMessage() %7B%0A    return message;%0A  %7D%0A
 %0A  @Override
@@ -1470,16 +1470,29 @@
 sponse %5B
+%22 +%0A        %22
 loadBala
@@ -1505,16 +1505,17 @@
 questId=
+'
 %22 + load
@@ -1533,16 +1533,31 @@
 uestId +
+ '%5C'' +%0A       
  %22, load
@@ -1597,21 +1597,57 @@
 te +
- %22%5D%22;%0A  %7D%0A    
+%0A        %22, message=%22 + message +%0A        '%5D';%0A  %7D
 %0A%7D%0A

add optional message field to SingularityLoadBalancerResponse