Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[AutoPR eventhub/resource-manager] EventHub: Added NetwrokruleSet API #2311

Merged
merged 3 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,28 @@ module Azure::EventHub::Mgmt::V2017_04_01
autoload :EventHubManagementClient, '2017-04-01/generated/azure_mgmt_event_hub/event_hub_management_client.rb'

module Models
autoload :MessagingRegionsProperties, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_regions_properties.rb'
autoload :CaptureDescription, '2017-04-01/generated/azure_mgmt_event_hub/models/capture_description.rb'
autoload :Resource, '2017-04-01/generated/azure_mgmt_event_hub/models/resource.rb'
autoload :ErrorResponse, '2017-04-01/generated/azure_mgmt_event_hub/models/error_response.rb'
autoload :ArmDisasterRecoveryListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/arm_disaster_recovery_list_result.rb'
autoload :EventHubListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/event_hub_list_result.rb'
autoload :MessagingRegionsListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_regions_list_result.rb'
autoload :AccessKeys, '2017-04-01/generated/azure_mgmt_event_hub/models/access_keys.rb'
autoload :ConsumerGroupListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/consumer_group_list_result.rb'
autoload :Destination, '2017-04-01/generated/azure_mgmt_event_hub/models/destination.rb'
autoload :CheckNameAvailabilityParameter, '2017-04-01/generated/azure_mgmt_event_hub/models/check_name_availability_parameter.rb'
autoload :EHNamespaceListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/ehnamespace_list_result.rb'
autoload :CheckNameAvailabilityResult, '2017-04-01/generated/azure_mgmt_event_hub/models/check_name_availability_result.rb'
autoload :RegenerateAccessKeyParameters, '2017-04-01/generated/azure_mgmt_event_hub/models/regenerate_access_key_parameters.rb'
autoload :Resource, '2017-04-01/generated/azure_mgmt_event_hub/models/resource.rb'
autoload :OperationDisplay, '2017-04-01/generated/azure_mgmt_event_hub/models/operation_display.rb'
autoload :NWRuleSetIpRules, '2017-04-01/generated/azure_mgmt_event_hub/models/nwrule_set_ip_rules.rb'
autoload :ConsumerGroupListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/consumer_group_list_result.rb'
autoload :AuthorizationRuleListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/authorization_rule_list_result.rb'
autoload :Operation, '2017-04-01/generated/azure_mgmt_event_hub/models/operation.rb'
autoload :MessagingRegionsProperties, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_regions_properties.rb'
autoload :RegenerateAccessKeyParameters, '2017-04-01/generated/azure_mgmt_event_hub/models/regenerate_access_key_parameters.rb'
autoload :Sku, '2017-04-01/generated/azure_mgmt_event_hub/models/sku.rb'
autoload :CaptureDescription, '2017-04-01/generated/azure_mgmt_event_hub/models/capture_description.rb'
autoload :Subnet, '2017-04-01/generated/azure_mgmt_event_hub/models/subnet.rb'
autoload :EventHubListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/event_hub_list_result.rb'
autoload :Operation, '2017-04-01/generated/azure_mgmt_event_hub/models/operation.rb'
autoload :AccessKeys, '2017-04-01/generated/azure_mgmt_event_hub/models/access_keys.rb'
autoload :OperationListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/operation_list_result.rb'
autoload :NWRuleSetVirtualNetworkRules, '2017-04-01/generated/azure_mgmt_event_hub/models/nwrule_set_virtual_network_rules.rb'
autoload :ErrorResponse, '2017-04-01/generated/azure_mgmt_event_hub/models/error_response.rb'
autoload :Destination, '2017-04-01/generated/azure_mgmt_event_hub/models/destination.rb'
autoload :MessagingRegionsListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_regions_list_result.rb'
autoload :EHNamespaceListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/ehnamespace_list_result.rb'
autoload :ArmDisasterRecoveryListResult, '2017-04-01/generated/azure_mgmt_event_hub/models/arm_disaster_recovery_list_result.rb'
autoload :TrackedResource, '2017-04-01/generated/azure_mgmt_event_hub/models/tracked_resource.rb'
autoload :EHNamespace, '2017-04-01/generated/azure_mgmt_event_hub/models/ehnamespace.rb'
autoload :AuthorizationRule, '2017-04-01/generated/azure_mgmt_event_hub/models/authorization_rule.rb'
Expand All @@ -56,6 +59,7 @@ module Models
autoload :ArmDisasterRecovery, '2017-04-01/generated/azure_mgmt_event_hub/models/arm_disaster_recovery.rb'
autoload :MessagingRegions, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_regions.rb'
autoload :MessagingPlan, '2017-04-01/generated/azure_mgmt_event_hub/models/messaging_plan.rb'
autoload :NetworkRuleSet, '2017-04-01/generated/azure_mgmt_event_hub/models/network_rule_set.rb'
autoload :SkuName, '2017-04-01/generated/azure_mgmt_event_hub/models/sku_name.rb'
autoload :SkuTier, '2017-04-01/generated/azure_mgmt_event_hub/models/sku_tier.rb'
autoload :AccessRights, '2017-04-01/generated/azure_mgmt_event_hub/models/access_rights.rb'
Expand All @@ -65,5 +69,7 @@ module Models
autoload :UnavailableReason, '2017-04-01/generated/azure_mgmt_event_hub/models/unavailable_reason.rb'
autoload :ProvisioningStateDR, '2017-04-01/generated/azure_mgmt_event_hub/models/provisioning_state_dr.rb'
autoload :RoleDisasterRecovery, '2017-04-01/generated/azure_mgmt_event_hub/models/role_disaster_recovery.rb'
autoload :NetworkRuleIPAction, '2017-04-01/generated/azure_mgmt_event_hub/models/network_rule_ipaction.rb'
autoload :DefaultAction, '2017-04-01/generated/azure_mgmt_event_hub/models/default_action.rb'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Azure::EventHub::Mgmt::V2017_04_01
module Models
#
# Description of topic resource.
# Description of NetworkRuleSet resource.
#
class NetworkRuleSet < Resource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Azure::EventHub::Mgmt::V2017_04_01
module Models
#
# The response from the List namespace operation.
# Description of NetWorkRuleSet - IpRules resource.
#
class NWRuleSetIpRules

Expand All @@ -16,7 +16,7 @@ class NWRuleSetIpRules
attr_accessor :ip_mask

# @return [NetworkRuleIPAction] The IP Filter Action. Possible values
# include: 'Allow'
# include: 'Allow'. Default value: 'Allow' .
attr_accessor :action


Expand All @@ -42,6 +42,7 @@ def self.mapper()
action: {
required: false,
serialized_name: 'action',
default_value: 'Allow',
type: {
name: 'String'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Azure::EventHub::Mgmt::V2017_04_01
module Models
#
# The response from the List namespace operation.
# Description of VirtualNetworkRules - NetworkRules resource.
#
class NWRuleSetVirtualNetworkRules

Expand All @@ -15,7 +15,7 @@ class NWRuleSetVirtualNetworkRules
# @return [Subnet] Subnet properties
attr_accessor :subnet

# @return [Boolean] Value that indicates whether to ignore missing Vnet
# @return [Boolean] Value that indicates whether to ignore missing VNet
# Service Endpoint
attr_accessor :ignore_missing_vnet_service_endpoint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.mapper()
class_name: 'Subnet',
model_properties: {
id: {
required: false,
required: true,
serialized_name: 'id',
type: {
name: 'String'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,207 @@ def regenerate_keys_async(resource_group_name, namespace_name, authorization_rul
promise.execute
end

#
# Create or update NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @param parameters [NetworkRuleSet] The Namespace IpFilterRule.
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [NetworkRuleSet] operation results.
#
def create_or_update_network_rule_set(resource_group_name, namespace_name, parameters, custom_headers = nil)
response = create_or_update_network_rule_set_async(resource_group_name, namespace_name, parameters, custom_headers).value!
response.body unless response.nil?
end

#
# Create or update NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @param parameters [NetworkRuleSet] The Namespace IpFilterRule.
# @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.
#
def create_or_update_network_rule_set_with_http_info(resource_group_name, namespace_name, parameters, custom_headers = nil)
create_or_update_network_rule_set_async(resource_group_name, namespace_name, parameters, custom_headers).value!
end

#
# Create or update NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @param parameters [NetworkRuleSet] The Namespace IpFilterRule.
# @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.
#
def create_or_update_network_rule_set_async(resource_group_name, namespace_name, parameters, custom_headers = nil)
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
fail ArgumentError, 'namespace_name is nil' if namespace_name.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?
fail ArgumentError, 'parameters is nil' if parameters.nil?


request_headers = {}

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

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

# Serialize Request
request_mapper = Azure::EventHub::Mgmt::V2017_04_01::Models::NetworkRuleSet.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.EventHub/namespaces/{namespaceName}/networkRuleSets/default'

request_url = @base_url || @client.base_url

options = {
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_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
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::EventHub::Mgmt::V2017_04_01::Models::NetworkRuleSet.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

#
# Gets NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [NetworkRuleSet] operation results.
#
def get_network_rule_set(resource_group_name, namespace_name, custom_headers = nil)
response = get_network_rule_set_async(resource_group_name, namespace_name, custom_headers).value!
response.body unless response.nil?
end

#
# Gets NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @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.
#
def get_network_rule_set_with_http_info(resource_group_name, namespace_name, custom_headers = nil)
get_network_rule_set_async(resource_group_name, namespace_name, custom_headers).value!
end

#
# Gets NetworkRuleSet for a Namespace.
#
# @param resource_group_name [String] Name of the resource group within the
# azure subscription.
# @param namespace_name [String] The Namespace name
# @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.
#
def get_network_rule_set_async(resource_group_name, namespace_name, custom_headers = nil)
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
fail ArgumentError, 'namespace_name is nil' if namespace_name.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 = {}

# 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.EventHub/namespaces/{namespaceName}/networkRuleSets/default'

request_url = @base_url || @client.base_url

options = {
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'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::EventHub::Mgmt::V2017_04_01::Models::NetworkRuleSet.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

#
# Creates or updates a namespace. Once created, this namespace's resource
# manifest is immutable. This operation is idempotent.
Expand Down