Class: Azure::CognitiveServices::LuisAuthoring::V3_0_preview::Settings

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

Overview

Settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Settings

Creates and initializes a new instance of the Settings class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.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/settings.rb', line 22

def client
  @client
end

Instance Method Details

#list(app_id, version_id, custom_headers: nil) ⇒ Array

Gets the settings in a version of the application.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

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

    A hash of custom headers that

Returns:

  • (Array)

    operation results.



34
35
36
37
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.rb', line 34

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

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

Gets the settings in a version of the application.

to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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

def list_async(app_id, version_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?


  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}/settings'

  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},
      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: 'AppVersionSettingObjectElementType',
                type: {
                  name: 'Composite',
                  class_name: 'AppVersionSettingObject'
                }
            }
          }
        }
        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, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets the settings in a version of the application.

will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



49
50
51
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.rb', line 49

def list_with_http_info(app_id, version_id, custom_headers:nil)
  list_async(app_id, version_id, custom_headers:custom_headers).value!
end

#update(app_id, version_id, list_of_app_version_setting_object, custom_headers: nil) ⇒ OperationStatus

Updates the settings in a version of the application.

list of the updated application version settings. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • list_of_app_version_setting_object (Array<AppVersionSettingObject>)

    A

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

    A hash of custom headers that

Returns:

  • (OperationStatus)

    operation results.



145
146
147
148
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.rb', line 145

def update(app_id, version_id, list_of_app_version_setting_object, custom_headers:nil)
  response = update_async(app_id, version_id, list_of_app_version_setting_object, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#update_async(app_id, version_id, list_of_app_version_setting_object, custom_headers: nil) ⇒ Concurrent::Promise

Updates the settings in a version of the application.

list of the updated application version settings. to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • list_of_app_version_setting_object (Array<AppVersionSettingObject>)

    A

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.rb', line 178

def update_async(app_id, version_id, list_of_app_version_setting_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, 'list_of_app_version_setting_object is nil' if list_of_app_version_setting_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 = {
    client_side_validation: true,
    required: true,
    serialized_name: 'listOfAppVersionSettingObject',
    type: {
      name: 'Sequence',
      element: {
          client_side_validation: true,
          required: false,
          serialized_name: 'AppVersionSettingObjectElementType',
          type: {
            name: 'Composite',
            class_name: 'AppVersionSettingObject'
          }
      }
    }
  }
  request_content = @client.serialize(request_mapper,  list_of_app_version_setting_object)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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(:put, 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

#update_with_http_info(app_id, version_id, list_of_app_version_setting_object, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Updates the settings in a version of the application.

list of the updated application version settings. will be added to the HTTP request.

Parameters:

  • app_id

    The application ID.

  • version_id (String)

    The version ID.

  • list_of_app_version_setting_object (Array<AppVersionSettingObject>)

    A

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



162
163
164
# File 'lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/settings.rb', line 162

def update_with_http_info(app_id, version_id, list_of_app_version_setting_object, custom_headers:nil)
  update_async(app_id, version_id, list_of_app_version_setting_object, custom_headers:custom_headers).value!
end