All Downloads are FREE. Search and download functionalities are using the official Maven repository.

models.internal.HostQuery Maven / Gradle / Ivy

There is a newer version: 0.9.2
Show newest version
/**
 * Copyright 2014 Groupon.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package models.internal;

import java.util.Optional;

/**
 * Internal model interface for a host query.
 *
 * @author Ville Koskela (vkoskela at groupon dot com)
 */
public interface HostQuery {

    /**
     * Set the hostname to query for. Optional. Defaults to all hosts. If this field is not set it is strongly
     * encouraged that the limit field is set.
     *
     * @param partialHostname The partial or complete hostname to match.
     * @return This instance of HostQuery.
     */
    HostQuery partialHostname(final Optional partialHostname);

    /**
     * Set the metrics software state to query for. Optional. Defaults to any state.
     *
     * @param metricsSoftwareState The metrics software state to match.
     * @return This instance of HostQuery.
     */
    HostQuery metricsSoftwareState(final Optional metricsSoftwareState);

    /**
     * Set the cluster to query for. Optional. Defaults to all clusters.
     *
     * @param cluster The complete cluster to match.
     * @return This instance of HostQuery.
     */
    HostQuery cluster(final Optional cluster);

    /**
     * The maximum number of hosts to return. Optional. Default is 1000.
     *
     * @param limit The maximum number of hosts to return.
     * @return This instance of HostQuery.
     */
    HostQuery limit(final int limit);

    /**
     * The offset into the result set. Optional. Default is not set.
     *
     * @param offset The offset into the result set.
     * @return This instance of HostQuery.
     */
    HostQuery offset(final Optional offset);

    /**
     * Sort the results by the specified field. Optional. Default sorting is defined by the underlying repository
     * implementation but it is strongly recommended that the repository make some attempt to sort by score or relevance
     * given the inputs.
     *
     * @param field The Field to sort on.
     * @return This instance of HostQuery.
     */
    HostQuery sortBy(final Optional field);

    /**
     * Execute the query and return the results.
     *
     * @return The results of the query as an {@code QueryResult} instance.
     */
    QueryResult execute();

    /**
     * Accessor for the hostname.
     *
     * @return The hostname.
     */
    Optional getPartialHostname();

    /**
     * Accessor for the cluster.
     *
     * @return The cluster.
     */
    Optional getCluster();

    /**
     * Accessor for the metrics software state.
     *
     * @return The metrics software state.
     */
    Optional getMetricsSoftwareState();

    /**
     * Accessor for the limit.
     *
     * @return The limit.
     */
    int getLimit();

    /**
     * Accessor for the offset.
     *
     * @return The offset.
     */
    Optional getOffset();

    /**
     * Accessor for the field to sort by.
     * @return The field to sort by.
     */
    Optional getSortBy();

    /**
     * The fields defined for a host.
     */
    public enum Field {
        /**
         * The hostname.
         */
        HOSTNAME,
        /**
         * The state of the metrics software.
         */
        METRICS_SOFTWARE_STATE;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy