Class: Azure::Network::Mgmt::V2020_08_01::InboundSecurityRuleOperations

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb

Overview

InboundSecurityRuleOperations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ InboundSecurityRuleOperations

Creates and initializes a new instance of the InboundSecurityRuleOperations class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientNetworkManagementClient (readonly)

Returns reference to the NetworkManagementClient.

Returns:



22
23
24
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 22

def client
  @client
end

Instance Method Details

#begin_create_or_update(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers: nil) ⇒ InboundSecurityRule

Creates or updates the specified Network Virtual Appliance Inbound Security Rules.

Virtual Appliance. update Network Virtual Appliance Inbound Security Rules operation. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • network_virtual_appliance_name (String)

    The name of the Network

  • rule_collection_name (String)

    The name of security rule collection.

  • parameters (InboundSecurityRule)

    Parameters supplied to the create or

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (InboundSecurityRule)

    operation results.



90
91
92
93
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 90

def begin_create_or_update(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:nil)
  response = begin_create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#begin_create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers: nil) ⇒ Concurrent::Promise

Creates or updates the specified Network Virtual Appliance Inbound Security Rules.

Virtual Appliance. update Network Virtual Appliance Inbound Security Rules operation. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • network_virtual_appliance_name (String)

    The name of the Network

  • rule_collection_name (String)

    The name of security rule collection.

  • parameters (InboundSecurityRule)

    Parameters supplied to the create or

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 129

def begin_create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'network_virtual_appliance_name is nil' if network_virtual_appliance_name.nil?
  fail ArgumentError, 'rule_collection_name is nil' if rule_collection_name.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::Network::Mgmt::V2020_08_01::Models::InboundSecurityRule.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/inboundSecurityRules/{ruleCollectionName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'networkVirtualApplianceName' => network_virtual_appliance_name,'ruleCollectionName' => rule_collection_name,'subscriptionId' => @client.subscription_id},
      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 MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Network::Mgmt::V2020_08_01::Models::InboundSecurityRule.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::Network::Mgmt::V2020_08_01::Models::InboundSecurityRule.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_or_update_with_http_info(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Creates or updates the specified Network Virtual Appliance Inbound Security Rules.

Virtual Appliance. update Network Virtual Appliance Inbound Security Rules operation. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • network_virtual_appliance_name (String)

    The name of the Network

  • rule_collection_name (String)

    The name of security rule collection.

  • parameters (InboundSecurityRule)

    Parameters supplied to the create or

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



110
111
112
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 110

def begin_create_or_update_with_http_info(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:nil)
  begin_create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:custom_headers).value!
end

#create_or_update(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers: nil) ⇒ InboundSecurityRule

Creates or updates the specified Network Virtual Appliance Inbound Security Rules.

Virtual Appliance. update Network Virtual Appliance Inbound Security Rules operation. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • network_virtual_appliance_name (String)

    The name of the Network

  • rule_collection_name (String)

    The name of security rule collection.

  • parameters (InboundSecurityRule)

    Parameters supplied to the create or

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (InboundSecurityRule)

    operation results.



39
40
41
42
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 39

def create_or_update(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:nil)
  response = create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers: nil) ⇒ Concurrent::Promise

Virtual Appliance. update Network Virtual Appliance Inbound Security Rules operation. will be added to the HTTP request.

response.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • network_virtual_appliance_name (String)

    The name of the Network

  • rule_collection_name (String)

    The name of security rule collection.

  • parameters (InboundSecurityRule)

    Parameters supplied to the create or

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/2020-08-01/generated/azure_mgmt_network/inbound_security_rule_operations.rb', line 57

def create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:nil)
  # Send request
  promise = begin_create_or_update_async(resource_group_name, network_virtual_appliance_name, rule_collection_name, parameters, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::Network::Mgmt::V2020_08_01::Models::InboundSecurityRule.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