class Azure::CognitiveServices::LuisRuntime::V3_0::PredictionOperations

PredictionOperations

Attributes

client[R]

@return [LuisRuntimeClient] reference to the LuisRuntimeClient

Private Class Methods

new(client) click to toggle source

Creates and initializes a new instance of the PredictionOperations class. @param client service class for accessing basic functionality.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 17
def initialize(client)
  @client = client
end

Private Instance Methods

get_slot_prediction(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application slot.

@param app_id The application ID. @param slot_name [String] The application slot name. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PredictionResponse] operation results.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 164
def get_slot_prediction(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
  response = get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application slot.

@param app_id The application ID. @param slot_name [String] The application slot name. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 207
def get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, 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, 'slot_name is nil' if slot_name.nil?
  fail ArgumentError, 'prediction_request is nil' if prediction_request.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::LuisRuntime::V3_0::Models::PredictionRequest.mapper()
  request_content = @client.serialize(request_mapper,  prediction_request)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'apps/{appId}/slots/{slotName}/predict'

  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,'slotName' => slot_name},
      query_params: {'verbose' => verbose,'show-all-intents' => show_all_intents,'log' => log},
      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 == 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::LuisRuntime::V3_0::Models::PredictionResponse.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
get_slot_prediction_with_http_info(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application slot.

@param app_id The application ID. @param slot_name [String] The application slot name. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 186
def get_slot_prediction_with_http_info(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
  get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
end
get_version_prediction(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application version.

@param app_id The application ID. @param version_id [String] The application version ID. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PredictionResponse] operation results.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 41
def get_version_prediction(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
  response = get_version_prediction_async(app_id, version_id, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_version_prediction_async(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application version.

@param app_id The application ID. @param version_id [String] The application version ID. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 84
def get_version_prediction_async(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, 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, 'prediction_request is nil' if prediction_request.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::LuisRuntime::V3_0::Models::PredictionRequest.mapper()
  request_content = @client.serialize(request_mapper,  prediction_request)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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: {'verbose' => verbose,'show-all-intents' => show_all_intents,'log' => log},
      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 == 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::LuisRuntime::V3_0::Models::PredictionResponse.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
get_version_prediction_with_http_info(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil) click to toggle source

Gets the predictions for an application version.

@param app_id The application ID. @param version_id [String] The application version ID. @param prediction_request [PredictionRequest] The prediction request parameters. @param verbose [Boolean] Indicates whether to get extra metadata for the entities predictions or not. @param show_all_intents [Boolean] Indicates whether to return all the intents in the response or just the top intent. @param log [Boolean] Indicates whether to log the endpoint query or not. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/3.0/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb, line 63
def get_version_prediction_with_http_info(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
  get_version_prediction_async(app_id, version_id, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
end