// Path: src/main/java/com/opentok/constants/DefaultApiUrl.java
// public class DefaultApiUrl {
//     public static final String DEFAULT_API_URI = "https://api.opentok.com";
//     
// }
// 
// Path: src/main/java/com/opentok/constants/Version.java
// public class Version {
//     public static final String VERSION = "4.6.0";
// }
// 
// Path: src/main/java/com/opentok/exception/InvalidArgumentException.java
// public class InvalidArgumentException extends OpenTokException {
// 
//     private static final long serialVersionUID = 6315168083117996091L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public InvalidArgumentException(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: src/main/java/com/opentok/exception/OpenTokException.java
// public class OpenTokException extends Exception {
// 	private static final long serialVersionUID = 6059658348908505724L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public OpenTokException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public OpenTokException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/opentok/exception/RequestException.java
// public class RequestException extends OpenTokException {
// 
//     private static final long serialVersionUID = -3852834447530956514L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public RequestException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public RequestException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }


import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.opentok.*;
import com.opentok.constants.DefaultApiUrl;
import com.opentok.constants.Version;
import com.opentok.exception.InvalidArgumentException;
import com.opentok.exception.OpenTokException;
import com.opentok.exception.RequestException;
import org.apache.commons.lang.StringUtils;
import org.asynchttpclient.*;
import org.asynchttpclient.Realm.AuthScheme;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.filter.FilterException;
import org.asynchttpclient.filter.RequestFilter;
import org.asynchttpclient.proxy.ProxyServer;
import java.io.ByteArrayOutputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
                    throw new RequestException("Could not patch opentok broadcast. Stream mode not supported for patching.");
                case 403:
                    throw new RequestException("Could not patch opentok broadcast. The request was unauthorized.");
                case 500:
                    throw new RequestException("Could not patch opentok broadcast. A server error occurred");
                default:
                    throw new RequestException("Could not patch opentok broadcast. The server response was invalid. Response code: " +
                            response.getStatusCode());
            }

        } catch (ExecutionException | InterruptedException e) {
            throw new RequestException("Could not patch an opentok broadcast.", e);
        }
        return responseString;
    }

    public String setBroadcastLayout(String broadcastId, BroadcastProperties properties) throws OpenTokException {
        if (properties.layout() == null) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
        String type = properties.layout().getType().toString();
        String stylesheet = properties.layout().getStylesheet();
        String screenshareLayout = null;
        if (StringUtils.isEmpty(type)) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
        if ((type.equals(BroadcastLayout.Type.CUSTOM.toString()) && StringUtils.isEmpty(stylesheet)) ||
                (!type.equals(BroadcastLayout.Type.CUSTOM.toString()) && !StringUtils.isEmpty(stylesheet))) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
// Path: src/main/java/com/opentok/constants/DefaultApiUrl.java
// public class DefaultApiUrl {
//     public static final String DEFAULT_API_URI = "https://api.opentok.com";
//     
// }
// 
// Path: src/main/java/com/opentok/constants/Version.java
// public class Version {
//     public static final String VERSION = "4.6.0";
// }
// 
// Path: src/main/java/com/opentok/exception/InvalidArgumentException.java
// public class InvalidArgumentException extends OpenTokException {
// 
//     private static final long serialVersionUID = 6315168083117996091L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public InvalidArgumentException(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: src/main/java/com/opentok/exception/OpenTokException.java
// public class OpenTokException extends Exception {
// 	private static final long serialVersionUID = 6059658348908505724L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public OpenTokException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public OpenTokException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/opentok/exception/RequestException.java
// public class RequestException extends OpenTokException {
// 
//     private static final long serialVersionUID = -3852834447530956514L;
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public RequestException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor. Do not use.
//      */
//     public RequestException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }


// Path: src/main/java/com/opentok/util/HttpClient.java
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.opentok.*;
import com.opentok.constants.DefaultApiUrl;
import com.opentok.constants.Version;
import com.opentok.exception.InvalidArgumentException;
import com.opentok.exception.OpenTokException;
import com.opentok.exception.RequestException;
import org.apache.commons.lang.StringUtils;
import org.asynchttpclient.*;
import org.asynchttpclient.Realm.AuthScheme;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.filter.FilterException;
import org.asynchttpclient.filter.RequestFilter;
import org.asynchttpclient.proxy.ProxyServer;
import java.io.ByteArrayOutputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

                    throw new RequestException("Could not patch opentok broadcast. Stream mode not supported for patching.");
                case 403:
                    throw new RequestException("Could not patch opentok broadcast. The request was unauthorized.");
                case 500:
                    throw new RequestException("Could not patch opentok broadcast. A server error occurred");
                default:
                    throw new RequestException("Could not patch opentok broadcast. The server response was invalid. Response code: " +
                            response.getStatusCode());
            }

        } catch (ExecutionException | InterruptedException e) {
            throw new RequestException("Could not patch an opentok broadcast.", e);
        }
        return responseString;
    }

    public String setBroadcastLayout(String broadcastId, BroadcastProperties properties) throws OpenTokException {
        if (properties.layout() == null) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
        String type = properties.layout().getType().toString();
        String stylesheet = properties.layout().getStylesheet();
        String screenshareLayout = null;
        if (StringUtils.isEmpty(type)) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
        if ((type.equals(BroadcastLayout.Type.CUSTOM.toString()) && StringUtils.isEmpty(stylesheet)) ||
                (!type.equals(BroadcastLayout.Type.CUSTOM.toString()) && !StringUtils.isEmpty(stylesheet))) {
            throw new RequestException("Could not set the layout. Either an invalid JSON or an invalid layout options.");
        }
        if (properties.layout().getScreenshareType() != null) {