// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// 	DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
// 
// 	@Override
// 	public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// 		if (value == null) {
// 			out.nullValue();
// 			return;
// 		}
// 		out.value(formatter.format(value));
// 	}
// 
// 	@Override
// 	public OffsetDateTime read(JsonReader in) throws IOException {
// 		if (in.peek() == JsonToken.NULL) {
// 			in.nextNull();
// 			return null;
// 		}
// 		return formatter.parse(in.nextString(), OffsetDateTime::from);
// 	}
// }
// 
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// 	/**
// 	 * The internal state when the account is created, but never connected. 
// 	 */
// 	INIT,
// 	
// 	/**
// 	 * The state when the account is pending for approval from administrator
// 	 */
// 	PENDING,
// 	
// 	/**
// 	 * The state where all pxGrid control functionalities are available.
// 	 */
// 	ENABLED,
// 	
// 	/**
// 	 * A disabled account. Administrator can disable or enable the account.
// 	 */
// 	DISABLED;
// }
// 
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// 	private String name;
// 	private String nodeName;
// 	private Map<String, String> properties;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getNodeName() {
// 		return nodeName;
// 	}
// 
// 	public void setNodeName(String nodeName) {
// 		this.nodeName = nodeName;
// 	}
// 
// 	public Map<String, String> getProperties() {
// 		return properties;
// 	}
// 
// 	public void setProperties(Map<String, String> properties) {
// 		this.properties = properties;
// 	}
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
package com.cisco.pxgrid.samples.ise;





/**
 * Demonstrates how to query all sessions and stream process for ISE Session Directory service
 */
public class SessionQueryAll {
	private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
	
	private static class SessionQueryRequest {
		OffsetDateTime startTimestamp;
	}

	private static void query(SampleConfiguration config) throws Exception {
		OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
		
		PxgridControl pxgrid = new PxgridControl(config);
		
		// pxGrid ServiceLookup for session service
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// 	DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
// 
// 	@Override
// 	public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// 		if (value == null) {
// 			out.nullValue();
// 			return;
// 		}
// 		out.value(formatter.format(value));
// 	}
// 
// 	@Override
// 	public OffsetDateTime read(JsonReader in) throws IOException {
// 		if (in.peek() == JsonToken.NULL) {
// 			in.nextNull();
// 			return null;
// 		}
// 		return formatter.parse(in.nextString(), OffsetDateTime::from);
// 	}
// }
// 
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// 	/**
// 	 * The internal state when the account is created, but never connected. 
// 	 */
// 	INIT,
// 	
// 	/**
// 	 * The state when the account is pending for approval from administrator
// 	 */
// 	PENDING,
// 	
// 	/**
// 	 * The state where all pxGrid control functionalities are available.
// 	 */
// 	ENABLED,
// 	
// 	/**
// 	 * A disabled account. Administrator can disable or enable the account.
// 	 */
// 	DISABLED;
// }
// 
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// 	private String name;
// 	private String nodeName;
// 	private Map<String, String> properties;
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getNodeName() {
// 		return nodeName;
// 	}
// 
// 	public void setNodeName(String nodeName) {
// 		this.nodeName = nodeName;
// 	}
// 
// 	public Map<String, String> getProperties() {
// 		return properties;
// 	}
// 
// 	public void setProperties(Map<String, String> properties) {
// 		this.properties = properties;
// 	}
// }


// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;

package com.cisco.pxgrid.samples.ise;





/**
 * Demonstrates how to query all sessions and stream process for ISE Session Directory service
 */
public class SessionQueryAll {
	private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
	
	private static class SessionQueryRequest {
		OffsetDateTime startTimestamp;
	}

	private static void query(SampleConfiguration config) throws Exception {
		OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
		
		PxgridControl pxgrid = new PxgridControl(config);
		
		// pxGrid ServiceLookup for session service
		Service[] services = pxgrid.serviceLookup("com.cisco.ise.session");