Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
    /**
     * The quota types.
     */
    public enum QuotaType {
        CONSUMER_BYTE_RATE,
        PRODUCER_BYTE_RATE,
        REQUEST_PERCENTAGE,
    }

    /**
     * The quota configuration for a specific user and client ID.
     */
    public class QuotaConfig {

        /**
         * Where in the hierarchy the quota value was specified.
         */
        public enum Source {
            // In order of descending precedence.
            USER_CLIENT,                  // /config/users/<user>/clients/<client-id>
            USER_DEFAULT_CLIENT,          // /config/users/<user>/clients/<default>
            USER,                         // /config/users/<user>
            DEFAULT_USER_CLIENT,          // /config/users/<default>/clients/<client-id>
            DEFAULT_USER_DEFAULT_CLIENT,  // /config/users/<default>/clients/<default>
            DEFAULT_USER,                 // /config/users/<default>
            CLIENT,                       // /config/clients/<client-id>
            DEFAULT_CLIENT,               // /config/clients/<default>
            DEFAULT,                      // static default
        }

        /**
         * Information about a quota value.
         */
        public class Value {
            /**
             * @param source the source for the value
             * @param value the non-null value
             */
            public Value(Source source, Double value);
            public Source source();
            public Double value();
        }

        /**
         * Information about the value for a quota type.
         */
        public class Entry {
            /**
             * @param value the active quota value
             * @param overriddenValues list of all values lower that are ignored due to being lower in the hierarchy
             */
            public Entry(Value value, List<Value> overriddenValues);
            public Value value();
            public List<Value> overriddenValues();
        }

        /**
         * Maps quota type to its configuration entry.
         *
         * Note that, depending upon the applied quota filtersettings in the request's options, this config may not map every
         * quota type to an entry. If a key is not contained in the map, then that quota type's value
         * is not specified.
         */
        public Map<QuotaType, Entry> config();
    }

    /**
     * Identifies a quota entity for a given user and client ID. If the provided user or client ID is
     * `Optional.empty()`, then the default name is used, otherwise if null, then the name is omitted
     * entirely. At least one of user or client ID must be specified.
     *
     * For example:
     *
     *   {user="kafka-user", clientId="kafka-client-id"} corresponds to quota source `USER_CLIENT` with
     *   specified user "kafka-user" and client ID "kafka-client-id".
     *
     *   {user="kafka-user", clientId=Optional.empty()} corresponds to quota source `USER_DEFAULT_CLIENT`
     *   with specified user "kafka-user" and default client ID.
     *
     *   {user=null, clientId="kafka-client-id"} corresponds to quota source `CLIENT` for client with
     *   ID "kafka-client-id".
     */
    public class QuotaEntity {
        public QuotaEntity(Optional<String> user, Optional<String> clientId);
        public Optional<String> user();
        public Optional<String> clientId();
    }

    public class DescribeQuotasOptions {
        // Whether to include the inherited values in the result. If false, then undefined values for
        // the config entries will be ommitted in the results.
        //
        // Default: true.
        DescribeQuotasOptions setWantInheritedValues(boolean wantInheritedValues);

        // Whether to include the overridden values for every quota type in the result.
        //
        // Default: true.
        DescribeQuotasOptions setWantOverriddenValues(boolean wantOverriddenValues);
    }

    public class DescribeQuotasResult {
        Map<QuotaEntity, QuotaConfig> configs;
    }

    public interface Admin extends AutoCloseable {
        /**
         * Describes the quotas for the provided entities.
         */
        DescribeQuotasResult describeQuotas(Collection<QuotaEntity> quotaEntities);
    }

...