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

org.elasticsearch.client.xpack.XPackUsageResponse Maven / Gradle / Ivy

There is a newer version: 8.0.0-alpha2
Show newest version
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */

package org.elasticsearch.client.xpack;

import org.elasticsearch.xcontent.XContentParser;

import java.io.IOException;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Response object from calling the xpack usage api.
 *
 * Usage information for each feature is accessible through {@link #getUsages()}.
 */
public class XPackUsageResponse {

    private final Map> usages;

    private XPackUsageResponse(Map> usages) {
        this.usages = usages;
    }

    @SuppressWarnings("unchecked")
    private static Map castMap(Object value) {
        return (Map) value;
    }

    /** Return a map from feature name to usage information for that feature. */
    public Map> getUsages() {
        return usages;
    }

    public static XPackUsageResponse fromXContent(XContentParser parser) throws IOException {
        Map rawMap = parser.map();
        Map> usages = rawMap.entrySet()
            .stream()
            .collect(Collectors.toMap(Map.Entry::getKey, e -> castMap(e.getValue())));
        return new XPackUsageResponse(usages);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy