class Azure::CognitiveServices::LuisAuthoring::V2_0::Pattern

Pattern

Attributes

client[R]

@return [LuisAuthoringClient] reference to the LuisAuthoringClient

Public Class Methods

new(client) click to toggle source

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

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 17
def initialize(client)
  @client = client
end

Public Instance Methods

add_pattern(app_id, version_id, pattern, custom_headers:nil) click to toggle source

Adds a pattern to a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern [PatternRuleCreateObject] The input pattern. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PatternRuleInfo] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 35
def add_pattern(app_id, version_id, pattern, custom_headers:nil)
  response = add_pattern_async(app_id, version_id, pattern, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
add_pattern_async(app_id, version_id, pattern, custom_headers:nil) click to toggle source

Adds a pattern to a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern [PatternRuleCreateObject] The input pattern. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 66
def add_pattern_async(app_id, version_id, pattern, 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, 'pattern is nil' if pattern.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::V2_0::Models::PatternRuleCreateObject.mapper()
  request_content = @client.serialize(request_mapper,  pattern)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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::V2_0::Models::PatternRuleInfo.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_pattern_with_http_info(app_id, version_id, pattern, custom_headers:nil) click to toggle source

Adds a pattern to a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern [PatternRuleCreateObject] The input pattern. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 51
def add_pattern_with_http_info(app_id, version_id, pattern, custom_headers:nil)
  add_pattern_async(app_id, version_id, pattern, custom_headers:custom_headers).value!
end
batch_add_patterns(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Adds a batch of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleCreateObject>] A JSON array containing patterns. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 401
def batch_add_patterns(app_id, version_id, patterns, custom_headers:nil)
  response = batch_add_patterns_async(app_id, version_id, patterns, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
batch_add_patterns_async(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Adds a batch of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleCreateObject>] A JSON array containing patterns. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 434
def batch_add_patterns_async(app_id, version_id, patterns, 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, 'patterns is nil' if patterns.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: 'patterns',
    type: {
      name: 'Sequence',
      element: {
          client_side_validation: true,
          required: false,
          serialized_name: 'PatternRuleCreateObjectElementType',
          type: {
            name: 'Composite',
            class_name: 'PatternRuleCreateObject'
          }
      }
    }
  }
  request_content = @client.serialize(request_mapper,  patterns)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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 = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'PatternRuleInfoElementType',
                type: {
                  name: 'Composite',
                  class_name: 'PatternRuleInfo'
                }
            }
          }
        }
        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_add_patterns_with_http_info(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Adds a batch of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleCreateObject>] A JSON array containing patterns. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 418
def batch_add_patterns_with_http_info(app_id, version_id, patterns, custom_headers:nil)
  batch_add_patterns_async(app_id, version_id, patterns, custom_headers:custom_headers).value!
end
delete_pattern(app_id, version_id, pattern_id, custom_headers:nil) click to toggle source

Deletes the pattern with the specified ID from a version of the application..

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [OperationStatus] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 766
def delete_pattern(app_id, version_id, pattern_id, custom_headers:nil)
  response = delete_pattern_async(app_id, version_id, pattern_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
delete_pattern_async(app_id, version_id, pattern_id, custom_headers:nil) click to toggle source

Deletes the pattern with the specified ID from a version of the application..

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 797
def delete_pattern_async(app_id, version_id, pattern_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, 'pattern_id is nil' if pattern_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}/patternrules/{patternId}'

  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,'patternId' => pattern_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::V2_0::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_pattern_with_http_info(app_id, version_id, pattern_id, custom_headers:nil) click to toggle source

Deletes the pattern with the specified ID from a version of the application..

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 782
def delete_pattern_with_http_info(app_id, version_id, pattern_id, custom_headers:nil)
  delete_pattern_async(app_id, version_id, pattern_id, custom_headers:custom_headers).value!
end
delete_patterns(app_id, version_id, pattern_ids, custom_headers:nil) click to toggle source

Deletes a list of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_ids The patterns IDs. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [OperationStatus] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 539
def delete_patterns(app_id, version_id, pattern_ids, custom_headers:nil)
  response = delete_patterns_async(app_id, version_id, pattern_ids, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
delete_patterns_async(app_id, version_id, pattern_ids, custom_headers:nil) click to toggle source

Deletes a list of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_ids The patterns IDs. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 570
def delete_patterns_async(app_id, version_id, pattern_ids, 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, 'pattern_ids is nil' if pattern_ids.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: 'patternIds',
    type: {
      name: 'Sequence',
      element: {
          client_side_validation: true,
          required: false,
          serialized_name: 'UuidElementType',
          type: {
            name: 'String'
          }
      }
    }
  }
  request_content = @client.serialize(request_mapper,  pattern_ids)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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(: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::V2_0::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_patterns_with_http_info(app_id, version_id, pattern_ids, custom_headers:nil) click to toggle source

Deletes a list of patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_ids The patterns IDs. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 555
def delete_patterns_with_http_info(app_id, version_id, pattern_ids, custom_headers:nil)
  delete_patterns_async(app_id, version_id, pattern_ids, custom_headers:custom_headers).value!
end
list_intent_patterns(app_id, version_id, intent_id, skip:0, take:100, custom_headers:nil) click to toggle source

Returns patterns for the specific intent in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param intent_id The intent classifier ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 866
def list_intent_patterns(app_id, version_id, intent_id, skip:0, take:100, custom_headers:nil)
  response = list_intent_patterns_async(app_id, version_id, intent_id, skip:skip, take:take, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_intent_patterns_async(app_id, version_id, intent_id, skip:0, take:100, custom_headers:nil) click to toggle source

Returns patterns for the specific intent in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param intent_id The intent classifier ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 903
def list_intent_patterns_async(app_id, version_id, intent_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, 'intent_id is nil' if intent_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}/intents/{intentId}/patternrules'

  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,'intentId' => intent_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: 'PatternRuleInfoElementType',
                type: {
                  name: 'Composite',
                  class_name: 'PatternRuleInfo'
                }
            }
          }
        }
        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_intent_patterns_with_http_info(app_id, version_id, intent_id, skip:0, take:100, custom_headers:nil) click to toggle source

Returns patterns for the specific intent in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param intent_id The intent classifier ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 885
def list_intent_patterns_with_http_info(app_id, version_id, intent_id, skip:0, take:100, custom_headers:nil)
  list_intent_patterns_async(app_id, version_id, intent_id, skip:skip, take:take, custom_headers:custom_headers).value!
end
list_patterns(app_id, version_id, skip:0, take:100, custom_headers:nil) click to toggle source

Gets patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 141
def list_patterns(app_id, version_id, skip:0, take:100, custom_headers:nil)
  response = list_patterns_async(app_id, version_id, skip:skip, take:take, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_patterns_async(app_id, version_id, skip:0, take:100, custom_headers:nil) click to toggle source

Gets patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 176
def list_patterns_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}/patternrules'

  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: 'PatternRuleInfoElementType',
                type: {
                  name: 'Composite',
                  class_name: 'PatternRuleInfo'
                }
            }
          }
        }
        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_patterns_with_http_info(app_id, version_id, skip:0, take:100, custom_headers:nil) click to toggle source

Gets patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param skip [Integer] The number of entries to skip. Default value is 0. @param take [Integer] The number of entries to return. Maximum page size is

  1. Default is 100.

@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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 159
def list_patterns_with_http_info(app_id, version_id, skip:0, take:100, custom_headers:nil)
  list_patterns_async(app_id, version_id, skip:skip, take:take, custom_headers:custom_headers).value!
end
update_pattern(app_id, version_id, pattern_id, pattern, custom_headers:nil) click to toggle source

Updates a pattern in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @param pattern [PatternRuleUpdateObject] An object representing a pattern. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PatternRuleInfo] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 659
def update_pattern(app_id, version_id, pattern_id, pattern, custom_headers:nil)
  response = update_pattern_async(app_id, version_id, pattern_id, pattern, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
update_pattern_async(app_id, version_id, pattern_id, pattern, custom_headers:nil) click to toggle source

Updates a pattern in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @param pattern [PatternRuleUpdateObject] An object representing a pattern. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 692
def update_pattern_async(app_id, version_id, pattern_id, pattern, 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, 'pattern_id is nil' if pattern_id.nil?
  fail ArgumentError, 'pattern is nil' if pattern.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::V2_0::Models::PatternRuleUpdateObject.mapper()
  request_content = @client.serialize(request_mapper,  pattern)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'apps/{appId}/versions/{versionId}/patternrules/{patternId}'

  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,'patternId' => pattern_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::V2_0::Models::PatternRuleInfo.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_pattern_with_http_info(app_id, version_id, pattern_id, pattern, custom_headers:nil) click to toggle source

Updates a pattern in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param pattern_id The pattern ID. @param pattern [PatternRuleUpdateObject] An object representing a pattern. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 676
def update_pattern_with_http_info(app_id, version_id, pattern_id, pattern, custom_headers:nil)
  update_pattern_async(app_id, version_id, pattern_id, pattern, custom_headers:custom_headers).value!
end
update_patterns(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Updates patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleUpdateObject>] An array represents the patterns. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 262
def update_patterns(app_id, version_id, patterns, custom_headers:nil)
  response = update_patterns_async(app_id, version_id, patterns, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
update_patterns_async(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Updates patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleUpdateObject>] An array represents the patterns. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 295
def update_patterns_async(app_id, version_id, patterns, 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, 'patterns is nil' if patterns.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: 'patterns',
    type: {
      name: 'Sequence',
      element: {
          client_side_validation: true,
          required: false,
          serialized_name: 'PatternRuleUpdateObjectElementType',
          type: {
            name: 'Composite',
            class_name: 'PatternRuleUpdateObject'
          }
      }
    }
  }
  request_content = @client.serialize(request_mapper,  patterns)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

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

  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 = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'PatternRuleInfoElementType',
                type: {
                  name: 'Composite',
                  class_name: 'PatternRuleInfo'
                }
            }
          }
        }
        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_patterns_with_http_info(app_id, version_id, patterns, custom_headers:nil) click to toggle source

Updates patterns in a version of the application.

@param app_id The application ID. @param version_id [String] The version ID. @param patterns [Array<PatternRuleUpdateObject>] An array represents the patterns. @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/2.0/generated/azure_cognitiveservices_luisauthoring/pattern.rb, line 279
def update_patterns_with_http_info(app_id, version_id, patterns, custom_headers:nil)
  update_patterns_async(app_id, version_id, patterns, custom_headers:custom_headers).value!
end