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

org.elasticsearch.client.security.GetApiKeyResponse 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.security;

import org.elasticsearch.client.security.support.ApiKey;
import org.elasticsearch.xcontent.ConstructingObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.XContentParser;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg;

/**
 * Response for get API keys.
* The result contains information about the API keys that were found. */ public final class GetApiKeyResponse { private final List foundApiKeysInfo; public GetApiKeyResponse(List foundApiKeysInfo) { Objects.requireNonNull(foundApiKeysInfo, "found_api_keys_info must be provided"); this.foundApiKeysInfo = Collections.unmodifiableList(foundApiKeysInfo); } public static GetApiKeyResponse emptyResponse() { return new GetApiKeyResponse(Collections.emptyList()); } public List getApiKeyInfos() { return foundApiKeysInfo; } @Override public int hashCode() { return Objects.hash(foundApiKeysInfo); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final GetApiKeyResponse other = (GetApiKeyResponse) obj; return Objects.equals(foundApiKeysInfo, other.foundApiKeysInfo); } @SuppressWarnings("unchecked") static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "get_api_key_response", args -> { return (args[0] == null) ? GetApiKeyResponse.emptyResponse() : new GetApiKeyResponse((List) args[0]); } ); static { PARSER.declareObjectArray(optionalConstructorArg(), (p, c) -> ApiKey.fromXContent(p), new ParseField("api_keys")); } public static GetApiKeyResponse fromXContent(XContentParser parser) throws IOException { return PARSER.parse(parser, null); } @Override public String toString() { return "GetApiKeyResponse [foundApiKeysInfo=" + foundApiKeysInfo + "]"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy