class Azure::ServerManagement::Mgmt::V2016_07_01_preview::Gateway

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 Gateway class. @param client service class for accessing basic functionality.

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

Private Instance Methods

begin_create(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Creates or updates a ManagementService gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 655
def begin_create(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  response = begin_create_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_create_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Creates or updates a ManagementService gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 698
def begin_create_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode: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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?

  gateway_parameters = GatewayParameters.new
  unless location.nil? && tags.nil? && upgrade_mode.nil?
    gateway_parameters.location = location
    gateway_parameters.tags = tags
    gateway_parameters.upgrade_mode = upgrade_mode
  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::GatewayParameters.mapper()
  request_content = @client.serialize(request_mapper,  gateway_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}'

  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,'gatewayName' => gateway_name},
      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(: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 == 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?
    # 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::GatewayResource.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
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::GatewayResource.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_with_http_info(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Creates or updates a ManagementService gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 677
def begin_create_with_http_info(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  begin_create_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
end
begin_get_profile(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Gets a gateway profile.

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

@return [GatewayProfile] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1099
def begin_get_profile(resource_group_name, gateway_name, custom_headers:nil)
  response = begin_get_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_get_profile_async(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Gets a gateway profile.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 1130
def begin_get_profile_async(resource_group_name, gateway_name, 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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).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/gateways/{gatewayName}/profile'

  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,'gatewayName' => gateway_name},
      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::GatewayProfile.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_get_profile_with_http_info(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Gets a gateway profile.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 1115
def begin_get_profile_with_http_info(resource_group_name, gateway_name, custom_headers:nil)
  begin_get_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
end
begin_regenerate_profile(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Regenerate a gateway's profile

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1009
def begin_regenerate_profile(resource_group_name, gateway_name, custom_headers:nil)
  response = begin_regenerate_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  nil
end
begin_regenerate_profile_async(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Regenerate a gateway's profile

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 1040
def begin_regenerate_profile_async(resource_group_name, gateway_name, 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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).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/gateways/{gatewayName}/regenerateprofile'

  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,'gatewayName' => gateway_name},
      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?

    result
  end

  promise.execute
end
begin_regenerate_profile_with_http_info(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Regenerate a gateway's profile

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 1025
def begin_regenerate_profile_with_http_info(resource_group_name, gateway_name, custom_headers:nil)
  begin_regenerate_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
end
begin_update(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Updates a gateway belonging to a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 796
def begin_update(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  response = begin_update_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_update_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Updates a gateway belonging to a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 839
def begin_update_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode: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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).nil?

  gateway_parameters = GatewayParameters.new
  unless location.nil? && tags.nil? && upgrade_mode.nil?
    gateway_parameters.location = location
    gateway_parameters.tags = tags
    gateway_parameters.upgrade_mode = upgrade_mode
  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::GatewayParameters.mapper()
  request_content = @client.serialize(request_mapper,  gateway_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/gateways/{gatewayName}'

  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,'gatewayName' => gateway_name},
      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(: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::GatewayResource.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_with_http_info(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Updates a gateway belonging to a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 818
def begin_update_with_http_info(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  begin_update_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
end
begin_upgrade(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Upgrades a gateway.

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 920
def begin_upgrade(resource_group_name, gateway_name, custom_headers:nil)
  response = begin_upgrade_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  nil
end
begin_upgrade_async(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Upgrades a gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 951
def begin_upgrade_async(resource_group_name, gateway_name, 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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).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/gateways/{gatewayName}/upgradetolatest'

  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,'gatewayName' => gateway_name},
      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?

    result
  end

  promise.execute
end
begin_upgrade_with_http_info(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Upgrades a gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 936
def begin_upgrade_with_http_info(resource_group_name, gateway_name, custom_headers:nil)
  begin_upgrade_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
end
create(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Creates or updates a ManagementService gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 41
def create(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  response = create_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode: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 gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 62
def create_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  # Send request
  promise = begin_create_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, 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::GatewayResource.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
delete(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Deletes a gateway from a resource group.

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 146
def delete(resource_group_name, gateway_name, custom_headers:nil)
  response = delete_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  nil
end
delete_async(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Deletes a gateway from a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 177
def delete_async(resource_group_name, gateway_name, 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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).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/gateways/{gatewayName}'

  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,'gatewayName' => gateway_name},
      query_params: {'api-version' => @client.api_version},
      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 || status_code == 204
      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
  end

  promise.execute
end
delete_with_http_info(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Deletes a gateway from a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 162
def delete_with_http_info(resource_group_name, gateway_name, custom_headers:nil)
  delete_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
end
get(resource_group_name, gateway_name, expand:nil, custom_headers:nil) click to toggle source

Gets a gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum) @param expand [GatewayExpandOption] Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Possible values include: 'status', 'download' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 240
def get(resource_group_name, gateway_name, expand:nil, custom_headers:nil)
  response = get_async(resource_group_name, gateway_name, expand:expand, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_async(resource_group_name, gateway_name, expand:nil, custom_headers:nil) click to toggle source

Gets a gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum) @param expand [GatewayExpandOption] Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Possible values include: 'status', 'download' @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/gateway.rb, line 279
def get_async(resource_group_name, gateway_name, 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, 'gateway_name is nil' if gateway_name.nil?
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MaxLength': '256'" if !gateway_name.nil? && gateway_name.length > 256
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'MinLength': '1'" if !gateway_name.nil? && gateway_name.length < 1
  fail ArgumentError, "'gateway_name' should satisfy the constraint - 'Pattern': '^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'" if !gateway_name.nil? && gateway_name.match(Regexp.new('^^[a-zA-Z0-9][a-zA-Z0-9_.-]*$$')).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/gateways/{gatewayName}'

  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,'gatewayName' => gateway_name},
      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::GatewayResource.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_profile(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Gets a gateway profile.

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

@return [GatewayProfile] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 605
def get_profile(resource_group_name, gateway_name, custom_headers:nil)
  response = get_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_profile_async(resource_group_name, gateway_name, 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 gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 620
def get_profile_async(resource_group_name, gateway_name, custom_headers:nil)
  # Send request
  promise = begin_get_profile_async(resource_group_name, gateway_name, 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::GatewayProfile.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_with_http_info(resource_group_name, gateway_name, expand:nil, custom_headers:nil) click to toggle source

Gets a gateway.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum) @param expand [GatewayExpandOption] Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Possible values include: 'status', 'download' @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/gateway.rb, line 260
def get_with_http_info(resource_group_name, gateway_name, expand:nil, custom_headers:nil)
  get_async(resource_group_name, gateway_name, expand:expand, custom_headers:custom_headers).value!
end
list(custom_headers:nil) click to toggle source

Returns gateways in a subscription.

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

@return [Array<GatewayResource>] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 345
def list(custom_headers:nil)
  first_page = list_as_lazy(custom_headers:custom_headers)
  first_page.get_all_items
end
list_as_lazy(custom_headers:nil) click to toggle source

Returns gateways in a subscription.

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

@return [GatewayResources] which provide lazy access to pages of the response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1373
def list_as_lazy(custom_headers:nil)
  response = list_async(custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end
list_async(custom_headers:nil) click to toggle source

Returns gateways in a subscription.

@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/gateway.rb, line 370
def list_async(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?


  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}/providers/Microsoft.ServerManagement/gateways'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id},
      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::GatewayResources.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_for_resource_group(resource_group_name, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array<GatewayResource>] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 431
def list_for_resource_group(resource_group_name, custom_headers:nil)
  first_page = list_for_resource_group_as_lazy(resource_group_name, custom_headers:custom_headers)
  first_page.get_all_items
end
list_for_resource_group_as_lazy(resource_group_name, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResources] which provide lazy access to pages of the response.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1395
def list_for_resource_group_as_lazy(resource_group_name, custom_headers:nil)
  response = list_for_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end
list_for_resource_group_async(resource_group_name, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @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/gateway.rb, line 460
def list_for_resource_group_async(resource_group_name, 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?


  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/gateways'

  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},
      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::GatewayResources.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_for_resource_group_next(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResources] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1286
def list_for_resource_group_next(next_page_link, custom_headers:nil)
  response = list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_for_resource_group_next_async(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @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/gateway.rb, line 1315
def list_for_resource_group_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.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 = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      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::GatewayResources.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_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @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/gateway.rb, line 1301
def list_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
  list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
end
list_for_resource_group_with_http_info(resource_group_name, custom_headers:nil) click to toggle source

Returns gateways in a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @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/gateway.rb, line 446
def list_for_resource_group_with_http_info(resource_group_name, custom_headers:nil)
  list_for_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
end
list_next(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResources] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 1198
def list_next(next_page_link, custom_headers:nil)
  response = list_next_async(next_page_link, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_next_async(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @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/gateway.rb, line 1227
def list_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.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 = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      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::GatewayResources.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_next_with_http_info(next_page_link, custom_headers:nil) click to toggle source

Returns gateways in a subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @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/gateway.rb, line 1213
def list_next_with_http_info(next_page_link, custom_headers:nil)
  list_next_async(next_page_link, custom_headers:custom_headers).value!
end
list_with_http_info(custom_headers:nil) click to toggle source

Returns gateways in a subscription.

@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/gateway.rb, line 358
def list_with_http_info(custom_headers:nil)
  list_async(custom_headers:custom_headers).value!
end
regenerate_profile(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Regenerate a gateway's profile

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 563
def regenerate_profile(resource_group_name, gateway_name, custom_headers:nil)
  response = regenerate_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  nil
end
regenerate_profile_async(resource_group_name, gateway_name, 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 gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 578
def regenerate_profile_async(resource_group_name, gateway_name, custom_headers:nil)
  # Send request
  promise = begin_regenerate_profile_async(resource_group_name, gateway_name, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

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

  promise
end
update(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil) click to toggle source

Updates a gateway belonging to a resource group.

@param resource_group_name [String] The resource group name uniquely identifies the resource group within the user subscriptionId. @param gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [GatewayResource] operation results.

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 97
def update(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  response = update_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
update_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode: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 gateway_name [String] The gateway name (256 characters maximum). @param location [String] Location of the resource. @param tags Resource tags. @param upgrade_mode [UpgradeMode] The upgradeMode property gives the flexibility to gateway to auto upgrade itself. If properties value not specified, then we assume upgradeMode = Automatic. Possible values include: 'Manual', 'Automatic' @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/gateway.rb, line 118
def update_async(resource_group_name, gateway_name, location:nil, tags:nil, upgrade_mode:nil, custom_headers:nil)
  # Send request
  promise = begin_update_async(resource_group_name, gateway_name, location:location, tags:tags, upgrade_mode:upgrade_mode, 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::GatewayResource.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
upgrade(resource_group_name, gateway_name, custom_headers:nil) click to toggle source

Upgrades a gateway.

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

# File lib/2016-07-01-preview/generated/azure_mgmt_server_management/gateway.rb, line 523
def upgrade(resource_group_name, gateway_name, custom_headers:nil)
  response = upgrade_async(resource_group_name, gateway_name, custom_headers:custom_headers).value!
  nil
end
upgrade_async(resource_group_name, gateway_name, 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 gateway_name [String] The gateway name (256 characters maximum). @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/gateway.rb, line 538
def upgrade_async(resource_group_name, gateway_name, custom_headers:nil)
  # Send request
  promise = begin_upgrade_async(resource_group_name, gateway_name, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

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

  promise
end