Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the management client #12484

Merged
merged 24 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
013de9b
ATOM based management operations
ShivangiReja May 9, 2020
f966e43
Use IsSharedAccessSignatureCredential and remove usingAAD
ShivangiReja May 14, 2020
0f9cc82
Add MessagingEntityAlreadyExists exception.
ShivangiReja May 14, 2020
54dec22
Change path to name
ShivangiReja May 16, 2020
06ea544
Rename ManagementClient to ServiceBusManagementClient
ShivangiReja May 16, 2020
658a414
Change file name
ShivangiReja May 16, 2020
fe9fd2a
Rename types, properties, params etc as per the API review feedback
ShivangiReja May 21, 2020
1da215a
Rename comparand -> other
ShivangiReja May 21, 2020
dcaad02
Rename QueueName to name and TopicName to name
ShivangiReja May 29, 2020
5bec71d
Feedback from the service team
ShivangiReja May 30, 2020
5d5b034
Add pagination for get entities methods
ShivangiReja Jun 2, 2020
c50ae52
Format file
ShivangiReja Jun 2, 2020
124db14
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-net i…
ShivangiReja Jun 2, 2020
c739131
Cleanups
ShivangiReja Jun 2, 2020
8181dac
Add tests
ShivangiReja Jun 3, 2020
ebdfd6e
Fix error message
ShivangiReja Jun 4, 2020
3c78f5c
Uncomment test
ShivangiReja Jun 4, 2020
66bf878
Fix test and PR comments
ShivangiReja Jun 4, 2020
2affe60
Set NonParallelizable Attribute where we call get entities method.
ShivangiReja Jun 4, 2020
c05ed2f
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-net i…
ShivangiReja Jun 4, 2020
833adc4
Fix warnings
ShivangiReja Jun 4, 2020
de65fd9
Move filters to management namespace and few other cleanups
ShivangiReja Jun 5, 2020
b547f49
Remove unused import
ShivangiReja Jun 5, 2020
26d317f
Add known prefix for each get entities test
ShivangiReja Jun 5, 2020
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 @@ -9,12 +9,12 @@
using System.Runtime.Serialization;
using Azure.Core;
using Azure.Messaging.ServiceBus.Amqp.Framing;
using Azure.Messaging.ServiceBus.Filters;
using Microsoft.Azure.Amqp;
using Microsoft.Azure.Amqp.Encoding;
using Microsoft.Azure.Amqp.Framing;
using Azure.Messaging.ServiceBus.Primitives;
using SBMessage = Azure.Messaging.ServiceBus.ServiceBusMessage;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Amqp
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Azure.Core;
using Azure.Messaging.ServiceBus.Amqp.Framing;
using Azure.Messaging.ServiceBus.Core;
using Azure.Messaging.ServiceBus.Filters;
using Azure.Messaging.ServiceBus.Management;
using Microsoft.Azure.Amqp;
using Microsoft.Azure.Amqp.Encoding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ private static (string KeyName, string Resource, DateTimeOffset ExpirationTime)

if (string.IsNullOrEmpty(value))
{
throw new ArgumentException(Resources.InvalidSharedAccessSignature, nameof(sharedAccessSignature));
throw new ArgumentException(
Resources.InvalidSharedAccessSignature,
nameof(sharedAccessSignature));
}

// Compare the token against the known signature properties and capture the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public static void AssertPositive(TimeSpan argumentValue, string argumentName)
///
/// <exception cref="ArgumentOutOfRangeException"><paramref name="argumentValue"/> is less than <paramref name="minimumValue"/>.</exception>
///
public static void AssertAtLeast(long argumentValue, long minimumValue, string argumentName)
public static void AssertAtLeast<T>(T argumentValue, T minimumValue, string argumentName)where T : notnull, IComparable<T>
{
if (argumentValue < minimumValue)
if (minimumValue.CompareTo(argumentValue) > 0)
{
throw new ArgumentOutOfRangeException(argumentName, $"The value supplied must be greater than or equal to {minimumValue}.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus.Filters;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Core
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace Azure.Messaging.ServiceBus.Management
/// </summary>
public class AuthorizationRules : List<AuthorizationRule>, IEquatable<AuthorizationRules>
{
private bool RequiresEncryption => Count > 0;

internal XElement Serialize()
{
var rules = new XElement(
Expand All @@ -40,7 +38,7 @@ public override int GetHashCode()
int hash = 7;
unchecked
{
foreach (var rule in this)
foreach (AuthorizationRule rule in this)
{
hash = (hash * 7) + rule.GetHashCode();
}
Expand All @@ -63,7 +61,7 @@ public override bool Equals(object obj)
/// </summary>
public bool Equals(AuthorizationRules other)
{
if (ReferenceEquals(other, null) || Count != other.Count)
if (other is null || Count != other.Count)
{
return false;
}
Expand Down Expand Up @@ -93,7 +91,7 @@ public bool Equals(AuthorizationRules other)
return true;
}

if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
if (left is null || right is null)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace Azure.Messaging.ServiceBus.Management
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Azure.Core;
using Azure.Messaging.ServiceBus.Primitives;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Represents the correlation rule filter expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

using System.Xml.Linq;
using Azure.Messaging.ServiceBus.Diagnostics;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal static class CorrelationRuleFilterExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Matches none the messages arriving to be selected for the subscription.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Represents the filter actions which are allowed for the transformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
using System;
using System.Xml.Linq;
using Azure.Messaging.ServiceBus.Diagnostics;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal static class RuleActionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

using System;
using Azure.Core;
using Azure.Messaging.ServiceBus.Primitives;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Represents a description of a rule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
using System.Globalization;
using System.Xml.Linq;
using Azure.Core;
using Azure.Messaging.ServiceBus.Management;
using Azure.Messaging.ServiceBus.Primitives;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal static class RuleDescriptionExtensions
{
Expand All @@ -33,9 +32,11 @@ public static void ValidateDescriptionName(this RuleDescription description)
{
if (description.Name.Contains(uriSchemeKey))
{
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
throw new ArgumentException(
nameof(description.Name),
Resources.CharacterReservedForUriScheme.FormatForUser(nameof(description.Name), uriSchemeKey));
Resources.CharacterReservedForUriScheme.FormatForUser(nameof(description.Name), uriSchemeKey),
nameof(description.Name));
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Describes a filter expression that is evaluated against a Message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
using System;
using System.Xml.Linq;
using Azure.Messaging.ServiceBus.Diagnostics;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal static class RuleFilterExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Azure.Core;
using Azure.Messaging.ServiceBus.Primitives;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Represents set of actions written in SQL language-based syntax that is performed against a <see cref="ServiceBusMessage" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Azure.Core;
using Azure.Messaging.ServiceBus.Primitives;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT License.

using System.Xml.Linq;
using Azure.Messaging.ServiceBus.Filters;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal static class SqlRuleFilterExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
/// <summary>
/// Matches all the messages arriving to be selected for the subscription.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
using System.Xml;
using System.Xml.Linq;
using Azure.Messaging.ServiceBus.Diagnostics;
using Azure.Messaging.ServiceBus.Management;

namespace Azure.Messaging.ServiceBus.Filters
namespace Azure.Messaging.ServiceBus.Management
{
internal class XmlObjectConvertor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using Azure.Core;
using Azure.Messaging.ServiceBus.Primitives;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 😞


namespace Azure.Messaging.ServiceBus.Management
{
Expand Down Expand Up @@ -99,12 +99,11 @@ public TimeSpan DefaultMessageTimeToLive
get => _defaultMessageTimeToLive;
set
{
if (value < ManagementClientConstants.MinimumAllowedTimeToLive || value > ManagementClientConstants.MaximumAllowedTimeToLive)
{
throw new ArgumentOutOfRangeException(
$"The value must be between {ManagementClientConstants.MinimumAllowedTimeToLive} and {ManagementClientConstants.MaximumAllowedTimeToLive}",
nameof(DefaultMessageTimeToLive));
}
Argument.AssertInRange(
value,
ManagementClientConstants.MinimumAllowedTimeToLive,
ManagementClientConstants.MaximumAllowedTimeToLive,
nameof(DefaultMessageTimeToLive));

_defaultMessageTimeToLive = value;
}
Expand All @@ -119,12 +118,10 @@ public TimeSpan AutoDeleteOnIdle
get => autoDeleteOnIdle;
set
{
if (value < ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle)
{
throw new ArgumentOutOfRangeException(
$"The value must be greater than {ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle}",
nameof(AutoDeleteOnIdle));
}
Argument.AssertAtLeast(
value,
ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle,
nameof(AutoDeleteOnIdle));

autoDeleteOnIdle = value;
}
Expand All @@ -147,12 +144,11 @@ public TimeSpan DuplicateDetectionHistoryTimeWindow
get => _duplicateDetectionHistoryTimeWindow;
set
{
if (value < ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow || value > ManagementClientConstants.MaximumDuplicateDetectionHistoryTimeWindow)
{
throw new ArgumentOutOfRangeException(
$"The value must be between {ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow} and {ManagementClientConstants.MaximumDuplicateDetectionHistoryTimeWindow}",
nameof(DuplicateDetectionHistoryTimeWindow));
}
Argument.AssertInRange(
value,
ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow,
ManagementClientConstants.MaximumDuplicateDetectionHistoryTimeWindow,
nameof(DuplicateDetectionHistoryTimeWindow));

_duplicateDetectionHistoryTimeWindow = value;
}
Expand All @@ -169,12 +165,10 @@ public int MaxDeliveryCount
get => _maxDeliveryCount;
set
{
if (value < ManagementClientConstants.MinAllowedMaxDeliveryCount)
{
throw new ArgumentOutOfRangeException(
$"The value must be greater than {ManagementClientConstants.MinAllowedMaxDeliveryCount}",
nameof(MaxDeliveryCount));
}
Argument.AssertAtLeast(
value,
ManagementClientConstants.MinAllowedMaxDeliveryCount,
nameof(MaxDeliveryCount));

_maxDeliveryCount = value;
}
Expand Down Expand Up @@ -265,15 +259,11 @@ public string UserMetadata
get => _userMetadata;
set
{
if (value == null)
{
throw new ArgumentNullException($"Value cannot be null", nameof(UserMetadata));
}

if (value.Length > ManagementClientConstants.MaxUserMetadataLength)
{
throw new ArgumentOutOfRangeException($"Length cannot cross {ManagementClientConstants.MaxUserMetadataLength} characters", nameof(UserMetadata));
}
Argument.AssertNotNull(value, nameof(UserMetadata));
Argument.AssertNotTooLong(
value,
ManagementClientConstants.MaxUserMetadataLength,
nameof(UserMetadata));

_userMetadata = value;
}
Expand Down Expand Up @@ -338,7 +328,7 @@ public bool Equals(QueueDescription other)
return true;
}

if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
if (left is null || right is null)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Azure.Core.Pipeline;
using Azure.Messaging.ServiceBus.Authorization;
using Azure.Messaging.ServiceBus.Core;
using Azure.Messaging.ServiceBus.Filters;

namespace Azure.Messaging.ServiceBus.Management
{
Expand Down
Loading