-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move non duplicated actions back into xpack core (#32952)
Most actions' request and response were moved from xpack core into protocol. We have decided to instead duplicate the actions in the HLRC instead of trying to reuse them. This commit moves the non duplicated actions back into xpack core and severs the tie between xpack core and protocol so no other actions can be moved and not duplicated.
- Loading branch information
Showing
43 changed files
with
4,241 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/XPackInfoRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.protocol.xpack; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.EnumSet; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Fetch information about X-Pack from the cluster. | ||
*/ | ||
public class XPackInfoRequest extends ActionRequest { | ||
|
||
public enum Category { | ||
BUILD, LICENSE, FEATURES; | ||
|
||
public static EnumSet<Category> toSet(String... categories) { | ||
EnumSet<Category> set = EnumSet.noneOf(Category.class); | ||
for (String category : categories) { | ||
switch (category) { | ||
case "_all": | ||
return EnumSet.allOf(Category.class); | ||
case "_none": | ||
return EnumSet.noneOf(Category.class); | ||
default: | ||
set.add(Category.valueOf(category.toUpperCase(Locale.ROOT))); | ||
} | ||
} | ||
return set; | ||
} | ||
} | ||
|
||
private boolean verbose; | ||
private EnumSet<Category> categories = EnumSet.noneOf(Category.class); | ||
|
||
public XPackInfoRequest() {} | ||
|
||
public void setVerbose(boolean verbose) { | ||
this.verbose = verbose; | ||
} | ||
|
||
public boolean isVerbose() { | ||
return verbose; | ||
} | ||
|
||
public void setCategories(EnumSet<Category> categories) { | ||
this.categories = categories; | ||
} | ||
|
||
public EnumSet<Category> getCategories() { | ||
return categories; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
this.verbose = in.readBoolean(); | ||
EnumSet<Category> categories = EnumSet.noneOf(Category.class); | ||
int size = in.readVInt(); | ||
for (int i = 0; i < size; i++) { | ||
categories.add(Category.valueOf(in.readString())); | ||
} | ||
this.categories = categories; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeBoolean(verbose); | ||
out.writeVInt(categories.size()); | ||
for (Category category : categories) { | ||
out.writeString(category.name()); | ||
} | ||
} | ||
} |
Oops, something went wrong.