azure_cognitiveservices_qnamaker 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/4.0/generated/azure_cognitiveservices_qnamaker.rb +63 -0
  4. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/alterations.rb +189 -0
  5. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/endpoint_keys.rb +194 -0
  6. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/knowledgebase.rb +721 -0
  7. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/alterations_dto.rb +54 -0
  8. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/create_kb_dto.rb +111 -0
  9. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/create_kb_input_dto.rb +95 -0
  10. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/delete_kb_contents_dto.rb +74 -0
  11. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/endpoint_keys_dto.rb +79 -0
  12. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/environment_type.rb +16 -0
  13. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/error.rb +108 -0
  14. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/error_code_type.rb +28 -0
  15. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/error_response.rb +48 -0
  16. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/error_response_error.rb +85 -0
  17. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/file_dto.rb +62 -0
  18. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/inner_error_model.rb +62 -0
  19. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/knowledgebase_dto.rb +155 -0
  20. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/knowledgebase_environment_type.rb +16 -0
  21. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/knowledgebases_dto.rb +55 -0
  22. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/metadata_dto.rb +65 -0
  23. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/operation.rb +115 -0
  24. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/operation_state_type.rb +18 -0
  25. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/qn_adocuments_dto.rb +55 -0
  26. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/qn_adto.rb +116 -0
  27. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/replace_kb_dto.rb +57 -0
  28. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_kb_contents_dto.rb +87 -0
  29. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_kb_operation_dto.rb +74 -0
  30. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_kb_operation_dtoadd.rb +85 -0
  31. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_kb_operation_dtodelete.rb +67 -0
  32. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_kb_operation_dtoupdate.rb +76 -0
  33. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_metadata_dto.rb +77 -0
  34. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_qna_dto.rb +102 -0
  35. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_qna_dtometadata.rb +69 -0
  36. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_qna_dtoquestions.rb +67 -0
  37. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/update_questions_dto.rb +74 -0
  38. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/models/word_alterations_dto.rb +55 -0
  39. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/module_definition.rb +9 -0
  40. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/operations.rb +112 -0
  41. data/lib/4.0/generated/azure_cognitiveservices_qnamaker/qnamaker_client.rb +143 -0
  42. data/lib/azure_cognitiveservices_qnamaker.rb +6 -0
  43. data/lib/module_definition.rb +7 -0
  44. data/lib/profiles/latest/modules/qnamaker_profile_module.rb +193 -0
  45. data/lib/profiles/latest/qnamaker_latest_profile_client.rb +38 -0
  46. data/lib/profiles/latest/qnamaker_module_definition.rb +8 -0
  47. data/lib/version.rb +7 -0
  48. metadata +165 -0
@@ -0,0 +1,721 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::CognitiveServices::Qnamaker::V4_0
7
+ #
8
+ # An API for QnAMaker Service
9
+ #
10
+ class Knowledgebase
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Knowledgebase class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [QnamakerClient] reference to the QnamakerClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Gets all knowledgebases for a user.
26
+ #
27
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
28
+ # will be added to the HTTP request.
29
+ #
30
+ # @return [KnowledgebasesDTO] operation results.
31
+ #
32
+ def list_all(custom_headers:nil)
33
+ response = list_all_async(custom_headers:custom_headers).value!
34
+ response.body unless response.nil?
35
+ end
36
+
37
+ #
38
+ # Gets all knowledgebases for a user.
39
+ #
40
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
41
+ # will be added to the HTTP request.
42
+ #
43
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
44
+ #
45
+ def list_all_with_http_info(custom_headers:nil)
46
+ list_all_async(custom_headers:custom_headers).value!
47
+ end
48
+
49
+ #
50
+ # Gets all knowledgebases for a user.
51
+ #
52
+ # @param [Hash{String => String}] A hash of custom headers that will be added
53
+ # to the HTTP request.
54
+ #
55
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
56
+ #
57
+ def list_all_async(custom_headers:nil)
58
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
59
+
60
+
61
+ request_headers = {}
62
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
63
+
64
+ # Set Headers
65
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
66
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
67
+ path_template = 'knowledgebases'
68
+
69
+ request_url = @base_url || @client.base_url
70
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
71
+
72
+ options = {
73
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
74
+ headers: request_headers.merge(custom_headers || {}),
75
+ base_url: request_url
76
+ }
77
+ promise = @client.make_request_async(:get, path_template, options)
78
+
79
+ promise = promise.then do |result|
80
+ http_response = result.response
81
+ status_code = http_response.status
82
+ response_content = http_response.body
83
+ unless status_code == 200
84
+ error_model = JSON.load(response_content)
85
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
86
+ end
87
+
88
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
89
+ # Deserialize Response
90
+ if status_code == 200
91
+ begin
92
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
93
+ result_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::KnowledgebasesDTO.mapper()
94
+ result.body = @client.deserialize(result_mapper, parsed_response)
95
+ rescue Exception => e
96
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
97
+ end
98
+ end
99
+
100
+ result
101
+ end
102
+
103
+ promise.execute
104
+ end
105
+
106
+ #
107
+ # Gets details of a specific knowledgebase.
108
+ #
109
+ # @param kb_id [String] Knowledgebase id.
110
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
111
+ # will be added to the HTTP request.
112
+ #
113
+ # @return [KnowledgebaseDTO] operation results.
114
+ #
115
+ def get_details(kb_id, custom_headers:nil)
116
+ response = get_details_async(kb_id, custom_headers:custom_headers).value!
117
+ response.body unless response.nil?
118
+ end
119
+
120
+ #
121
+ # Gets details of a specific knowledgebase.
122
+ #
123
+ # @param kb_id [String] Knowledgebase id.
124
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
125
+ # will be added to the HTTP request.
126
+ #
127
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
128
+ #
129
+ def get_details_with_http_info(kb_id, custom_headers:nil)
130
+ get_details_async(kb_id, custom_headers:custom_headers).value!
131
+ end
132
+
133
+ #
134
+ # Gets details of a specific knowledgebase.
135
+ #
136
+ # @param kb_id [String] Knowledgebase id.
137
+ # @param [Hash{String => String}] A hash of custom headers that will be added
138
+ # to the HTTP request.
139
+ #
140
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
141
+ #
142
+ def get_details_async(kb_id, custom_headers:nil)
143
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
144
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
145
+
146
+
147
+ request_headers = {}
148
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
149
+
150
+ # Set Headers
151
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
152
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
153
+ path_template = 'knowledgebases/{kbId}'
154
+
155
+ request_url = @base_url || @client.base_url
156
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
157
+
158
+ options = {
159
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
160
+ path_params: {'kbId' => kb_id},
161
+ headers: request_headers.merge(custom_headers || {}),
162
+ base_url: request_url
163
+ }
164
+ promise = @client.make_request_async(:get, path_template, options)
165
+
166
+ promise = promise.then do |result|
167
+ http_response = result.response
168
+ status_code = http_response.status
169
+ response_content = http_response.body
170
+ unless status_code == 200
171
+ error_model = JSON.load(response_content)
172
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
173
+ end
174
+
175
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
176
+ # Deserialize Response
177
+ if status_code == 200
178
+ begin
179
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
180
+ result_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::KnowledgebaseDTO.mapper()
181
+ result.body = @client.deserialize(result_mapper, parsed_response)
182
+ rescue Exception => e
183
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
184
+ end
185
+ end
186
+
187
+ result
188
+ end
189
+
190
+ promise.execute
191
+ end
192
+
193
+ #
194
+ # Deletes the knowledgebase and all its data.
195
+ #
196
+ # @param kb_id [String] Knowledgebase id.
197
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
198
+ # will be added to the HTTP request.
199
+ #
200
+ #
201
+ def delete(kb_id, custom_headers:nil)
202
+ response = delete_async(kb_id, custom_headers:custom_headers).value!
203
+ nil
204
+ end
205
+
206
+ #
207
+ # Deletes the knowledgebase and all its data.
208
+ #
209
+ # @param kb_id [String] Knowledgebase id.
210
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
211
+ # will be added to the HTTP request.
212
+ #
213
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
214
+ #
215
+ def delete_with_http_info(kb_id, custom_headers:nil)
216
+ delete_async(kb_id, custom_headers:custom_headers).value!
217
+ end
218
+
219
+ #
220
+ # Deletes the knowledgebase and all its data.
221
+ #
222
+ # @param kb_id [String] Knowledgebase id.
223
+ # @param [Hash{String => String}] A hash of custom headers that will be added
224
+ # to the HTTP request.
225
+ #
226
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
227
+ #
228
+ def delete_async(kb_id, custom_headers:nil)
229
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
230
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
231
+
232
+
233
+ request_headers = {}
234
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
235
+
236
+ # Set Headers
237
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
238
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
239
+ path_template = 'knowledgebases/{kbId}'
240
+
241
+ request_url = @base_url || @client.base_url
242
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
243
+
244
+ options = {
245
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
246
+ path_params: {'kbId' => kb_id},
247
+ headers: request_headers.merge(custom_headers || {}),
248
+ base_url: request_url
249
+ }
250
+ promise = @client.make_request_async(:delete, path_template, options)
251
+
252
+ promise = promise.then do |result|
253
+ http_response = result.response
254
+ status_code = http_response.status
255
+ response_content = http_response.body
256
+ unless status_code == 204
257
+ error_model = JSON.load(response_content)
258
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
259
+ end
260
+
261
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
262
+
263
+ result
264
+ end
265
+
266
+ promise.execute
267
+ end
268
+
269
+ #
270
+ # Publishes all changes in test index of a knowledgebase to its prod index.
271
+ #
272
+ # @param kb_id [String] Knowledgebase id.
273
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
274
+ # will be added to the HTTP request.
275
+ #
276
+ #
277
+ def publish(kb_id, custom_headers:nil)
278
+ response = publish_async(kb_id, custom_headers:custom_headers).value!
279
+ nil
280
+ end
281
+
282
+ #
283
+ # Publishes all changes in test index of a knowledgebase to its prod index.
284
+ #
285
+ # @param kb_id [String] Knowledgebase id.
286
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
287
+ # will be added to the HTTP request.
288
+ #
289
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
290
+ #
291
+ def publish_with_http_info(kb_id, custom_headers:nil)
292
+ publish_async(kb_id, custom_headers:custom_headers).value!
293
+ end
294
+
295
+ #
296
+ # Publishes all changes in test index of a knowledgebase to its prod index.
297
+ #
298
+ # @param kb_id [String] Knowledgebase id.
299
+ # @param [Hash{String => String}] A hash of custom headers that will be added
300
+ # to the HTTP request.
301
+ #
302
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
303
+ #
304
+ def publish_async(kb_id, custom_headers:nil)
305
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
306
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
307
+
308
+
309
+ request_headers = {}
310
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
311
+
312
+ # Set Headers
313
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
314
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
315
+ path_template = 'knowledgebases/{kbId}'
316
+
317
+ request_url = @base_url || @client.base_url
318
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
319
+
320
+ options = {
321
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
322
+ path_params: {'kbId' => kb_id},
323
+ headers: request_headers.merge(custom_headers || {}),
324
+ base_url: request_url
325
+ }
326
+ promise = @client.make_request_async(:post, path_template, options)
327
+
328
+ promise = promise.then do |result|
329
+ http_response = result.response
330
+ status_code = http_response.status
331
+ response_content = http_response.body
332
+ unless status_code == 204
333
+ error_model = JSON.load(response_content)
334
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
335
+ end
336
+
337
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
338
+
339
+ result
340
+ end
341
+
342
+ promise.execute
343
+ end
344
+
345
+ #
346
+ # Replace knowledgebase contents.
347
+ #
348
+ # @param kb_id [String] Knowledgebase id.
349
+ # @param replace_kb [ReplaceKbDTO] An instance of ReplaceKbDTO which contains
350
+ # list of qnas to be uploaded
351
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
352
+ # will be added to the HTTP request.
353
+ #
354
+ #
355
+ def replace(kb_id, replace_kb, custom_headers:nil)
356
+ response = replace_async(kb_id, replace_kb, custom_headers:custom_headers).value!
357
+ nil
358
+ end
359
+
360
+ #
361
+ # Replace knowledgebase contents.
362
+ #
363
+ # @param kb_id [String] Knowledgebase id.
364
+ # @param replace_kb [ReplaceKbDTO] An instance of ReplaceKbDTO which contains
365
+ # list of qnas to be uploaded
366
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
367
+ # will be added to the HTTP request.
368
+ #
369
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
370
+ #
371
+ def replace_with_http_info(kb_id, replace_kb, custom_headers:nil)
372
+ replace_async(kb_id, replace_kb, custom_headers:custom_headers).value!
373
+ end
374
+
375
+ #
376
+ # Replace knowledgebase contents.
377
+ #
378
+ # @param kb_id [String] Knowledgebase id.
379
+ # @param replace_kb [ReplaceKbDTO] An instance of ReplaceKbDTO which contains
380
+ # list of qnas to be uploaded
381
+ # @param [Hash{String => String}] A hash of custom headers that will be added
382
+ # to the HTTP request.
383
+ #
384
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
385
+ #
386
+ def replace_async(kb_id, replace_kb, custom_headers:nil)
387
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
388
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
389
+ fail ArgumentError, 'replace_kb is nil' if replace_kb.nil?
390
+
391
+
392
+ request_headers = {}
393
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
394
+
395
+ # Set Headers
396
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
397
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
398
+
399
+ # Serialize Request
400
+ request_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::ReplaceKbDTO.mapper()
401
+ request_content = @client.serialize(request_mapper, replace_kb)
402
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
403
+
404
+ path_template = 'knowledgebases/{kbId}'
405
+
406
+ request_url = @base_url || @client.base_url
407
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
408
+
409
+ options = {
410
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
411
+ path_params: {'kbId' => kb_id},
412
+ body: request_content,
413
+ headers: request_headers.merge(custom_headers || {}),
414
+ base_url: request_url
415
+ }
416
+ promise = @client.make_request_async(:put, path_template, options)
417
+
418
+ promise = promise.then do |result|
419
+ http_response = result.response
420
+ status_code = http_response.status
421
+ response_content = http_response.body
422
+ unless status_code == 204
423
+ error_model = JSON.load(response_content)
424
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
425
+ end
426
+
427
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
428
+
429
+ result
430
+ end
431
+
432
+ promise.execute
433
+ end
434
+
435
+ #
436
+ # Asynchronous operation to modify a knowledgebase.
437
+ #
438
+ # @param kb_id [String] Knowledgebase id.
439
+ # @param update_kb [UpdateKbOperationDTO] Post body of the request.
440
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
441
+ # will be added to the HTTP request.
442
+ #
443
+ # @return [Operation] operation results.
444
+ #
445
+ def update(kb_id, update_kb, custom_headers:nil)
446
+ response = update_async(kb_id, update_kb, custom_headers:custom_headers).value!
447
+ response.body unless response.nil?
448
+ end
449
+
450
+ #
451
+ # Asynchronous operation to modify a knowledgebase.
452
+ #
453
+ # @param kb_id [String] Knowledgebase id.
454
+ # @param update_kb [UpdateKbOperationDTO] Post body of the request.
455
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
456
+ # will be added to the HTTP request.
457
+ #
458
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
459
+ #
460
+ def update_with_http_info(kb_id, update_kb, custom_headers:nil)
461
+ update_async(kb_id, update_kb, custom_headers:custom_headers).value!
462
+ end
463
+
464
+ #
465
+ # Asynchronous operation to modify a knowledgebase.
466
+ #
467
+ # @param kb_id [String] Knowledgebase id.
468
+ # @param update_kb [UpdateKbOperationDTO] Post body of the request.
469
+ # @param [Hash{String => String}] A hash of custom headers that will be added
470
+ # to the HTTP request.
471
+ #
472
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
473
+ #
474
+ def update_async(kb_id, update_kb, custom_headers:nil)
475
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
476
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
477
+ fail ArgumentError, 'update_kb is nil' if update_kb.nil?
478
+
479
+
480
+ request_headers = {}
481
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
482
+
483
+ # Set Headers
484
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
485
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
486
+
487
+ # Serialize Request
488
+ request_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::UpdateKbOperationDTO.mapper()
489
+ request_content = @client.serialize(request_mapper, update_kb)
490
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
491
+
492
+ path_template = 'knowledgebases/{kbId}'
493
+
494
+ request_url = @base_url || @client.base_url
495
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
496
+
497
+ options = {
498
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
499
+ path_params: {'kbId' => kb_id},
500
+ body: request_content,
501
+ headers: request_headers.merge(custom_headers || {}),
502
+ base_url: request_url
503
+ }
504
+ promise = @client.make_request_async(:patch, path_template, options)
505
+
506
+ promise = promise.then do |result|
507
+ http_response = result.response
508
+ status_code = http_response.status
509
+ response_content = http_response.body
510
+ unless status_code == 202
511
+ error_model = JSON.load(response_content)
512
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
513
+ end
514
+
515
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
516
+ # Deserialize Response
517
+ if status_code == 202
518
+ begin
519
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
520
+ result_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::Operation.mapper()
521
+ result.body = @client.deserialize(result_mapper, parsed_response)
522
+ rescue Exception => e
523
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
524
+ end
525
+ end
526
+
527
+ result
528
+ end
529
+
530
+ promise.execute
531
+ end
532
+
533
+ #
534
+ # Asynchronous operation to create a new knowledgebase.
535
+ #
536
+ # @param create_kb_payload [CreateKbDTO] Post body of the request.
537
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
538
+ # will be added to the HTTP request.
539
+ #
540
+ # @return [Operation] operation results.
541
+ #
542
+ def create(create_kb_payload, custom_headers:nil)
543
+ response = create_async(create_kb_payload, custom_headers:custom_headers).value!
544
+ response.body unless response.nil?
545
+ end
546
+
547
+ #
548
+ # Asynchronous operation to create a new knowledgebase.
549
+ #
550
+ # @param create_kb_payload [CreateKbDTO] Post body of the request.
551
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
552
+ # will be added to the HTTP request.
553
+ #
554
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
555
+ #
556
+ def create_with_http_info(create_kb_payload, custom_headers:nil)
557
+ create_async(create_kb_payload, custom_headers:custom_headers).value!
558
+ end
559
+
560
+ #
561
+ # Asynchronous operation to create a new knowledgebase.
562
+ #
563
+ # @param create_kb_payload [CreateKbDTO] Post body of the request.
564
+ # @param [Hash{String => String}] A hash of custom headers that will be added
565
+ # to the HTTP request.
566
+ #
567
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
568
+ #
569
+ def create_async(create_kb_payload, custom_headers:nil)
570
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
571
+ fail ArgumentError, 'create_kb_payload is nil' if create_kb_payload.nil?
572
+
573
+
574
+ request_headers = {}
575
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
576
+
577
+ # Set Headers
578
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
579
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
580
+
581
+ # Serialize Request
582
+ request_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::CreateKbDTO.mapper()
583
+ request_content = @client.serialize(request_mapper, create_kb_payload)
584
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
585
+
586
+ path_template = 'knowledgebases/create'
587
+
588
+ request_url = @base_url || @client.base_url
589
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
590
+
591
+ options = {
592
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
593
+ body: request_content,
594
+ headers: request_headers.merge(custom_headers || {}),
595
+ base_url: request_url
596
+ }
597
+ promise = @client.make_request_async(:post, path_template, options)
598
+
599
+ promise = promise.then do |result|
600
+ http_response = result.response
601
+ status_code = http_response.status
602
+ response_content = http_response.body
603
+ unless status_code == 202
604
+ error_model = JSON.load(response_content)
605
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
606
+ end
607
+
608
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
609
+ # Deserialize Response
610
+ if status_code == 202
611
+ begin
612
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
613
+ result_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::Operation.mapper()
614
+ result.body = @client.deserialize(result_mapper, parsed_response)
615
+ rescue Exception => e
616
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
617
+ end
618
+ end
619
+
620
+ result
621
+ end
622
+
623
+ promise.execute
624
+ end
625
+
626
+ #
627
+ # Download the knowledgebase.
628
+ #
629
+ # @param kb_id [String] Knowledgebase id.
630
+ # @param environment [EnvironmentType] Specifies whether environment is Test or
631
+ # Prod. Possible values include: 'Prod', 'Test'
632
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
633
+ # will be added to the HTTP request.
634
+ #
635
+ # @return [QnADocumentsDTO] operation results.
636
+ #
637
+ def download(kb_id, environment, custom_headers:nil)
638
+ response = download_async(kb_id, environment, custom_headers:custom_headers).value!
639
+ response.body unless response.nil?
640
+ end
641
+
642
+ #
643
+ # Download the knowledgebase.
644
+ #
645
+ # @param kb_id [String] Knowledgebase id.
646
+ # @param environment [EnvironmentType] Specifies whether environment is Test or
647
+ # Prod. Possible values include: 'Prod', 'Test'
648
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
649
+ # will be added to the HTTP request.
650
+ #
651
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
652
+ #
653
+ def download_with_http_info(kb_id, environment, custom_headers:nil)
654
+ download_async(kb_id, environment, custom_headers:custom_headers).value!
655
+ end
656
+
657
+ #
658
+ # Download the knowledgebase.
659
+ #
660
+ # @param kb_id [String] Knowledgebase id.
661
+ # @param environment [EnvironmentType] Specifies whether environment is Test or
662
+ # Prod. Possible values include: 'Prod', 'Test'
663
+ # @param [Hash{String => String}] A hash of custom headers that will be added
664
+ # to the HTTP request.
665
+ #
666
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
667
+ #
668
+ def download_async(kb_id, environment, custom_headers:nil)
669
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
670
+ fail ArgumentError, 'kb_id is nil' if kb_id.nil?
671
+ fail ArgumentError, 'environment is nil' if environment.nil?
672
+
673
+
674
+ request_headers = {}
675
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
676
+
677
+ # Set Headers
678
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
679
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
680
+ path_template = 'knowledgebases/{kbId}/{environment}/qna'
681
+
682
+ request_url = @base_url || @client.base_url
683
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
684
+
685
+ options = {
686
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
687
+ path_params: {'kbId' => kb_id,'environment' => environment},
688
+ headers: request_headers.merge(custom_headers || {}),
689
+ base_url: request_url
690
+ }
691
+ promise = @client.make_request_async(:get, path_template, options)
692
+
693
+ promise = promise.then do |result|
694
+ http_response = result.response
695
+ status_code = http_response.status
696
+ response_content = http_response.body
697
+ unless status_code == 200
698
+ error_model = JSON.load(response_content)
699
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
700
+ end
701
+
702
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
703
+ # Deserialize Response
704
+ if status_code == 200
705
+ begin
706
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
707
+ result_mapper = Azure::CognitiveServices::Qnamaker::V4_0::Models::QnADocumentsDTO.mapper()
708
+ result.body = @client.deserialize(result_mapper, parsed_response)
709
+ rescue Exception => e
710
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
711
+ end
712
+ end
713
+
714
+ result
715
+ end
716
+
717
+ promise.execute
718
+ end
719
+
720
+ end
721
+ end