class Azure::CognitiveServices::LuisAuthoring::V3_0_preview::AzureAccounts

AzureAccounts

Attributes

client[R]

@return [LuisAuthoringClient] reference to the LuisAuthoringClient

Private Class Methods

new(client) click to toggle source

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

# File lib/3.0-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 17
def initialize(client)
  @client = client
end

Private Instance Methods

assign_to_app(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Assign a LUIS Azure account to an application

Assigns an Azure account to the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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/3.0-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 39
def assign_to_app(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  response = assign_to_app_async(app_id, arm_token:arm_token, azure_account_info_object:azure_account_info_object, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
assign_to_app_async(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Assign a LUIS Azure account to an application

Assigns an Azure account to the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 78
def assign_to_app_async(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_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['ArmToken'] = arm_token unless arm_token.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

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

  path_template = 'apps/{appId}/azureaccounts'

  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},
      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::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
assign_to_app_with_http_info(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Assign a LUIS Azure account to an application

Assigns an Azure account to the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 59
def assign_to_app_with_http_info(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  assign_to_app_async(app_id, arm_token:arm_token, azure_account_info_object:azure_account_info_object, custom_headers:custom_headers).value!
end
get_assigned(app_id, arm_token:nil, custom_headers:nil) click to toggle source

apps - Get LUIS Azure accounts assigned to the application

Gets the LUIS Azure accounts assigned to the application for the user using his ARM token.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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/3.0-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 153
def get_assigned(app_id, arm_token:nil, custom_headers:nil)
  response = get_assigned_async(app_id, arm_token:arm_token, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_assigned_async(app_id, arm_token:nil, custom_headers:nil) click to toggle source

apps - Get LUIS Azure accounts assigned to the application

Gets the LUIS Azure accounts assigned to the application for the user using his ARM token.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 190
def get_assigned_async(app_id, arm_token:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_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['ArmToken'] = arm_token unless arm_token.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'apps/{appId}/azureaccounts'

  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},
      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: 'AzureAccountInfoObjectElementType',
                type: {
                  name: 'Composite',
                  class_name: 'AzureAccountInfoObject'
                }
            }
          }
        }
        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_assigned_with_http_info(app_id, arm_token:nil, custom_headers:nil) click to toggle source

apps - Get LUIS Azure accounts assigned to the application

Gets the LUIS Azure accounts assigned to the application for the user using his ARM token.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 172
def get_assigned_with_http_info(app_id, arm_token:nil, custom_headers:nil)
  get_assigned_async(app_id, arm_token:arm_token, custom_headers:custom_headers).value!
end
list_user_luisaccounts(arm_token:nil, custom_headers:nil) click to toggle source

user - Get LUIS Azure accounts

Gets the LUIS Azure accounts for the user using his ARM token.

@param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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/3.0-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 387
def list_user_luisaccounts(arm_token:nil, custom_headers:nil)
  response = list_user_luisaccounts_async(arm_token:arm_token, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_user_luisaccounts_async(arm_token:nil, custom_headers:nil) click to toggle source

user - Get LUIS Azure accounts

Gets the LUIS Azure accounts for the user using his ARM token.

@param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 420
def list_user_luisaccounts_async(arm_token:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.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['ArmToken'] = arm_token unless arm_token.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'azureaccounts'

  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]],
      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: 'AzureAccountInfoObjectElementType',
                type: {
                  name: 'Composite',
                  class_name: 'AzureAccountInfoObject'
                }
            }
          }
        }
        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_user_luisaccounts_with_http_info(arm_token:nil, custom_headers:nil) click to toggle source

user - Get LUIS Azure accounts

Gets the LUIS Azure accounts for the user using his ARM token.

@param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 404
def list_user_luisaccounts_with_http_info(arm_token:nil, custom_headers:nil)
  list_user_luisaccounts_async(arm_token:arm_token, custom_headers:custom_headers).value!
end
remove_from_app(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Removes an assigned LUIS Azure account from an application

Removes assigned Azure account from the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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/3.0-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 275
def remove_from_app(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  response = remove_from_app_async(app_id, arm_token:arm_token, azure_account_info_object:azure_account_info_object, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
remove_from_app_async(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Removes an assigned LUIS Azure account from an application

Removes assigned Azure account from the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 314
def remove_from_app_async(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'app_id is nil' if app_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['ArmToken'] = arm_token unless arm_token.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

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

  path_template = 'apps/{appId}/azureaccounts'

  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},
      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::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
remove_from_app_with_http_info(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil) click to toggle source

apps - Removes an assigned LUIS Azure account from an application

Removes assigned Azure account from the application.

@param app_id The application ID. @param arm_token [String] The custom arm token header to use; containing the user's ARM token used to validate azure accounts information. @param azure_account_info_object [AzureAccountInfoObject] The Azure account information object. @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-preview/generated/azure_cognitiveservices_luisauthoring/azure_accounts.rb, line 295
def remove_from_app_with_http_info(app_id, arm_token:nil, azure_account_info_object:nil, custom_headers:nil)
  remove_from_app_async(app_id, arm_token:arm_token, azure_account_info_object:azure_account_info_object, custom_headers:custom_headers).value!
end