azure_cognitiveservices_qnamaker 0.18.0 → 0.18.1

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