public Request<DeleteVirtualInterfaceRequest> marshall(
      DeleteVirtualInterfaceRequest deleteVirtualInterfaceRequest) {
    if (deleteVirtualInterfaceRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<DeleteVirtualInterfaceRequest> request =
        new DefaultRequest<DeleteVirtualInterfaceRequest>(
            deleteVirtualInterfaceRequest, "AmazonDirectConnect");
    String target = "OvertureService.DeleteVirtualInterface";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.1");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (deleteVirtualInterfaceRequest.getVirtualInterfaceId() != null) {
        jsonWriter
            .key("virtualInterfaceId")
            .value(deleteVirtualInterfaceRequest.getVirtualInterfaceId());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<CreatePrivateVirtualInterfaceRequest> marshall(
      CreatePrivateVirtualInterfaceRequest createPrivateVirtualInterfaceRequest) {

    if (createPrivateVirtualInterfaceRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreatePrivateVirtualInterfaceRequest> request =
        new DefaultRequest<CreatePrivateVirtualInterfaceRequest>(
            createPrivateVirtualInterfaceRequest, "AmazonDirectConnect");
    request.addHeader("X-Amz-Target", "OvertureService.CreatePrivateVirtualInterface");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (createPrivateVirtualInterfaceRequest.getConnectionId() != null) {
        jsonGenerator
            .writeFieldName("connectionId")
            .writeValue(createPrivateVirtualInterfaceRequest.getConnectionId());
      }
      if (createPrivateVirtualInterfaceRequest.getNewPrivateVirtualInterface() != null) {
        jsonGenerator.writeFieldName("newPrivateVirtualInterface");
        NewPrivateVirtualInterfaceJsonMarshaller.getInstance()
            .marshall(
                createPrivateVirtualInterfaceRequest.getNewPrivateVirtualInterface(),
                jsonGenerator);
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(VirtualGateway virtualGateway, JSONWriter jsonWriter) {
    if (virtualGateway == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (virtualGateway.getVirtualGatewayId() != null) {
        jsonWriter.key("virtualGatewayId").value(virtualGateway.getVirtualGatewayId());
      }

      if (virtualGateway.getVirtualGatewayState() != null) {
        jsonWriter.key("virtualGatewayState").value(virtualGateway.getVirtualGatewayState());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<DescribeInterconnectsRequest> marshall(
      DescribeInterconnectsRequest describeInterconnectsRequest) {

    if (describeInterconnectsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<DescribeInterconnectsRequest> request =
        new DefaultRequest<DescribeInterconnectsRequest>(
            describeInterconnectsRequest, "AmazonDirectConnect");
    request.addHeader("X-Amz-Target", "OvertureService.DescribeInterconnects");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator =
          SdkJsonProtocolFactory.createWriter(false, "1.1");

      jsonGenerator.writeStartObject();

      if (describeInterconnectsRequest.getInterconnectId() != null) {
        jsonGenerator
            .writeFieldName("interconnectId")
            .writeValue(describeInterconnectsRequest.getInterconnectId());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }