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

co.elastic.clients.elasticsearch.security.InvalidateTokenRequest Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to Elasticsearch B.V. under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch B.V. licenses this file to you 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 co.elastic.clients.elasticsearch.security;

import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch._types.RequestBase;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.endpoints.SimpleEndpoint;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.Collections;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

//----------------------------------------------------------------
//       THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------

// typedef: security.invalidate_token.Request

/**
 * Invalidate a token.
 * 

* The access tokens returned by the get token API have a finite period of time * for which they are valid. After that time period, they can no longer be used. * The time period is defined by the * xpack.security.authc.token.timeout setting. *

* The refresh tokens returned by the get token API are only valid for 24 hours. * They can also be used exactly once. If you want to invalidate one or more * access or refresh tokens immediately, use this invalidate token API. *

* NOTE: While all parameters are optional, at least one of them is required. * More specifically, either one of token or * refresh_token parameters is required. If none of these two are * specified, then realm_name and/or username need to * be specified. * * @see API * specification */ @JsonpDeserializable public class InvalidateTokenRequest extends RequestBase implements JsonpSerializable { @Nullable private final String realmName; @Nullable private final String refreshToken; @Nullable private final String token; @Nullable private final String username; // --------------------------------------------------------------------------------------------- private InvalidateTokenRequest(Builder builder) { this.realmName = builder.realmName; this.refreshToken = builder.refreshToken; this.token = builder.token; this.username = builder.username; } public static InvalidateTokenRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** * The name of an authentication realm. This parameter cannot be used with * either refresh_token or token. *

* API name: {@code realm_name} */ @Nullable public final String realmName() { return this.realmName; } /** * A refresh token. This parameter cannot be used if any of * refresh_token, realm_name, or username * are used. *

* API name: {@code refresh_token} */ @Nullable public final String refreshToken() { return this.refreshToken; } /** * An access token. This parameter cannot be used if any of * refresh_token, realm_name, or username * are used. *

* API name: {@code token} */ @Nullable public final String token() { return this.token; } /** * The username of a user. This parameter cannot be used with either * refresh_token or token. *

* API name: {@code username} */ @Nullable public final String username() { return this.username; } /** * Serialize this object to JSON. */ public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); generator.writeEnd(); } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.realmName != null) { generator.writeKey("realm_name"); generator.write(this.realmName); } if (this.refreshToken != null) { generator.writeKey("refresh_token"); generator.write(this.refreshToken); } if (this.token != null) { generator.writeKey("token"); generator.write(this.token); } if (this.username != null) { generator.writeKey("username"); generator.write(this.username); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link InvalidateTokenRequest}. */ public static class Builder extends RequestBase.AbstractBuilder implements ObjectBuilder { @Nullable private String realmName; @Nullable private String refreshToken; @Nullable private String token; @Nullable private String username; /** * The name of an authentication realm. This parameter cannot be used with * either refresh_token or token. *

* API name: {@code realm_name} */ public final Builder realmName(@Nullable String value) { this.realmName = value; return this; } /** * A refresh token. This parameter cannot be used if any of * refresh_token, realm_name, or username * are used. *

* API name: {@code refresh_token} */ public final Builder refreshToken(@Nullable String value) { this.refreshToken = value; return this; } /** * An access token. This parameter cannot be used if any of * refresh_token, realm_name, or username * are used. *

* API name: {@code token} */ public final Builder token(@Nullable String value) { this.token = value; return this; } /** * The username of a user. This parameter cannot be used with either * refresh_token or token. *

* API name: {@code username} */ public final Builder username(@Nullable String value) { this.username = value; return this; } @Override protected Builder self() { return this; } /** * Builds a {@link InvalidateTokenRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public InvalidateTokenRequest build() { _checkSingleUse(); return new InvalidateTokenRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link InvalidateTokenRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer .lazy(Builder::new, InvalidateTokenRequest::setupInvalidateTokenRequestDeserializer); protected static void setupInvalidateTokenRequestDeserializer( ObjectDeserializer op) { op.add(Builder::realmName, JsonpDeserializer.stringDeserializer(), "realm_name"); op.add(Builder::refreshToken, JsonpDeserializer.stringDeserializer(), "refresh_token"); op.add(Builder::token, JsonpDeserializer.stringDeserializer(), "token"); op.add(Builder::username, JsonpDeserializer.stringDeserializer(), "username"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code security.invalidate_token}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( "es/security.invalidate_token", // Request method request -> { return "DELETE"; }, // Request path request -> { return "/_security/oauth2/token"; }, // Path parameters request -> { return Collections.emptyMap(); }, // Request parameters request -> { return Collections.emptyMap(); }, SimpleEndpoint.emptyMap(), true, InvalidateTokenResponse._DESERIALIZER); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy