-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
indexes.ts
322 lines (311 loc) · 9.3 KB
/
indexes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { Indexes } from "../operationsInterfaces";
import * as coreHttp from "@azure/core-http";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SearchServiceClientContext } from "../searchServiceClientContext";
import {
SearchIndex,
IndexesCreateOptionalParams,
IndexesCreateResponse,
IndexesListOptionalParams,
IndexesListResponse,
IndexesCreateOrUpdateOptionalParams,
IndexesCreateOrUpdateResponse,
IndexesDeleteOptionalParams,
IndexesGetOptionalParams,
IndexesGetResponse,
IndexesGetStatisticsOptionalParams,
IndexesGetStatisticsResponse,
AnalyzeRequest,
IndexesAnalyzeOptionalParams,
IndexesAnalyzeResponse
} from "../models";
/** Class representing a Indexes. */
export class IndexesImpl implements Indexes {
private readonly client: SearchServiceClientContext;
/**
* Initialize a new instance of the class Indexes class.
* @param client Reference to the service client
*/
constructor(client: SearchServiceClientContext) {
this.client = client;
}
/**
* Creates a new search index.
* @param index The definition of the index to create.
* @param options The options parameters.
*/
create(
index: SearchIndex,
options?: IndexesCreateOptionalParams
): Promise<IndexesCreateResponse> {
const operationArguments: coreHttp.OperationArguments = {
index,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
createOperationSpec
) as Promise<IndexesCreateResponse>;
}
/**
* Lists all indexes available for a search service.
* @param options The options parameters.
*/
list(options?: IndexesListOptionalParams): Promise<IndexesListResponse> {
const operationArguments: coreHttp.OperationArguments = {
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
listOperationSpec
) as Promise<IndexesListResponse>;
}
/**
* Creates a new search index or updates an index if it already exists.
* @param indexName The definition of the index to create or update.
* @param index The definition of the index to create or update.
* @param options The options parameters.
*/
createOrUpdate(
indexName: string,
index: SearchIndex,
options?: IndexesCreateOrUpdateOptionalParams
): Promise<IndexesCreateOrUpdateResponse> {
const operationArguments: coreHttp.OperationArguments = {
indexName,
index,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
createOrUpdateOperationSpec
) as Promise<IndexesCreateOrUpdateResponse>;
}
/**
* Deletes a search index and all the documents it contains. This operation is permanent, with no
* recovery option. Make sure you have a master copy of your index definition, data ingestion code, and
* a backup of the primary data source in case you need to re-build the index.
* @param indexName The name of the index to delete.
* @param options The options parameters.
*/
delete(
indexName: string,
options?: IndexesDeleteOptionalParams
): Promise<coreHttp.RestResponse> {
const operationArguments: coreHttp.OperationArguments = {
indexName,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
deleteOperationSpec
) as Promise<coreHttp.RestResponse>;
}
/**
* Retrieves an index definition.
* @param indexName The name of the index to retrieve.
* @param options The options parameters.
*/
get(
indexName: string,
options?: IndexesGetOptionalParams
): Promise<IndexesGetResponse> {
const operationArguments: coreHttp.OperationArguments = {
indexName,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
getOperationSpec
) as Promise<IndexesGetResponse>;
}
/**
* Returns statistics for the given index, including a document count and storage usage.
* @param indexName The name of the index for which to retrieve statistics.
* @param options The options parameters.
*/
getStatistics(
indexName: string,
options?: IndexesGetStatisticsOptionalParams
): Promise<IndexesGetStatisticsResponse> {
const operationArguments: coreHttp.OperationArguments = {
indexName,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
getStatisticsOperationSpec
) as Promise<IndexesGetStatisticsResponse>;
}
/**
* Shows how an analyzer breaks text into tokens.
* @param indexName The name of the index for which to test an analyzer.
* @param request The text and analyzer or analysis components to test.
* @param options The options parameters.
*/
analyze(
indexName: string,
request: AnalyzeRequest,
options?: IndexesAnalyzeOptionalParams
): Promise<IndexesAnalyzeResponse> {
const operationArguments: coreHttp.OperationArguments = {
indexName,
request,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(
operationArguments,
analyzeOperationSpec
) as Promise<IndexesAnalyzeResponse>;
}
}
// Operation Specifications
const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
const createOperationSpec: coreHttp.OperationSpec = {
path: "/indexes",
httpMethod: "POST",
responses: {
201: {
bodyMapper: Mappers.SearchIndex
},
default: {
bodyMapper: Mappers.SearchError
}
},
requestBody: Parameters.index,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.xMsClientRequestId
],
mediaType: "json",
serializer
};
const listOperationSpec: coreHttp.OperationSpec = {
path: "/indexes",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ListIndexesResult
},
default: {
bodyMapper: Mappers.SearchError
}
},
queryParameters: [Parameters.apiVersion, Parameters.select],
urlParameters: [Parameters.endpoint],
headerParameters: [Parameters.accept, Parameters.xMsClientRequestId],
serializer
};
const createOrUpdateOperationSpec: coreHttp.OperationSpec = {
path: "/indexes('{indexName}')",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.SearchIndex
},
201: {
bodyMapper: Mappers.SearchIndex
},
default: {
bodyMapper: Mappers.SearchError
}
},
requestBody: Parameters.index,
queryParameters: [Parameters.apiVersion, Parameters.allowIndexDowntime],
urlParameters: [Parameters.endpoint, Parameters.indexName],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.xMsClientRequestId,
Parameters.ifMatch,
Parameters.ifNoneMatch,
Parameters.prefer
],
mediaType: "json",
serializer
};
const deleteOperationSpec: coreHttp.OperationSpec = {
path: "/indexes('{indexName}')",
httpMethod: "DELETE",
responses: {
204: {},
404: {},
default: {
bodyMapper: Mappers.SearchError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.indexName],
headerParameters: [
Parameters.accept,
Parameters.xMsClientRequestId,
Parameters.ifMatch,
Parameters.ifNoneMatch
],
serializer
};
const getOperationSpec: coreHttp.OperationSpec = {
path: "/indexes('{indexName}')",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.SearchIndex
},
default: {
bodyMapper: Mappers.SearchError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.indexName],
headerParameters: [Parameters.accept, Parameters.xMsClientRequestId],
serializer
};
const getStatisticsOperationSpec: coreHttp.OperationSpec = {
path: "/indexes('{indexName}')/search.stats",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.GetIndexStatisticsResult
},
default: {
bodyMapper: Mappers.SearchError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.indexName],
headerParameters: [Parameters.accept, Parameters.xMsClientRequestId],
serializer
};
const analyzeOperationSpec: coreHttp.OperationSpec = {
path: "/indexes('{indexName}')/search.analyze",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.AnalyzeResult
},
default: {
bodyMapper: Mappers.SearchError
}
},
requestBody: Parameters.request,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint, Parameters.indexName],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.xMsClientRequestId
],
mediaType: "json",
serializer
};