|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | + |
| 9 | +package org.elasticsearch.client.feature; |
| 10 | + |
| 11 | +import org.elasticsearch.common.ParseField; |
| 12 | +import org.elasticsearch.common.xcontent.ConstructingObjectParser; |
| 13 | +import org.elasticsearch.common.xcontent.ObjectParser; |
| 14 | +import org.elasticsearch.common.xcontent.XContentParser; |
| 15 | + |
| 16 | +import java.util.List; |
| 17 | + |
| 18 | +public class ResetFeaturesResponse { |
| 19 | + private final List<ResetFeatureStateStatus> features; |
| 20 | + |
| 21 | + private static final ParseField FEATURES = new ParseField("features"); |
| 22 | + |
| 23 | + @SuppressWarnings("unchecked") |
| 24 | + private static final ConstructingObjectParser<ResetFeaturesResponse, Void> PARSER = new ConstructingObjectParser<>( |
| 25 | + "snapshottable_features_response", true, |
| 26 | + (a, ctx) -> new ResetFeaturesResponse((List<ResetFeatureStateStatus>) a[0]) |
| 27 | + ); |
| 28 | + |
| 29 | + static { |
| 30 | + PARSER.declareObjectArray( |
| 31 | + ConstructingObjectParser.constructorArg(), |
| 32 | + ResetFeaturesResponse.ResetFeatureStateStatus::parse, FEATURES); |
| 33 | + } |
| 34 | + |
| 35 | + public ResetFeaturesResponse(List<ResetFeatureStateStatus> features) { |
| 36 | + this.features = features; |
| 37 | + } |
| 38 | + |
| 39 | + public List<ResetFeatureStateStatus> getFeatures() { |
| 40 | + return features; |
| 41 | + } |
| 42 | + |
| 43 | + public static ResetFeaturesResponse parse(XContentParser parser) { |
| 44 | + return PARSER.apply(parser, null); |
| 45 | + } |
| 46 | + |
| 47 | + public static class ResetFeatureStateStatus { |
| 48 | + private final String featureName; |
| 49 | + private final String status; |
| 50 | + |
| 51 | + private static final ParseField FEATURE_NAME = new ParseField("feature_name"); |
| 52 | + private static final ParseField STATUS = new ParseField("status"); |
| 53 | + |
| 54 | + private static final ConstructingObjectParser<ResetFeatureStateStatus, Void> PARSER = new ConstructingObjectParser<>( |
| 55 | + "features", true, (a, ctx) -> new ResetFeatureStateStatus((String) a[0], (String) a[1]) |
| 56 | + ); |
| 57 | + |
| 58 | + static { |
| 59 | + PARSER.declareField(ConstructingObjectParser.constructorArg(), |
| 60 | + (p, c) -> p.text(), FEATURE_NAME, ObjectParser.ValueType.STRING); |
| 61 | + PARSER.declareField(ConstructingObjectParser.constructorArg(), |
| 62 | + (p, c) -> p.text(), STATUS, ObjectParser.ValueType.STRING); |
| 63 | + } |
| 64 | + |
| 65 | + ResetFeatureStateStatus(String featureName, String status) { |
| 66 | + this.featureName = featureName; |
| 67 | + this.status = status; |
| 68 | + } |
| 69 | + |
| 70 | + public static ResetFeatureStateStatus parse(XContentParser parser, Void ctx) { |
| 71 | + return PARSER.apply(parser, ctx); |
| 72 | + } |
| 73 | + |
| 74 | + public String getFeatureName() { |
| 75 | + return featureName; |
| 76 | + } |
| 77 | + |
| 78 | + public String getStatus() { |
| 79 | + return status; |
| 80 | + } |
| 81 | + } |
| 82 | +} |
0 commit comments