Skip to content
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace EventHub.Tests.ScenarioTests
using Xunit;
public partial class ScenarioTests
{
[Fact(Skip = "ReRecord due to CR change")]
[Fact]
public void ConsumerGroupsCreateGetUpdateDelete()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace EventHub.Tests.ScenarioTests
using Xunit;
public partial class ScenarioTests
{
[Fact(Skip = "ReRecord due to CR change")]
[Fact]
public void EventCreateGetUpdateDelete()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace EventHub.Tests.ScenarioTests
using Xunit;
public partial class ScenarioTests
{
[Fact(Skip = "ReRecord due to CR change")]
[Fact()]
public void EventhubCreateGetUpdateDeleteAuthorizationRules_Length()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.


namespace EventHub.Tests.ScenarioTests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.Azure.Management.EventHub;
using Microsoft.Azure.Management.EventHub.Models;
using Microsoft.Rest.Azure;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using TestHelper;
using Xunit;
public partial class ScenarioTests
{
[Fact]
public void EventHubskiptop()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
InitializeClients(context);

var location = this.ResourceManagementClient.GetLocationFromProvider();

var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
if (string.IsNullOrWhiteSpace(resourceGroup))
{
resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
}

var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);

var createNamespaceResponse = this.EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
new EHNamespace()
{
Location = location,
Sku = new Sku
{
Name = SkuName.Standard,
Tier = SkuTier.Standard
},
Tags = new Dictionary<string, string>()
{
{"tag1", "value1"},
{"tag2", "value2"}
}
});

Assert.NotNull(createNamespaceResponse);
Assert.Equal(createNamespaceResponse.Name, namespaceName);
TestUtilities.Wait(TimeSpan.FromSeconds(5));

// Create a EventHub
var eventhubName = TestUtilities.GenerateName(EventHubManagementHelper.EventHubPrefix);

for (int ehCount = 0; ehCount < 10; ehCount++)
{
var eventhubNameLoop = eventhubName + "_" + ehCount.ToString();
var createEventHubResponseForLoop = this.EventHubManagementClient.EventHubs.CreateOrUpdate(resourceGroup, namespaceName, eventhubNameLoop, new Eventhub());

Assert.NotNull(createEventHubResponseForLoop);
Assert.Equal(createEventHubResponseForLoop.Name, eventhubNameLoop);
}

var createEventHubResponseList = this.EventHubManagementClient.EventHubs.ListByNamespace(resourceGroup, namespaceName);

Assert.Equal(10, createEventHubResponseList.Count<Eventhub>());

var gettop10EventHub = this.EventHubManagementClient.EventHubs.ListByNamespace(resourceGroup, namespaceName, skip: 5, top: 5);

Assert.Equal(5, gettop10EventHub.Count<Eventhub>());

// Create a ConsumerGroup
var consumergroupName = TestUtilities.GenerateName(EventHubManagementHelper.ConsumerGroupPrefix);

for (int consumergroupCount = 0; consumergroupCount < 10; consumergroupCount++)
{
var consumergroupNameLoop = consumergroupName + "_" + consumergroupCount.ToString();
var createConsumerGroupResponseForLoop = this.EventHubManagementClient.ConsumerGroups.CreateOrUpdate(resourceGroup, namespaceName, createEventHubResponseList.ElementAt<Eventhub>(0).Name, consumergroupNameLoop, new ConsumerGroup());

Assert.NotNull(createConsumerGroupResponseForLoop);
Assert.Equal(createConsumerGroupResponseForLoop.Name, consumergroupNameLoop);
}

var createConsumerGroupResponseList = this.EventHubManagementClient.ConsumerGroups.ListByEventHub(resourceGroup, namespaceName, createEventHubResponseList.ElementAt<Eventhub>(0).Name);

Assert.Equal(11, createConsumerGroupResponseList.Count<ConsumerGroup>());

var gettop10ConsumerGroup = this.EventHubManagementClient.ConsumerGroups.ListByEventHub(resourceGroup, namespaceName, createEventHubResponseList.ElementAt<Eventhub>(0).Name, skip: 5, top: 4);

Assert.Equal(4, gettop10ConsumerGroup.Count<ConsumerGroup>());


TestUtilities.Wait(TimeSpan.FromSeconds(5));

// Delete namespace and check for the NotFound exception
EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace EventHub.Tests.ScenarioTests
using Xunit;
public partial class ScenarioTests
{
[Fact(Skip = "ReRecord due to CR change")]
[Fact]
public void NamespaceCreateGetUpdateDelete()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace EventHub.Tests.ScenarioTests
using Xunit;
public partial class ScenarioTests
{
[Fact(Skip = "ReRecord due to CR change")]
[Fact]
public void NamespaceCreateGetUpdateDeleteAuthorizationRules()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,16 @@ internal ConsumerGroupsOperations(EventHubManagementClient client)
/// <param name='eventHubName'>
/// The Event Hub name
/// </param>
/// <param name='skip'>
/// Skip is only used if a previous operation returned a partial result. If a
/// previous response contains a nextLink element, the value of the nextLink
/// element will include a skip parameter that specifies a starting point to
/// use for subsequent calls.
/// </param>
/// <param name='top'>
/// May be used to limit the number of results to the most recent N
/// usageDetails.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -825,7 +835,7 @@ internal ConsumerGroupsOperations(EventHubManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IPage<ConsumerGroup>>> ListByEventHubWithHttpMessagesAsync(string resourceGroupName, string namespaceName, string eventHubName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<IPage<ConsumerGroup>>> ListByEventHubWithHttpMessagesAsync(string resourceGroupName, string namespaceName, string eventHubName, int? skip = default(int?), int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (resourceGroupName == null)
{
Expand Down Expand Up @@ -876,6 +886,22 @@ internal ConsumerGroupsOperations(EventHubManagementClient client)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
}
if (skip > 1000)
{
throw new ValidationException(ValidationRules.InclusiveMaximum, "skip", 1000);
}
if (skip < 0)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
}
if (top > 1000)
{
throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000);
}
if (top < 1)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1);
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
Expand All @@ -886,6 +912,8 @@ internal ConsumerGroupsOperations(EventHubManagementClient client)
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("namespaceName", namespaceName);
tracingParameters.Add("eventHubName", eventHubName);
tracingParameters.Add("skip", skip);
tracingParameters.Add("top", top);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "ListByEventHub", tracingParameters);
}
Expand All @@ -901,6 +929,14 @@ internal ConsumerGroupsOperations(EventHubManagementClient client)
{
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
}
if (skip != null)
{
_queryParameters.Add(string.Format("$skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(skip, Client.SerializationSettings).Trim('"'))));
}
if (top != null)
{
_queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
}
if (_queryParameters.Count > 0)
{
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,19 @@ public static ConsumerGroup Get(this IConsumerGroupsOperations operations, strin
/// <param name='eventHubName'>
/// The Event Hub name
/// </param>
public static IPage<ConsumerGroup> ListByEventHub(this IConsumerGroupsOperations operations, string resourceGroupName, string namespaceName, string eventHubName)
/// <param name='skip'>
/// Skip is only used if a previous operation returned a partial result. If a
/// previous response contains a nextLink element, the value of the nextLink
/// element will include a skip parameter that specifies a starting point to
/// use for subsequent calls.
/// </param>
/// <param name='top'>
/// May be used to limit the number of results to the most recent N
/// usageDetails.
/// </param>
public static IPage<ConsumerGroup> ListByEventHub(this IConsumerGroupsOperations operations, string resourceGroupName, string namespaceName, string eventHubName, int? skip = default(int?), int? top = default(int?))
{
return operations.ListByEventHubAsync(resourceGroupName, namespaceName, eventHubName).GetAwaiter().GetResult();
return operations.ListByEventHubAsync(resourceGroupName, namespaceName, eventHubName, skip, top).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -219,12 +229,22 @@ public static IPage<ConsumerGroup> ListByEventHub(this IConsumerGroupsOperations
/// <param name='eventHubName'>
/// The Event Hub name
/// </param>
/// <param name='skip'>
/// Skip is only used if a previous operation returned a partial result. If a
/// previous response contains a nextLink element, the value of the nextLink
/// element will include a skip parameter that specifies a starting point to
/// use for subsequent calls.
/// </param>
/// <param name='top'>
/// May be used to limit the number of results to the most recent N
/// usageDetails.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IPage<ConsumerGroup>> ListByEventHubAsync(this IConsumerGroupsOperations operations, string resourceGroupName, string namespaceName, string eventHubName, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IPage<ConsumerGroup>> ListByEventHubAsync(this IConsumerGroupsOperations operations, string resourceGroupName, string namespaceName, string eventHubName, int? skip = default(int?), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ListByEventHubWithHttpMessagesAsync(resourceGroupName, namespaceName, eventHubName, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.ListByEventHubWithHttpMessagesAsync(resourceGroupName, namespaceName, eventHubName, skip, top, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public partial class EventHubManagementClient : ServiceClient<EventHubManagement
/// </summary>
public virtual IConsumerGroupsOperations ConsumerGroups { get; private set; }

/// <summary>
/// Gets the IRegionsOperations.
/// </summary>
public virtual IRegionsOperations Regions { get; private set; }

/// <summary>
/// Initializes a new instance of the EventHubManagementClient class.
/// </summary>
Expand Down Expand Up @@ -306,6 +311,7 @@ private void Initialize()
DisasterRecoveryConfigs = new DisasterRecoveryConfigsOperations(this);
EventHubs = new EventHubsOperations(this);
ConsumerGroups = new ConsumerGroupsOperations(this);
Regions = new RegionsOperations(this);
BaseUri = new System.Uri("https://management.azure.com");
ApiVersion = "2017-04-01";
AcceptLanguage = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ internal EventHubsOperations(EventHubManagementClient client)
/// <param name='namespaceName'>
/// The Namespace name
/// </param>
/// <param name='skip'>
/// Skip is only used if a previous operation returned a partial result. If a
/// previous response contains a nextLink element, the value of the nextLink
/// element will include a skip parameter that specifies a starting point to
/// use for subsequent calls.
/// </param>
/// <param name='top'>
/// May be used to limit the number of results to the most recent N
/// usageDetails.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -80,7 +90,7 @@ internal EventHubsOperations(EventHubManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IPage<Eventhub>>> ListByNamespaceWithHttpMessagesAsync(string resourceGroupName, string namespaceName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<IPage<Eventhub>>> ListByNamespaceWithHttpMessagesAsync(string resourceGroupName, string namespaceName, int? skip = default(int?), int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (resourceGroupName == null)
{
Expand Down Expand Up @@ -120,6 +130,22 @@ internal EventHubsOperations(EventHubManagementClient client)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
}
if (skip > 1000)
{
throw new ValidationException(ValidationRules.InclusiveMaximum, "skip", 1000);
}
if (skip < 0)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
}
if (top > 1000)
{
throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000);
}
if (top < 1)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1);
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
Expand All @@ -129,6 +155,8 @@ internal EventHubsOperations(EventHubManagementClient client)
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("namespaceName", namespaceName);
tracingParameters.Add("skip", skip);
tracingParameters.Add("top", top);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "ListByNamespace", tracingParameters);
}
Expand All @@ -143,6 +171,14 @@ internal EventHubsOperations(EventHubManagementClient client)
{
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
}
if (skip != null)
{
_queryParameters.Add(string.Format("$skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(skip, Client.SerializationSettings).Trim('"'))));
}
if (top != null)
{
_queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
}
if (_queryParameters.Count > 0)
{
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
Expand Down
Loading