34
34
35
35
import org .apache .lucene .util .CollectionUtil ;
36
36
import org .opensearch .cluster .metadata .AliasMetadata ;
37
+ import org .opensearch .cluster .metadata .Context ;
37
38
import org .opensearch .cluster .metadata .MappingMetadata ;
38
39
import org .opensearch .common .settings .Settings ;
39
40
import org .opensearch .core .xcontent .XContentParser ;
@@ -61,6 +62,7 @@ public class GetIndexResponse {
61
62
private Map <String , Settings > settings ;
62
63
private Map <String , Settings > defaultSettings ;
63
64
private Map <String , String > dataStreams ;
65
+ private Map <String , Context > contexts ;
64
66
private String [] indices ;
65
67
66
68
GetIndexResponse (
@@ -69,7 +71,8 @@ public class GetIndexResponse {
69
71
Map <String , List <AliasMetadata >> aliases ,
70
72
Map <String , Settings > settings ,
71
73
Map <String , Settings > defaultSettings ,
72
- Map <String , String > dataStreams
74
+ Map <String , String > dataStreams ,
75
+ Map <String , Context > contexts
73
76
) {
74
77
this .indices = indices ;
75
78
// to have deterministic order
@@ -89,6 +92,9 @@ public class GetIndexResponse {
89
92
if (dataStreams != null ) {
90
93
this .dataStreams = dataStreams ;
91
94
}
95
+ if (contexts != null ) {
96
+ this .contexts = contexts ;
97
+ }
92
98
}
93
99
94
100
public String [] getIndices () {
@@ -123,6 +129,10 @@ public Map<String, String> getDataStreams() {
123
129
return dataStreams ;
124
130
}
125
131
132
+ public Map <String , Context > contexts () {
133
+ return contexts ;
134
+ }
135
+
126
136
/**
127
137
* Returns the string value for the specified index and setting. If the includeDefaults flag was not set or set to
128
138
* false on the {@link GetIndexRequest}, this method will only return a value where the setting was explicitly set
@@ -167,6 +177,7 @@ private static IndexEntry parseIndexEntry(XContentParser parser) throws IOExcept
167
177
Settings indexSettings = null ;
168
178
Settings indexDefaultSettings = null ;
169
179
String dataStream = null ;
180
+ Context context = null ;
170
181
// We start at START_OBJECT since fromXContent ensures that
171
182
while (parser .nextToken () != Token .END_OBJECT ) {
172
183
ensureExpectedToken (Token .FIELD_NAME , parser .currentToken (), parser );
@@ -185,6 +196,9 @@ private static IndexEntry parseIndexEntry(XContentParser parser) throws IOExcept
185
196
case "defaults" :
186
197
indexDefaultSettings = Settings .fromXContent (parser );
187
198
break ;
199
+ case "context" :
200
+ context = Context .fromXContent (parser );
201
+ break ;
188
202
default :
189
203
parser .skipChildren ();
190
204
}
@@ -197,7 +211,7 @@ private static IndexEntry parseIndexEntry(XContentParser parser) throws IOExcept
197
211
parser .skipChildren ();
198
212
}
199
213
}
200
- return new IndexEntry (indexAliases , indexMappings , indexSettings , indexDefaultSettings , dataStream );
214
+ return new IndexEntry (indexAliases , indexMappings , indexSettings , indexDefaultSettings , dataStream , context );
201
215
}
202
216
203
217
// This is just an internal container to make stuff easier for returning
@@ -207,19 +221,22 @@ private static class IndexEntry {
207
221
Settings indexSettings = Settings .EMPTY ;
208
222
Settings indexDefaultSettings = Settings .EMPTY ;
209
223
String dataStream ;
224
+ Context context ;
210
225
211
226
IndexEntry (
212
227
List <AliasMetadata > indexAliases ,
213
228
MappingMetadata indexMappings ,
214
229
Settings indexSettings ,
215
230
Settings indexDefaultSettings ,
216
- String dataStream
231
+ String dataStream ,
232
+ Context context
217
233
) {
218
234
if (indexAliases != null ) this .indexAliases = indexAliases ;
219
235
if (indexMappings != null ) this .indexMappings = indexMappings ;
220
236
if (indexSettings != null ) this .indexSettings = indexSettings ;
221
237
if (indexDefaultSettings != null ) this .indexDefaultSettings = indexDefaultSettings ;
222
238
if (dataStream != null ) this .dataStream = dataStream ;
239
+ if (context != null ) this .context = context ;
223
240
}
224
241
}
225
242
@@ -229,6 +246,7 @@ public static GetIndexResponse fromXContent(XContentParser parser) throws IOExce
229
246
Map <String , Settings > settings = new HashMap <>();
230
247
Map <String , Settings > defaultSettings = new HashMap <>();
231
248
Map <String , String > dataStreams = new HashMap <>();
249
+ Map <String , Context > contexts = new HashMap <>();
232
250
List <String > indices = new ArrayList <>();
233
251
234
252
if (parser .currentToken () == null ) {
@@ -254,12 +272,15 @@ public static GetIndexResponse fromXContent(XContentParser parser) throws IOExce
254
272
if (indexEntry .dataStream != null ) {
255
273
dataStreams .put (indexName , indexEntry .dataStream );
256
274
}
275
+ if (indexEntry .context != null ) {
276
+ contexts .put (indexName , indexEntry .context );
277
+ }
257
278
} else if (parser .currentToken () == Token .START_ARRAY ) {
258
279
parser .skipChildren ();
259
280
} else {
260
281
parser .nextToken ();
261
282
}
262
283
}
263
- return new GetIndexResponse (indices .toArray (new String [0 ]), mappings , aliases , settings , defaultSettings , dataStreams );
284
+ return new GetIndexResponse (indices .toArray (new String [0 ]), mappings , aliases , settings , defaultSettings , dataStreams , contexts );
264
285
}
265
286
}
0 commit comments