// Path: query/src/main/java/io/keen/client/java/result/QueryResult.java
// public abstract class QueryResult {
//     /**
//      * @return {@code false}
//      */
//     public boolean isDouble() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isLong() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isString() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isListResult() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isIntervalResult() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isGroupResult() { return false; }
// 
//     /**
//      * @return doubleValue, which is IllegalStateException in abstract class.
//      */
//     public double doubleValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return longValue, which is IllegalStateException in abstract class.
//      */
//     public long longValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return stringValue, which is IllegalStateException in abstract class.
//      */
//     public String stringValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return list results, which is IllegalStateException in abstract class.
//      */
//     public List<QueryResult> getListResults() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return map of AbsoluteTimeframe to QueryResult's, which is IllegalStateException in
//      * abstract class.
//      */
//     public List<IntervalResultValue> getIntervalResults() { throw new IllegalStateException(); }
// 
//     /**
//      * @return map of Group to QueryResult's, which is IllegalStateException in abstract class.
//      */
//     public Map<Group, QueryResult> getGroupResults() { throw new IllegalStateException(); }
// 
//     @Override
//     public String toString() {
//         return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return EqualsBuilder.reflectionEquals(this, obj);
//     }
// 
//     @Override
//     public int hashCode() {
//         return HashCodeBuilder.reflectionHashCode(this);
//     }
// }


import java.io.IOException;
import java.util.List;
import java.util.Map;
import io.keen.client.java.result.QueryResult;
package io.keen.client.java;



/**
 * Represents the set of operations that can be performed against the
 * <a href="https://keen.io/docs/api/#saved-queries">Saved/Cached Query API</a> endpoints.
 *
 * @author masojus
 */
public interface SavedQueries {
    /**
     * Save the given query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Saved Query.
     */
    Map<String, Object> createSavedQuery(String queryName,
                                         KeenQueryRequest query) throws IOException;

    /**
     * Save the given query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param displayName The display name to be used for this resource.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Saved Query.
     */
    Map<String, Object> createSavedQuery(String queryName,
                                         KeenQueryRequest query,
                                         String displayName) throws IOException;

    /**
     * Save the given query as a cached query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param refreshRate The refresh rate for this cached query, empirically in the range
     *                    [14400, 86400] seconds or 4-24 hrs.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Cached Query.
     */
    Map<String, Object> createCachedQuery(String queryName,
                                          KeenQueryRequest query,
                                          int refreshRate) throws IOException;

    /**
     * Save the given query as a cached query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param displayName The display name to be used for this resource.
     * @param refreshRate The refresh rate for this cached query, empirically in the range
     *                    [14400, 86400] seconds or 4-24 hrs.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Cached Query.
     */
    Map<String, Object> createCachedQuery(String queryName,
                                          KeenQueryRequest query,
                                          String displayName,
                                          int refreshRate) throws IOException;

    /**
     * Get a single Saved/Cached query definition.
     *
     * @param queryName The resource name for the query.
     *
     * @return The definition for the given query resource.
     * @throws IOException If there is an error getting the Saved/Cached Query definition.
     */
    Map<String, Object> getDefinition(String queryName) throws IOException;

    /**
     * Get all Saved/Cached Query definitions.
     *
     * @return All the Saved/Cached query definitions for this project.
     * @throws IOException If there is an error getting the Saved/Cached Query definitions.
     */
    List<Map<String, Object>> getAllDefinitions() throws IOException;

    /**
     * Get the result of the Saved/Cached query with the given resource name.
     *
     * @param queryName The resource name for the query.
     *
     * @return The result of the Saved/Cached query.
     * @throws IOException If there is an error getting the Saved/Cached Query result.
     */
// Path: query/src/main/java/io/keen/client/java/result/QueryResult.java
// public abstract class QueryResult {
//     /**
//      * @return {@code false}
//      */
//     public boolean isDouble() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isLong() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isString() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isListResult() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isIntervalResult() {
//         return false;
//     }
// 
//     /**
//      * @return {@code false}
//      */
//     public boolean isGroupResult() { return false; }
// 
//     /**
//      * @return doubleValue, which is IllegalStateException in abstract class.
//      */
//     public double doubleValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return longValue, which is IllegalStateException in abstract class.
//      */
//     public long longValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return stringValue, which is IllegalStateException in abstract class.
//      */
//     public String stringValue() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return list results, which is IllegalStateException in abstract class.
//      */
//     public List<QueryResult> getListResults() {
//         throw new IllegalStateException();
//     }
// 
//     /**
//      * @return map of AbsoluteTimeframe to QueryResult's, which is IllegalStateException in
//      * abstract class.
//      */
//     public List<IntervalResultValue> getIntervalResults() { throw new IllegalStateException(); }
// 
//     /**
//      * @return map of Group to QueryResult's, which is IllegalStateException in abstract class.
//      */
//     public Map<Group, QueryResult> getGroupResults() { throw new IllegalStateException(); }
// 
//     @Override
//     public String toString() {
//         return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return EqualsBuilder.reflectionEquals(this, obj);
//     }
// 
//     @Override
//     public int hashCode() {
//         return HashCodeBuilder.reflectionHashCode(this);
//     }
// }


// Path: query/src/main/java/io/keen/client/java/SavedQueries.java
import java.io.IOException;
import java.util.List;
import java.util.Map;
import io.keen.client.java.result.QueryResult;

package io.keen.client.java;



/**
 * Represents the set of operations that can be performed against the
 * <a href="https://keen.io/docs/api/#saved-queries">Saved/Cached Query API</a> endpoints.
 *
 * @author masojus
 */
public interface SavedQueries {
    /**
     * Save the given query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Saved Query.
     */
    Map<String, Object> createSavedQuery(String queryName,
                                         KeenQueryRequest query) throws IOException;

    /**
     * Save the given query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param displayName The display name to be used for this resource.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Saved Query.
     */
    Map<String, Object> createSavedQuery(String queryName,
                                         KeenQueryRequest query,
                                         String displayName) throws IOException;

    /**
     * Save the given query as a cached query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param refreshRate The refresh rate for this cached query, empirically in the range
     *                    [14400, 86400] seconds or 4-24 hrs.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Cached Query.
     */
    Map<String, Object> createCachedQuery(String queryName,
                                          KeenQueryRequest query,
                                          int refreshRate) throws IOException;

    /**
     * Save the given query as a cached query.
     *
     * @param queryName The resource name for the query. Alphanumerics, hyphens, and underscores.
     * @param query The query definition.
     * @param displayName The display name to be used for this resource.
     * @param refreshRate The refresh rate for this cached query, empirically in the range
     *                    [14400, 86400] seconds or 4-24 hrs.
     *
     * @return The raw return value of the PUT request as a Map containing the complete new
     *         Saved/Cached Query definition with auditing like created/updated/run information.
     * @throws IOException If there is an error creating the Cached Query.
     */
    Map<String, Object> createCachedQuery(String queryName,
                                          KeenQueryRequest query,
                                          String displayName,
                                          int refreshRate) throws IOException;

    /**
     * Get a single Saved/Cached query definition.
     *
     * @param queryName The resource name for the query.
     *
     * @return The definition for the given query resource.
     * @throws IOException If there is an error getting the Saved/Cached Query definition.
     */
    Map<String, Object> getDefinition(String queryName) throws IOException;

    /**
     * Get all Saved/Cached Query definitions.
     *
     * @return All the Saved/Cached query definitions for this project.
     * @throws IOException If there is an error getting the Saved/Cached Query definitions.
     */
    List<Map<String, Object>> getAllDefinitions() throws IOException;

    /**
     * Get the result of the Saved/Cached query with the given resource name.
     *
     * @param queryName The resource name for the query.
     *
     * @return The result of the Saved/Cached query.
     * @throws IOException If there is an error getting the Saved/Cached Query result.
     */
    QueryResult getResult(String queryName) throws IOException;