class Azure::ServerManagement::Mgmt::V2016_07_01_preview::PowerShell

REST API for Azure Server Management Service.

Attributes

client[R]

@return [ServerManagement] reference to the ServerManagement

Private Class Methods

new(client) click to toggle source

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 17
def initialize(client)
  @client = client
end

Private Instance Methods

begin_cancel_command(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Cancels a PowerShell command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 909
def begin_cancel_command(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = begin_cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Cancels a PowerShell command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 944
def begin_cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/cancel'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version},
      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 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.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
begin_cancel_command_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Cancels a PowerShell command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 927
def begin_cancel_command_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil)
  begin_cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
end
begin_create_session(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Creates a PowerShell session.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellSessionResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 571
def begin_create_session(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = begin_create_session_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_create_session_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Creates a PowerShell session.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 606
def begin_create_session_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version},
      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 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellSessionResource.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
begin_create_session_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Creates a PowerShell session.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 589
def begin_create_session_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil)
  begin_create_session_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
end
begin_invoke_command(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Creates a PowerShell script and invokes it.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Script to execute. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 788
def begin_invoke_command(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  response = begin_invoke_command_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_invoke_command_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Creates a PowerShell script and invokes it.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Script to execute. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 825
def begin_invoke_command_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.nil?

  power_shell_command_parameters = PowerShellCommandParameters.new
  unless command.nil?
    power_shell_command_parameters.command = command
  end

  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::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandParameters.mapper()
  request_content = @client.serialize(request_mapper,  power_shell_command_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/invokeCommand'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version},
      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 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.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
begin_invoke_command_with_http_info(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Creates a PowerShell script and invokes it.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Script to execute. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 807
def begin_invoke_command_with_http_info(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  begin_invoke_command_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers).value!
end
begin_update_command(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Updates a running PowerShell command with more data.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 679
def begin_update_command(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = begin_update_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_update_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Updates a running PowerShell command with more data.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 714
def begin_update_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:patch, 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 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.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
begin_update_command_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Updates a running PowerShell command with more data.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 697
def begin_update_command_with_http_info(resource_group_name, node_name, session, pssession, custom_headers:nil)
  begin_update_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
end
cancel_command(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Cancels a PowerShell command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 401
def cancel_command(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 418
def cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  # Send request
  promise = begin_cancel_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
create_session(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Creates a PowerShell session.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellSessionResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 141
def create_session(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = create_session_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_session_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 158
def create_session_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  # Send request
  promise = begin_create_session_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellSessionResource.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
get_command_status(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil) click to toggle source

Gets the status of a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param expand [PowerShellExpandOption] Gets current output from an ongoing call. Possible values include: 'output' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandStatus] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 191
def get_command_status(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil)
  response = get_command_status_async(resource_group_name, node_name, session, pssession, expand:expand, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_command_status_async(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil) click to toggle source

Gets the status of a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param expand [PowerShellExpandOption] Gets current output from an ongoing call. Possible values include: 'output' @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 230
def get_command_status_async(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version,'$expand' => expand},
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandStatus.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_command_status_with_http_info(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil) click to toggle source

Gets the status of a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param expand [PowerShellExpandOption] Gets current output from an ongoing call. Possible values include: 'output' @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 211
def get_command_status_with_http_info(resource_group_name, node_name, session, pssession, expand:nil, custom_headers:nil)
  get_command_status_async(resource_group_name, node_name, session, pssession, expand:expand, custom_headers:custom_headers).value!
end
invoke_command(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Creates a PowerShell script and invokes it.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Script to execute. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 352
def invoke_command(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  response = invoke_command_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
invoke_command_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Script to execute. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 370
def invoke_command_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  # Send request
  promise = begin_invoke_command_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
list_session(resource_group_name, node_name, session, custom_headers:nil) click to toggle source

Gets a list of the active sessions.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellSessionResources] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 36
def list_session(resource_group_name, node_name, session, custom_headers:nil)
  response = list_session_async(resource_group_name, node_name, session, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_session_async(resource_group_name, node_name, session, custom_headers:nil) click to toggle source

Gets a list of the active sessions.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 69
def list_session_async(resource_group_name, node_name, session, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session},
      query_params: {'api-version' => @client.api_version},
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellSessionResources.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
list_session_with_http_info(resource_group_name, node_name, session, custom_headers:nil) click to toggle source

Gets a list of the active sessions.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 53
def list_session_with_http_info(resource_group_name, node_name, session, custom_headers:nil)
  list_session_async(resource_group_name, node_name, session, custom_headers:custom_headers).value!
end
tab_completion(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Gets tab completion values for a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Command to get tab completion for. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellTabCompletionResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 450
def tab_completion(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  response = tab_completion_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
tab_completion_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Gets tab completion values for a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Command to get tab completion for. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 487
def tab_completion_async(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '3'" if !resource_group_name.nil? && resource_group_name.length < 3
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '[a-zA-Z0-9]+'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^[a-zA-Z0-9]+$')).nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MaxLength': '256'" if !node_name.nil? && node_name.length > 256
  fail ArgumentError, "'node_name' should satisfy the constraint - 'MinLength': '1'" if !node_name.nil? && node_name.length < 1
  fail ArgumentError, "'node_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !node_name.nil? && node_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?
  fail ArgumentError, 'session is nil' if session.nil?
  fail ArgumentError, 'pssession is nil' if pssession.nil?

  power_shell_tab_completion_paramters = PowerShellTabCompletionParameters.new
  unless command.nil?
    power_shell_tab_completion_paramters.command = command
  end

  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::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellTabCompletionParameters.mapper()
  request_content = @client.serialize(request_mapper,  power_shell_tab_completion_paramters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}/features/powerShellConsole/pssessions/{pssession}/tab'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session,'pssession' => pssession},
      query_params: {'api-version' => @client.api_version},
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellTabCompletionResults.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
tab_completion_with_http_info(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil) click to toggle source

Gets tab completion values for a command.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param command [String] Command to get tab completion for. @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/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 469
def tab_completion_with_http_info(resource_group_name, node_name, session, pssession, command:nil, custom_headers:nil)
  tab_completion_async(resource_group_name, node_name, session, pssession, command:command, custom_headers:custom_headers).value!
end
update_command(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

Updates a running PowerShell command with more data.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PowerShellCommandResults] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 303
def update_command(resource_group_name, node_name, session, pssession, custom_headers:nil)
  response = update_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
update_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil) click to toggle source

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param node_name [String] The node name (256 characters maximum). @param session [String] The sessionId from the user. @param pssession [String] The PowerShell sessionId from the user. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/power_shell.rb, line 320
def update_command_async(resource_group_name, node_name, session, pssession, custom_headers:nil)
  # Send request
  promise = begin_update_command_async(resource_group_name, node_name, session, pssession, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::PowerShellCommandResults.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end