diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props
index b2c29cc57ea77..37cf24da90cd7 100644
--- a/eng/Packages.Data.props
+++ b/eng/Packages.Data.props
@@ -116,7 +116,7 @@
-
+
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj b/sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj
index d946ca140dc17..e34d88566b51e 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj
+++ b/sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj
@@ -27,7 +27,7 @@
-
+
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayContainer.cs
index faef73ed442af..de2e00f36d985 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string applicationGatewayName, C
}
var response = _restClient.Get(Id.ResourceGroupName, applicationGatewayName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationGateway(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string applicat
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, applicationGatewayName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationGateway(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string applicat
/// Tries to get details for this resource from the service.
/// The name of the application gateway.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ApplicationGateway TryGet(string applicationGatewayName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string applicationGatewayName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ApplicationGateway TryGet(string applicationGatewayName, Cancella
throw new ArgumentNullException(nameof(applicationGatewayName));
}
- return Get(applicationGatewayName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, applicationGatewayName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationGateway(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ApplicationGateway TryGet(string applicationGatewayName, Cancella
/// Tries to get details for this resource from the service.
/// The name of the application gateway.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string applicationGatewayName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string applicationGatewayName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string applicationGate
throw new ArgumentNullException(nameof(applicationGatewayName));
}
- return await GetAsync(applicationGatewayName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, applicationGatewayName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationGateway(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string applicationGate
/// Tries to get details for this resource from the service.
/// The name of the application gateway.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string applicationGatewayName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string applicationGatewayName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string applicationGatewayName, CancellationTok
throw new ArgumentNullException(nameof(applicationGatewayName));
}
- return TryGet(applicationGatewayName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(applicationGatewayName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string applicationGatewayName, CancellationTok
/// Tries to get details for this resource from the service.
/// The name of the application gateway.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string applicationGatewayName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string applicationGatewayName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string applicationGatewayName
throw new ArgumentNullException(nameof(applicationGatewayName));
}
- return await TryGetAsync(applicationGatewayName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(applicationGatewayName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayOperations.cs
index 1447477cbda36..c23c7a43bcef5 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayOperations.cs
@@ -55,6 +55,8 @@ public async virtual Task> GetAsync(CancellationTok
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationGateway(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -73,6 +75,8 @@ public virtual Response Get(CancellationToken cancellationTo
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationGateway(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionContainer.cs
index b67357ca0ccae..5e8c1d5fc0758 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionContainer.cs
@@ -58,6 +58,8 @@ public virtual Response Get(string
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -82,6 +84,8 @@ public async virtual Task>
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -94,9 +98,9 @@ public async virtual Task>
/// Tries to get details for this resource from the service.
/// The name of the application gateway private endpoint connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ApplicationGatewayPrivateEndpointConnection TryGet(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -105,11 +109,10 @@ public virtual ApplicationGatewayPrivateEndpointConnection TryGet(string connect
throw new ArgumentNullException(nameof(connectionName));
}
- return Get(connectionName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -121,9 +124,9 @@ public virtual ApplicationGatewayPrivateEndpointConnection TryGet(string connect
/// Tries to get details for this resource from the service.
/// The name of the application gateway private endpoint connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -132,11 +135,10 @@ public async virtual Task TryGetAsy
throw new ArgumentNullException(nameof(connectionName));
}
- return await GetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -148,7 +150,7 @@ public async virtual Task TryGetAsy
/// Tries to get details for this resource from the service.
/// The name of the application gateway private endpoint connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.CheckIfExists");
scope.Start();
@@ -159,7 +161,8 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
throw new ArgumentNullException(nameof(connectionName));
}
- return TryGet(connectionName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(connectionName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -171,7 +174,7 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
/// Tries to get details for this resource from the service.
/// The name of the application gateway private endpoint connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationGatewayPrivateEndpointConnectionContainer.CheckIfExists");
scope.Start();
@@ -182,7 +185,8 @@ public async virtual Task CheckIfExistsAsync(string connectionName, Cancel
throw new ArgumentNullException(nameof(connectionName));
}
- return await TryGetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionOperations.cs
index 4882af58995e5..3563904760d81 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationGatewayPrivateEndpointConnectionOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task>
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(Cancell
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationGatewayPrivateEndpointConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupContainer.cs
index 8f7e652d4a17c..e4db829c90a97 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string applicationSecurity
}
var response = _restClient.Get(Id.ResourceGroupName, applicationSecurityGroupName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationSecurityGroup(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string ap
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, applicationSecurityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationSecurityGroup(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string ap
/// Tries to get details for this resource from the service.
/// The name of the application security group.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ApplicationSecurityGroup TryGet(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ApplicationSecurityGroup TryGet(string applicationSecurityGroupNa
throw new ArgumentNullException(nameof(applicationSecurityGroupName));
}
- return Get(applicationSecurityGroupName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, applicationSecurityGroupName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationSecurityGroup(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ApplicationSecurityGroup TryGet(string applicationSecurityGroupNa
/// Tries to get details for this resource from the service.
/// The name of the application security group.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string applicati
throw new ArgumentNullException(nameof(applicationSecurityGroupName));
}
- return await GetAsync(applicationSecurityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, applicationSecurityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ApplicationSecurityGroup(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string applicati
/// Tries to get details for this resource from the service.
/// The name of the application security group.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string applicationSecurityGroupName, Cancellat
throw new ArgumentNullException(nameof(applicationSecurityGroupName));
}
- return TryGet(applicationSecurityGroupName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(applicationSecurityGroupName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string applicationSecurityGroupName, Cancellat
/// Tries to get details for this resource from the service.
/// The name of the application security group.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string applicationSecurityGroupName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ApplicationSecurityGroupContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string applicationSecurityGro
throw new ArgumentNullException(nameof(applicationSecurityGroupName));
}
- return await TryGetAsync(applicationSecurityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(applicationSecurityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupOperations.cs
index eea65eda849a9..ee4b5a0683996 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ApplicationSecurityGroupOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(Cancellat
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ApplicationSecurityGroup(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancella
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ApplicationSecurityGroup(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallContainer.cs
index e730a33b83677..c30f494678e8a 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string azureFirewallName, Cancellatio
}
var response = _restClient.Get(Id.ResourceGroupName, azureFirewallName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new AzureFirewall(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string azureFirewall
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, azureFirewallName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new AzureFirewall(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string azureFirewall
/// Tries to get details for this resource from the service.
/// The name of the Azure Firewall.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual AzureFirewall TryGet(string azureFirewallName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string azureFirewallName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual AzureFirewall TryGet(string azureFirewallName, CancellationToken
throw new ArgumentNullException(nameof(azureFirewallName));
}
- return Get(azureFirewallName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, azureFirewallName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new AzureFirewall(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual AzureFirewall TryGet(string azureFirewallName, CancellationToken
/// Tries to get details for this resource from the service.
/// The name of the Azure Firewall.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string azureFirewallName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string azureFirewallName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string azureFirewallName, C
throw new ArgumentNullException(nameof(azureFirewallName));
}
- return await GetAsync(azureFirewallName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, azureFirewallName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new AzureFirewall(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string azureFirewallName, C
/// Tries to get details for this resource from the service.
/// The name of the Azure Firewall.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string azureFirewallName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string azureFirewallName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string azureFirewallName, CancellationToken ca
throw new ArgumentNullException(nameof(azureFirewallName));
}
- return TryGet(azureFirewallName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(azureFirewallName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string azureFirewallName, CancellationToken ca
/// Tries to get details for this resource from the service.
/// The name of the Azure Firewall.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string azureFirewallName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string azureFirewallName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string azureFirewallName, Can
throw new ArgumentNullException(nameof(azureFirewallName));
}
- return await TryGetAsync(azureFirewallName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(azureFirewallName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallOperations.cs
index 1ee88bc607a41..d1613f69ab457 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/AzureFirewallOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToken ca
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new AzureFirewall(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationToken =
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new AzureFirewall(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolContainer.cs
index 009624ea528ca..142fcfeebf97f 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string backendAddressPoolName, C
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, backendAddressPoolName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BackendAddressPool(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string backendA
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, backendAddressPoolName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BackendAddressPool(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string backendA
/// Tries to get details for this resource from the service.
/// The name of the backend address pool.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual BackendAddressPool TryGet(string backendAddressPoolName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string backendAddressPoolName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual BackendAddressPool TryGet(string backendAddressPoolName, Cancella
throw new ArgumentNullException(nameof(backendAddressPoolName));
}
- return Get(backendAddressPoolName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, backendAddressPoolName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BackendAddressPool(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual BackendAddressPool TryGet(string backendAddressPoolName, Cancella
/// Tries to get details for this resource from the service.
/// The name of the backend address pool.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string backendAddressPoolName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string backendAddressPoolName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string backendAddressP
throw new ArgumentNullException(nameof(backendAddressPoolName));
}
- return await GetAsync(backendAddressPoolName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, backendAddressPoolName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BackendAddressPool(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string backendAddressP
/// Tries to get details for this resource from the service.
/// The name of the backend address pool.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string backendAddressPoolName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string backendAddressPoolName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string backendAddressPoolName, CancellationTok
throw new ArgumentNullException(nameof(backendAddressPoolName));
}
- return TryGet(backendAddressPoolName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(backendAddressPoolName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string backendAddressPoolName, CancellationTok
/// Tries to get details for this resource from the service.
/// The name of the backend address pool.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string backendAddressPoolName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string backendAddressPoolName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BackendAddressPoolContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string backendAddressPoolName
throw new ArgumentNullException(nameof(backendAddressPoolName));
}
- return await TryGetAsync(backendAddressPoolName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(backendAddressPoolName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolOperations.cs
index 6de83824eb90e..033429d6290c3 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BackendAddressPoolOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationTok
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BackendAddressPool(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationTo
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BackendAddressPool(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostContainer.cs
index 3f51a2d4f6dfc..7f3b564bb75c9 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string bastionHostName, CancellationTok
}
var response = _restClient.Get(Id.ResourceGroupName, bastionHostName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BastionHost(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string bastionHostName
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, bastionHostName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BastionHost(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string bastionHostName
/// Tries to get details for this resource from the service.
/// The name of the Bastion Host.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual BastionHost TryGet(string bastionHostName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string bastionHostName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual BastionHost TryGet(string bastionHostName, CancellationToken canc
throw new ArgumentNullException(nameof(bastionHostName));
}
- return Get(bastionHostName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, bastionHostName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BastionHost(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual BastionHost TryGet(string bastionHostName, CancellationToken canc
/// Tries to get details for this resource from the service.
/// The name of the Bastion Host.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string bastionHostName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string bastionHostName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string bastionHostName, Cance
throw new ArgumentNullException(nameof(bastionHostName));
}
- return await GetAsync(bastionHostName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, bastionHostName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BastionHost(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string bastionHostName, Cance
/// Tries to get details for this resource from the service.
/// The name of the Bastion Host.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string bastionHostName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string bastionHostName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string bastionHostName, CancellationToken canc
throw new ArgumentNullException(nameof(bastionHostName));
}
- return TryGet(bastionHostName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(bastionHostName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string bastionHostName, CancellationToken canc
/// Tries to get details for this resource from the service.
/// The name of the Bastion Host.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string bastionHostName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string bastionHostName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string bastionHostName, Cance
throw new ArgumentNullException(nameof(bastionHostName));
}
- return await TryGetAsync(bastionHostName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(bastionHostName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostOperations.cs
index 88bf25e6acf25..d474bdbaabef5 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BastionHostOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToken canc
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BastionHost(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationToken = d
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BastionHost(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionContainer.cs
index 26ca11ea86b57..28b99a309fef4 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string connectionName, CancellationTo
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BgpConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string connectionNam
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BgpConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string connectionNam
/// Tries to get details for this resource from the service.
/// The name of the connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual BgpConnection TryGet(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual BgpConnection TryGet(string connectionName, CancellationToken can
throw new ArgumentNullException(nameof(connectionName));
}
- return Get(connectionName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BgpConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual BgpConnection TryGet(string connectionName, CancellationToken can
/// Tries to get details for this resource from the service.
/// The name of the connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string connectionName, Canc
throw new ArgumentNullException(nameof(connectionName));
}
- return await GetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new BgpConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string connectionName, Canc
/// Tries to get details for this resource from the service.
/// The name of the connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
throw new ArgumentNullException(nameof(connectionName));
}
- return TryGet(connectionName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(connectionName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
/// Tries to get details for this resource from the service.
/// The name of the connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("BgpConnectionContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string connectionName, Cancel
throw new ArgumentNullException(nameof(connectionName));
}
- return await TryGetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionOperations.cs
index 7719d54fe84a8..f61083e0f0576 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/BgpConnectionOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToken ca
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new BgpConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationToken =
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new BgpConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorContainer.cs
index 2f5811618f43f..5720ae916ad78 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorContainer.cs
@@ -183,6 +183,8 @@ public virtual Response Get(string connectionMonitorName, Can
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionMonitorName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ConnectionMonitor(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -207,6 +209,8 @@ public async virtual Task> GetAsync(string connectio
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionMonitorName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ConnectionMonitor(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -219,9 +223,9 @@ public async virtual Task> GetAsync(string connectio
/// Tries to get details for this resource from the service.
/// The name of the connection monitor.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ConnectionMonitor TryGet(string connectionMonitorName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string connectionMonitorName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.GetIfExists");
scope.Start();
try
{
@@ -230,11 +234,10 @@ public virtual ConnectionMonitor TryGet(string connectionMonitorName, Cancellati
throw new ArgumentNullException(nameof(connectionMonitorName));
}
- return Get(connectionMonitorName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, connectionMonitorName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ConnectionMonitor(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -246,9 +249,9 @@ public virtual ConnectionMonitor TryGet(string connectionMonitorName, Cancellati
/// Tries to get details for this resource from the service.
/// The name of the connection monitor.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string connectionMonitorName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string connectionMonitorName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.GetIfExists");
scope.Start();
try
{
@@ -257,11 +260,10 @@ public async virtual Task TryGetAsync(string connectionMonito
throw new ArgumentNullException(nameof(connectionMonitorName));
}
- return await GetAsync(connectionMonitorName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, connectionMonitorName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ConnectionMonitor(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -273,7 +275,7 @@ public async virtual Task TryGetAsync(string connectionMonito
/// Tries to get details for this resource from the service.
/// The name of the connection monitor.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string connectionMonitorName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string connectionMonitorName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.CheckIfExists");
scope.Start();
@@ -284,7 +286,8 @@ public virtual bool CheckIfExists(string connectionMonitorName, CancellationToke
throw new ArgumentNullException(nameof(connectionMonitorName));
}
- return TryGet(connectionMonitorName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(connectionMonitorName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -296,7 +299,7 @@ public virtual bool CheckIfExists(string connectionMonitorName, CancellationToke
/// Tries to get details for this resource from the service.
/// The name of the connection monitor.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string connectionMonitorName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string connectionMonitorName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ConnectionMonitorContainer.CheckIfExists");
scope.Start();
@@ -307,7 +310,8 @@ public async virtual Task CheckIfExistsAsync(string connectionMonitorName,
throw new ArgumentNullException(nameof(connectionMonitorName));
}
- return await TryGetAsync(connectionMonitorName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(connectionMonitorName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorOperations.cs
index 54babf5913902..7716411d044f9 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ConnectionMonitorOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToke
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ConnectionMonitor(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationTok
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ConnectionMonitor(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixContainer.cs
index b31deb347f8ad..9bb89da2cab7f 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixContainer.cs
@@ -180,6 +180,8 @@ public virtual Response Get(string customIpPrefixName, string ex
}
var response = _restClient.Get(Id.ResourceGroupName, customIpPrefixName, expand, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new CustomIpPrefix(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -205,6 +207,8 @@ public async virtual Task> GetAsync(string customIpPref
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, customIpPrefixName, expand, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new CustomIpPrefix(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -218,9 +222,9 @@ public async virtual Task> GetAsync(string customIpPref
/// The name of the custom IP prefix.
/// Expands referenced resources.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual CustomIpPrefix TryGet(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.GetIfExists");
scope.Start();
try
{
@@ -229,11 +233,10 @@ public virtual CustomIpPrefix TryGet(string customIpPrefixName, string expand =
throw new ArgumentNullException(nameof(customIpPrefixName));
}
- return Get(customIpPrefixName, expand, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, customIpPrefixName, expand, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new CustomIpPrefix(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -246,9 +249,9 @@ public virtual CustomIpPrefix TryGet(string customIpPrefixName, string expand =
/// The name of the custom IP prefix.
/// Expands referenced resources.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.GetIfExists");
scope.Start();
try
{
@@ -257,11 +260,10 @@ public async virtual Task TryGetAsync(string customIpPrefixName,
throw new ArgumentNullException(nameof(customIpPrefixName));
}
- return await GetAsync(customIpPrefixName, expand, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, customIpPrefixName, expand, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new CustomIpPrefix(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -274,7 +276,7 @@ public async virtual Task TryGetAsync(string customIpPrefixName,
/// The name of the custom IP prefix.
/// Expands referenced resources.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.CheckIfExists");
scope.Start();
@@ -285,7 +287,8 @@ public virtual bool CheckIfExists(string customIpPrefixName, string expand = nul
throw new ArgumentNullException(nameof(customIpPrefixName));
}
- return TryGet(customIpPrefixName, expand, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(customIpPrefixName, expand, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -298,7 +301,7 @@ public virtual bool CheckIfExists(string customIpPrefixName, string expand = nul
/// The name of the custom IP prefix.
/// Expands referenced resources.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string customIpPrefixName, string expand = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("CustomIpPrefixContainer.CheckIfExists");
scope.Start();
@@ -309,7 +312,8 @@ public async virtual Task CheckIfExistsAsync(string customIpPrefixName, st
throw new ArgumentNullException(nameof(customIpPrefixName));
}
- return await TryGetAsync(customIpPrefixName, expand, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(customIpPrefixName, expand, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixOperations.cs
index e308c82ffc786..0095e65fdedcd 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/CustomIpPrefixOperations.cs
@@ -53,6 +53,8 @@ public async virtual Task> GetAsync(string expand = nul
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new CustomIpPrefix(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -72,6 +74,8 @@ public virtual Response Get(string expand = null, CancellationTo
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, expand, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new CustomIpPrefix(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyContainer.cs
index d7936b7da4df5..cf66239eb3b56 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyContainer.cs
@@ -177,6 +177,8 @@ public virtual Response Get(string ddosCustomPolicyName, Cance
}
var response = _restClient.Get(Id.ResourceGroupName, ddosCustomPolicyName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DdosCustomPolicy(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -201,6 +203,8 @@ public async virtual Task> GetAsync(string ddosCustom
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, ddosCustomPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DdosCustomPolicy(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -213,9 +217,9 @@ public async virtual Task> GetAsync(string ddosCustom
/// Tries to get details for this resource from the service.
/// The name of the DDoS custom policy.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual DdosCustomPolicy TryGet(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.GetIfExists");
scope.Start();
try
{
@@ -224,11 +228,10 @@ public virtual DdosCustomPolicy TryGet(string ddosCustomPolicyName, Cancellation
throw new ArgumentNullException(nameof(ddosCustomPolicyName));
}
- return Get(ddosCustomPolicyName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, ddosCustomPolicyName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DdosCustomPolicy(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -240,9 +243,9 @@ public virtual DdosCustomPolicy TryGet(string ddosCustomPolicyName, Cancellation
/// Tries to get details for this resource from the service.
/// The name of the DDoS custom policy.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.GetIfExists");
scope.Start();
try
{
@@ -251,11 +254,10 @@ public async virtual Task TryGetAsync(string ddosCustomPolicyN
throw new ArgumentNullException(nameof(ddosCustomPolicyName));
}
- return await GetAsync(ddosCustomPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, ddosCustomPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DdosCustomPolicy(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -267,7 +269,7 @@ public async virtual Task TryGetAsync(string ddosCustomPolicyN
/// Tries to get details for this resource from the service.
/// The name of the DDoS custom policy.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.CheckIfExists");
scope.Start();
@@ -278,7 +280,8 @@ public virtual bool CheckIfExists(string ddosCustomPolicyName, CancellationToken
throw new ArgumentNullException(nameof(ddosCustomPolicyName));
}
- return TryGet(ddosCustomPolicyName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(ddosCustomPolicyName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -290,7 +293,7 @@ public virtual bool CheckIfExists(string ddosCustomPolicyName, CancellationToken
/// Tries to get details for this resource from the service.
/// The name of the DDoS custom policy.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string ddosCustomPolicyName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DdosCustomPolicyContainer.CheckIfExists");
scope.Start();
@@ -301,7 +304,8 @@ public async virtual Task CheckIfExistsAsync(string ddosCustomPolicyName,
throw new ArgumentNullException(nameof(ddosCustomPolicyName));
}
- return await TryGetAsync(ddosCustomPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(ddosCustomPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyOperations.cs
index 3aa3157846c43..7a906597ef7d8 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosCustomPolicyOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToken
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DdosCustomPolicy(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationToke
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DdosCustomPolicy(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanContainer.cs
index ea0d7570ee0c1..7e9798c0ea76d 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string ddosProtectionPlanName, C
}
var response = _restClient.Get(Id.ResourceGroupName, ddosProtectionPlanName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DdosProtectionPlan(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string ddosProt
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, ddosProtectionPlanName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DdosProtectionPlan(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string ddosProt
/// Tries to get details for this resource from the service.
/// The name of the DDoS protection plan.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual DdosProtectionPlan TryGet(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual DdosProtectionPlan TryGet(string ddosProtectionPlanName, Cancella
throw new ArgumentNullException(nameof(ddosProtectionPlanName));
}
- return Get(ddosProtectionPlanName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, ddosProtectionPlanName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DdosProtectionPlan(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual DdosProtectionPlan TryGet(string ddosProtectionPlanName, Cancella
/// Tries to get details for this resource from the service.
/// The name of the DDoS protection plan.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string ddosProtectionP
throw new ArgumentNullException(nameof(ddosProtectionPlanName));
}
- return await GetAsync(ddosProtectionPlanName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, ddosProtectionPlanName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DdosProtectionPlan(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string ddosProtectionP
/// Tries to get details for this resource from the service.
/// The name of the DDoS protection plan.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string ddosProtectionPlanName, CancellationTok
throw new ArgumentNullException(nameof(ddosProtectionPlanName));
}
- return TryGet(ddosProtectionPlanName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(ddosProtectionPlanName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string ddosProtectionPlanName, CancellationTok
/// Tries to get details for this resource from the service.
/// The name of the DDoS protection plan.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string ddosProtectionPlanName
throw new ArgumentNullException(nameof(ddosProtectionPlanName));
}
- return await TryGetAsync(ddosProtectionPlanName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(ddosProtectionPlanName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanOperations.cs
index ffd6a352d2a0d..010f5e51785e8 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DdosProtectionPlanOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationTok
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DdosProtectionPlan(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationTo
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DdosProtectionPlan(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationContainer.cs
index fa835b742bb23..b0821dbb41d99 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string dscpConfigurationName, Can
}
var response = _restClient.Get(Id.ResourceGroupName, dscpConfigurationName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DscpConfiguration(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string dscpConfi
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, dscpConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DscpConfiguration(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string dscpConfi
/// Tries to get details for this resource from the service.
/// The name of the resource.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual DscpConfiguration TryGet(string dscpConfigurationName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string dscpConfigurationName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual DscpConfiguration TryGet(string dscpConfigurationName, Cancellati
throw new ArgumentNullException(nameof(dscpConfigurationName));
}
- return Get(dscpConfigurationName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, dscpConfigurationName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DscpConfiguration(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual DscpConfiguration TryGet(string dscpConfigurationName, Cancellati
/// Tries to get details for this resource from the service.
/// The name of the resource.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string dscpConfigurationName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string dscpConfigurationName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string dscpConfiguratio
throw new ArgumentNullException(nameof(dscpConfigurationName));
}
- return await GetAsync(dscpConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, dscpConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new DscpConfiguration(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string dscpConfiguratio
/// Tries to get details for this resource from the service.
/// The name of the resource.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string dscpConfigurationName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string dscpConfigurationName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string dscpConfigurationName, CancellationToke
throw new ArgumentNullException(nameof(dscpConfigurationName));
}
- return TryGet(dscpConfigurationName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(dscpConfigurationName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string dscpConfigurationName, CancellationToke
/// Tries to get details for this resource from the service.
/// The name of the resource.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string dscpConfigurationName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string dscpConfigurationName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("DscpConfigurationContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string dscpConfigurationName,
throw new ArgumentNullException(nameof(dscpConfigurationName));
}
- return await TryGetAsync(dscpConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(dscpConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationOperations.cs
index fbdc94a7bf098..719c200a0d071 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/DscpConfigurationOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationToke
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new DscpConfiguration(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationTok
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new DscpConfiguration(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationContainer.cs
index f0e170225a6e2..0ce5521f74997 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string authorizati
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, authorizationName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuitAuthorization(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(s
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuitAuthorization(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(s
/// Tries to get details for this resource from the service.
/// The name of the authorization.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ExpressRouteCircuitAuthorization TryGet(string authorizationName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string authorizationName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ExpressRouteCircuitAuthorization TryGet(string authorizationName,
throw new ArgumentNullException(nameof(authorizationName));
}
- return Get(authorizationName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, authorizationName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitAuthorization(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ExpressRouteCircuitAuthorization TryGet(string authorizationName,
/// Tries to get details for this resource from the service.
/// The name of the authorization.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string authorizationName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string authorizationName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string a
throw new ArgumentNullException(nameof(authorizationName));
}
- return await GetAsync(authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitAuthorization(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string a
/// Tries to get details for this resource from the service.
/// The name of the authorization.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string authorizationName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string authorizationName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string authorizationName, CancellationToken ca
throw new ArgumentNullException(nameof(authorizationName));
}
- return TryGet(authorizationName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(authorizationName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string authorizationName, CancellationToken ca
/// Tries to get details for this resource from the service.
/// The name of the authorization.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string authorizationName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string authorizationName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitAuthorizationContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string authorizationName, Can
throw new ArgumentNullException(nameof(authorizationName));
}
- return await TryGetAsync(authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationOperations.cs
index a32fa749a6ac7..76f00bb1f9b8c 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitAuthorizationOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(C
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuitAuthorization(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuitAuthorization(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionContainer.cs
index 57d7e7beb4fc5..d2d626647b84d 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string connectionName
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, connectionName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuitConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(stri
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuitConnection(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(stri
/// Tries to get details for this resource from the service.
/// The name of the express route circuit connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ExpressRouteCircuitConnection TryGet(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ExpressRouteCircuitConnection TryGet(string connectionName, Cance
throw new ArgumentNullException(nameof(connectionName));
}
- return Get(connectionName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Name, Id.Name, connectionName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ExpressRouteCircuitConnection TryGet(string connectionName, Cance
/// Tries to get details for this resource from the service.
/// The name of the express route circuit connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string conn
throw new ArgumentNullException(nameof(connectionName));
}
- return await GetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string conn
/// Tries to get details for this resource from the service.
/// The name of the express route circuit connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
throw new ArgumentNullException(nameof(connectionName));
}
- return TryGet(connectionName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(connectionName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string connectionName, CancellationToken cance
/// Tries to get details for this resource from the service.
/// The name of the express route circuit connection.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string connectionName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitConnectionContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string connectionName, Cancel
throw new ArgumentNullException(nameof(connectionName));
}
- return await TryGetAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(connectionName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionOperations.cs
index 41f2eb2515c4b..d688871500a6c 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitConnectionOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(Canc
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuitConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken can
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuitConnection(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitContainer.cs
index d26ca141522e5..1e3928e4546af 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string circuitName, Cancellatio
}
var response = _restClient.Get(Id.ResourceGroupName, circuitName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuit(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string circuit
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, circuitName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuit(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string circuit
/// Tries to get details for this resource from the service.
/// The name of express route circuit.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ExpressRouteCircuit TryGet(string circuitName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string circuitName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ExpressRouteCircuit TryGet(string circuitName, CancellationToken
throw new ArgumentNullException(nameof(circuitName));
}
- return Get(circuitName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, circuitName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuit(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ExpressRouteCircuit TryGet(string circuitName, CancellationToken
/// Tries to get details for this resource from the service.
/// The name of express route circuit.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string circuitName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string circuitName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string circuitName, C
throw new ArgumentNullException(nameof(circuitName));
}
- return await GetAsync(circuitName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, circuitName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuit(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string circuitName, C
/// Tries to get details for this resource from the service.
/// The name of express route circuit.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string circuitName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string circuitName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string circuitName, CancellationToken cancella
throw new ArgumentNullException(nameof(circuitName));
}
- return TryGet(circuitName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(circuitName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string circuitName, CancellationToken cancella
/// Tries to get details for this resource from the service.
/// The name of express route circuit.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string circuitName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string circuitName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string circuitName, Cancellat
throw new ArgumentNullException(nameof(circuitName));
}
- return await TryGetAsync(circuitName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(circuitName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitOperations.cs
index dbd6cf46fca6d..003ae3b6917d0 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitOperations.cs
@@ -52,6 +52,8 @@ public async virtual Task> GetAsync(CancellationTo
try
{
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuit(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -70,6 +72,8 @@ public virtual Response Get(CancellationToken cancellationT
try
{
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuit(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringContainer.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringContainer.cs
index f3faa29144713..20fe9530fc515 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringContainer.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringContainer.cs
@@ -179,6 +179,8 @@ public virtual Response Get(string peeringName, Canc
}
var response = _restClient.Get(Id.ResourceGroupName, Id.Name, peeringName, cancellationToken: cancellationToken);
+ if (response.Value == null)
+ throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
return Response.FromValue(new ExpressRouteCircuitPeering(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -203,6 +205,8 @@ public async virtual Task> GetAsync(string
}
var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, peeringName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
return Response.FromValue(new ExpressRouteCircuitPeering(Parent, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -215,9 +219,9 @@ public async virtual Task> GetAsync(string
/// Tries to get details for this resource from the service.
/// The name of the peering.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual ExpressRouteCircuitPeering TryGet(string peeringName, CancellationToken cancellationToken = default)
+ public virtual Response GetIfExists(string peeringName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.GetIfExists");
scope.Start();
try
{
@@ -226,11 +230,10 @@ public virtual ExpressRouteCircuitPeering TryGet(string peeringName, Cancellatio
throw new ArgumentNullException(nameof(peeringName));
}
- return Get(peeringName, cancellationToken: cancellationToken).Value;
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = _restClient.Get(Id.ResourceGroupName, Id.Name, peeringName, cancellationToken: cancellationToken);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitPeering(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -242,9 +245,9 @@ public virtual ExpressRouteCircuitPeering TryGet(string peeringName, Cancellatio
/// Tries to get details for this resource from the service.
/// The name of the peering.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task TryGetAsync(string peeringName, CancellationToken cancellationToken = default)
+ public async virtual Task> GetIfExistsAsync(string peeringName, CancellationToken cancellationToken = default)
{
- using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.TryGet");
+ using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.GetIfExists");
scope.Start();
try
{
@@ -253,11 +256,10 @@ public async virtual Task TryGetAsync(string peering
throw new ArgumentNullException(nameof(peeringName));
}
- return await GetAsync(peeringName, cancellationToken: cancellationToken).ConfigureAwait(false);
- }
- catch (RequestFailedException e) when (e.Status == 404)
- {
- return null;
+ var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, peeringName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return response.Value == null
+ ? Response.FromValue(null, response.GetRawResponse())
+ : Response.FromValue(new ExpressRouteCircuitPeering(this, response.Value), response.GetRawResponse());
}
catch (Exception e)
{
@@ -269,7 +271,7 @@ public async virtual Task TryGetAsync(string peering
/// Tries to get details for this resource from the service.
/// The name of the peering.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public virtual bool CheckIfExists(string peeringName, CancellationToken cancellationToken = default)
+ public virtual Response CheckIfExists(string peeringName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.CheckIfExists");
scope.Start();
@@ -280,7 +282,8 @@ public virtual bool CheckIfExists(string peeringName, CancellationToken cancella
throw new ArgumentNullException(nameof(peeringName));
}
- return TryGet(peeringName, cancellationToken: cancellationToken) != null;
+ var response = GetIfExists(peeringName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
@@ -292,7 +295,7 @@ public virtual bool CheckIfExists(string peeringName, CancellationToken cancella
/// Tries to get details for this resource from the service.
/// The name of the peering.
/// A token to allow the caller to cancel the call to the service. The default value is .
- public async virtual Task CheckIfExistsAsync(string peeringName, CancellationToken cancellationToken = default)
+ public async virtual Task> CheckIfExistsAsync(string peeringName, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ExpressRouteCircuitPeeringContainer.CheckIfExists");
scope.Start();
@@ -303,7 +306,8 @@ public async virtual Task CheckIfExistsAsync(string peeringName, Cancellat
throw new ArgumentNullException(nameof(peeringName));
}
- return await TryGetAsync(peeringName, cancellationToken: cancellationToken).ConfigureAwait(false) != null;
+ var response = await GetIfExistsAsync(peeringName, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
}
catch (Exception e)
{
diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringOperations.cs
index e8b441da43e70..11799ef028644 100644
--- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringOperations.cs
+++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ExpressRouteCircuitPeeringOperations.cs
@@ -55,6 +55,8 @@ public async virtual Task