Class: Azure::CognitiveServices::LuisAuthoring::V3_0_preview::Examples

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb

Overview

Examples

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Examples

Creates and initializes a new instance of the Examples class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientLuisAuthoringClient (readonly)

Returns reference to the LuisAuthoringClient.

Returns:



22
23
24
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 22

def client
  @client
end

Instance Method Details

#add(app_id, version_id, example_label_object, custom_headers: nil) ⇒ LabelExampleResponse

Adds a labeled example utterance in a version of the application.

with the expected intent and entities. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object (ExampleLabelObject)

    A labeled example utterance

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (LabelExampleResponse)

    operation results.



36
37
38
39
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 36

def add(app_id, version_id, example_label_object, custom_headers:nil)
  response = add_async(app_id, version_id, example_label_object, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#add_async(app_id, version_id, example_label_object, custom_headers: nil) ⇒ Concurrent::Promise

Adds a labeled example utterance in a version of the application.

with the expected intent and entities. to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object (ExampleLabelObject)

    A labeled example utterance

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 69

def add_async(app_id, version_id, example_label_object, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_id.nil?
  fail ArgumentError, 'version_id is nil' if version_id.nil?
  fail ArgumentError, 'example_label_object is nil' if example_label_object.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::LuisAuthoring::V3_0_preview::Models::ExampleLabelObject.mapper()
  request_content = @client.serialize(request_mapper,  example_label_object)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'apps/{appId}/versions/{versionId}/example'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'appId' => app_id,'versionId' => version_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 201
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::LuisAuthoring::V3_0_preview::Models::LabelExampleResponse.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#add_with_http_info(app_id, version_id, example_label_object, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Adds a labeled example utterance in a version of the application.

with the expected intent and entities. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object (ExampleLabelObject)

    A labeled example utterance

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



53
54
55
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 53

def add_with_http_info(app_id, version_id, example_label_object, custom_headers:nil)
  add_async(app_id, version_id, example_label_object, custom_headers:custom_headers).value!
end

#batch(app_id, version_id, example_label_object_array, custom_headers: nil) ⇒ Array

Adds a batch of labeled example utterances to a version of the application.

example utterances. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object_array (Array<ExampleLabelObject>)

    Array of

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (Array)

    operation results.



143
144
145
146
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 143

def batch(app_id, version_id, example_label_object_array, custom_headers:nil)
  response = batch_async(app_id, version_id, example_label_object_array, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#batch_async(app_id, version_id, example_label_object_array, custom_headers: nil) ⇒ Concurrent::Promise

Adds a batch of labeled example utterances to a version of the application.

example utterances. to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object_array (Array<ExampleLabelObject>)

    Array of

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 176

def batch_async(app_id, version_id, example_label_object_array, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_id.nil?
  fail ArgumentError, 'version_id is nil' if version_id.nil?
  fail ArgumentError, 'example_label_object_array is nil' if example_label_object_array.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = {
    client_side_validation: true,
    required: true,
    serialized_name: 'exampleLabelObjectArray',
    type: {
      name: 'Sequence',
      element: {
          client_side_validation: true,
          required: false,
          serialized_name: 'ExampleLabelObjectElementType',
          type: {
            name: 'Composite',
            class_name: 'ExampleLabelObject'
          }
      }
    }
  }
  request_content = @client.serialize(request_mapper,  example_label_object_array)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'apps/{appId}/versions/{versionId}/examples'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'appId' => app_id,'versionId' => version_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 201 || status_code == 207
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'BatchLabelExampleElementType',
                type: {
                  name: 'Composite',
                  class_name: 'BatchLabelExample'
                }
            }
          }
        }
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end
    # Deserialize Response
    if status_code == 207
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'BatchLabelExampleElementType',
                type: {
                  name: 'Composite',
                  class_name: 'BatchLabelExample'
                }
            }
          }
        }
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#batch_with_http_info(app_id, version_id, example_label_object_array, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Adds a batch of labeled example utterances to a version of the application.

example utterances. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_label_object_array (Array<ExampleLabelObject>)

    Array of

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



160
161
162
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 160

def batch_with_http_info(app_id, version_id, example_label_object_array, custom_headers:nil)
  batch_async(app_id, version_id, example_label_object_array, custom_headers:custom_headers).value!
end

#delete(app_id, version_id, example_id, custom_headers: nil) ⇒ OperationStatus

Deletes the labeled example utterances with the specified ID from a version of the application.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_id (Integer)

    The example ID.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (OperationStatus)

    operation results.



430
431
432
433
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 430

def delete(app_id, version_id, example_id, custom_headers:nil)
  response = delete_async(app_id, version_id, example_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#delete_async(app_id, version_id, example_id, custom_headers: nil) ⇒ Concurrent::Promise

Deletes the labeled example utterances with the specified ID from a version of the application.

to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_id (Integer)

    The example ID.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 463

def delete_async(app_id, version_id, example_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_id.nil?
  fail ArgumentError, 'version_id is nil' if version_id.nil?
  fail ArgumentError, 'example_id is nil' if example_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'apps/{appId}/versions/{versionId}/examples/{exampleId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'appId' => app_id,'versionId' => version_id,'exampleId' => example_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::LuisAuthoring::V3_0_preview::Models::OperationStatus.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#delete_with_http_info(app_id, version_id, example_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes the labeled example utterances with the specified ID from a version of the application.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • example_id (Integer)

    The example ID.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



447
448
449
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 447

def delete_with_http_info(app_id, version_id, example_id, custom_headers:nil)
  delete_async(app_id, version_id, example_id, custom_headers:custom_headers).value!
end

#list(app_id, version_id, skip: 0, take: 100, custom_headers: nil) ⇒ Array

Returns example utterances to be reviewed from a version of the application.

  1. Default is 100.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • skip (Integer) (defaults to: 0)

    The number of entries to skip. Default value is 0.

  • take (Integer) (defaults to: 100)

    The number of entries to return. Maximum page size is

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (Array)

    operation results.



309
310
311
312
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 309

def list(app_id, version_id, skip:0, take:100, custom_headers:nil)
  response = list_async(app_id, version_id, skip:skip, take:take, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_async(app_id, version_id, skip: 0, take: 100, custom_headers: nil) ⇒ Concurrent::Promise

Returns example utterances to be reviewed from a version of the application.

  1. Default is 100.

to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • skip (Integer) (defaults to: 0)

    The number of entries to skip. Default value is 0.

  • take (Integer) (defaults to: 100)

    The number of entries to return. Maximum page size is

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 344

def list_async(app_id, version_id, skip:0, take:100, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_id.nil?
  fail ArgumentError, 'version_id is nil' if version_id.nil?
  fail ArgumentError, "'skip' should satisfy the constraint - 'InclusiveMinimum': '0'" if !skip.nil? && skip < 0
  fail ArgumentError, "'take' should satisfy the constraint - 'InclusiveMaximum': '500'" if !take.nil? && take > 500
  fail ArgumentError, "'take' should satisfy the constraint - 'InclusiveMinimum': '0'" if !take.nil? && take < 0


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'apps/{appId}/versions/{versionId}/examples'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'appId' => app_id,'versionId' => version_id},
      query_params: {'skip' => skip,'take' => take},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'LabeledUtteranceElementType',
                type: {
                  name: 'Composite',
                  class_name: 'LabeledUtterance'
                }
            }
          }
        }
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_with_http_info(app_id, version_id, skip: 0, take: 100, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Returns example utterances to be reviewed from a version of the application.

  1. Default is 100.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • skip (Integer) (defaults to: 0)

    The number of entries to skip. Default value is 0.

  • take (Integer) (defaults to: 100)

    The number of entries to return. Maximum page size is

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



327
328
329
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/examples.rb', line 327

def list_with_http_info(app_id, version_id, skip:0, take:100, custom_headers:nil)
  list_async(app_id, version_id, skip:skip, take:take, custom_headers:custom_headers).value!
end