// Path: core/src/main/java/io/keen/client/java/http/HttpMethods.java
// public final class HttpMethods {
//     private HttpMethods() {}
// 
//     public final static String GET = "GET";
//     public final static String POST = "POST";
//     public final static String PUT = "PUT";
//     public final static String DELETE = "DELETE";
// }


import io.keen.client.java.http.HttpMethods;
package io.keen.client.java;


/**
 * Base class that represents requests to the endpoints for managing persistent analyses, such as
 * <a href="https://keen.io/docs/api/#saved-queries">Saved/Cached Queries</a> and
 * <a href="https://keen.io/docs/api/#cached-datasets">Cached Datasets</a>.
 *
 * Should be an interface, but KeenQueryRequest is meant to be a package-private interface defining
 * package-private functionality, so until the next major version when we fix up public interface
 * surface area, it's a package-private abstract class.
 *
 * @author masojus
 */
abstract class PersistentAnalysis extends KeenQueryRequest {
    // This regex does not match strings like "árbol π" since the API only accepts ASCII in the URL.
    private static final String RESOURCE_NAME_REGEX = "^[\\w-]*$";

    private final String httpMethod;
    private final boolean needsMasterKey;

    // The name of the specific persistent analysis we're working on, if any--e.g. "max_signups".
    private final String resourceName;
    private final String displayName;


    PersistentAnalysis(String httpMethod,
                       boolean needsMasterKey,
                       String resourceName,
                       String displayName) {
        // HTTP Method is provided by our code, so let's trust it's valid.
        this.httpMethod = httpMethod;
        this.needsMasterKey = needsMasterKey;

        // The resource name can only be omitted for a GET request.
// Path: core/src/main/java/io/keen/client/java/http/HttpMethods.java
// public final class HttpMethods {
//     private HttpMethods() {}
// 
//     public final static String GET = "GET";
//     public final static String POST = "POST";
//     public final static String PUT = "PUT";
//     public final static String DELETE = "DELETE";
// }


// Path: query/src/main/java/io/keen/client/java/PersistentAnalysis.java
import io.keen.client.java.http.HttpMethods;

package io.keen.client.java;


/**
 * Base class that represents requests to the endpoints for managing persistent analyses, such as
 * <a href="https://keen.io/docs/api/#saved-queries">Saved/Cached Queries</a> and
 * <a href="https://keen.io/docs/api/#cached-datasets">Cached Datasets</a>.
 *
 * Should be an interface, but KeenQueryRequest is meant to be a package-private interface defining
 * package-private functionality, so until the next major version when we fix up public interface
 * surface area, it's a package-private abstract class.
 *
 * @author masojus
 */
abstract class PersistentAnalysis extends KeenQueryRequest {
    // This regex does not match strings like "árbol π" since the API only accepts ASCII in the URL.
    private static final String RESOURCE_NAME_REGEX = "^[\\w-]*$";

    private final String httpMethod;
    private final boolean needsMasterKey;

    // The name of the specific persistent analysis we're working on, if any--e.g. "max_signups".
    private final String resourceName;
    private final String displayName;


    PersistentAnalysis(String httpMethod,
                       boolean needsMasterKey,
                       String resourceName,
                       String displayName) {
        // HTTP Method is provided by our code, so let's trust it's valid.
        this.httpMethod = httpMethod;
        this.needsMasterKey = needsMasterKey;

        // The resource name can only be omitted for a GET request.
        if (null == resourceName && !HttpMethods.GET.equals(httpMethod)) {