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

    Request<CreateWorkspacesRequest> request =
        new DefaultRequest<CreateWorkspacesRequest>(createWorkspacesRequest, "AmazonWorkspaces");
    String target = "WorkspacesService.CreateWorkspaces";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

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

      jsonWriter.object();

      com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest> workspacesList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest>)
              (createWorkspacesRequest.getWorkspaces());
      if (workspacesList != null
          && !(workspacesList.isAutoConstruct() && workspacesList.isEmpty())) {

        jsonWriter.key("Workspaces");
        jsonWriter.array();

        for (WorkspaceRequest workspacesListValue : workspacesList) {
          if (workspacesListValue != null) {
            jsonWriter.object();
            if (workspacesListValue.getDirectoryId() != null) {
              jsonWriter.key("DirectoryId").value(workspacesListValue.getDirectoryId());
            }
            if (workspacesListValue.getUserName() != null) {
              jsonWriter.key("UserName").value(workspacesListValue.getUserName());
            }
            if (workspacesListValue.getBundleId() != null) {
              jsonWriter.key("BundleId").value(workspacesListValue.getBundleId());
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } 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(RebuildRequest rebuildRequest, JSONWriter jsonWriter) {
    if (rebuildRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (rebuildRequest.getWorkspaceId() != null) {
        jsonWriter.key("WorkspaceId").value(rebuildRequest.getWorkspaceId());
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Workspace workspace, JSONWriter jsonWriter) {
    if (workspace == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (workspace.getWorkspaceId() != null) {
        jsonWriter.key("WorkspaceId").value(workspace.getWorkspaceId());
      }

      if (workspace.getDirectoryId() != null) {
        jsonWriter.key("DirectoryId").value(workspace.getDirectoryId());
      }

      if (workspace.getUserName() != null) {
        jsonWriter.key("UserName").value(workspace.getUserName());
      }

      if (workspace.getIpAddress() != null) {
        jsonWriter.key("IpAddress").value(workspace.getIpAddress());
      }

      if (workspace.getState() != null) {
        jsonWriter.key("State").value(workspace.getState());
      }

      if (workspace.getBundleId() != null) {
        jsonWriter.key("BundleId").value(workspace.getBundleId());
      }

      if (workspace.getSubnetId() != null) {
        jsonWriter.key("SubnetId").value(workspace.getSubnetId());
      }

      if (workspace.getErrorMessage() != null) {
        jsonWriter.key("ErrorMessage").value(workspace.getErrorMessage());
      }

      if (workspace.getErrorCode() != null) {
        jsonWriter.key("ErrorCode").value(workspace.getErrorCode());
      }

      if (workspace.getComputerName() != null) {
        jsonWriter.key("ComputerName").value(workspace.getComputerName());
      }

      if (workspace.getVolumeEncryptionKey() != null) {
        jsonWriter.key("VolumeEncryptionKey").value(workspace.getVolumeEncryptionKey());
      }

      if (workspace.getUserVolumeEncryptionEnabled() != null) {
        jsonWriter
            .key("UserVolumeEncryptionEnabled")
            .value(workspace.getUserVolumeEncryptionEnabled());
      }

      if (workspace.getRootVolumeEncryptionEnabled() != null) {
        jsonWriter
            .key("RootVolumeEncryptionEnabled")
            .value(workspace.getRootVolumeEncryptionEnabled());
      }

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