/// <summary>
 /// The New Dedicated Circuit operation creates a new dedicated circuit.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the relationship between
 /// Azure and the customer.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the New Bgp Peering operation.
 /// </param>
 /// <returns>
 /// A standard express route gateway response including an HTTP status
 /// code and request ID.
 /// </returns>
 public static ExpressRouteOperationResponse BeginNew(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IBgpPeeringOperations)s).BeginNewAsync(serviceKey, accessType, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The Get Dedicated Circuit Peering Routing Information operation
 /// retrieves the ARP information for specific BGP.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRoutingInfoOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the circuit.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public or microsoft.
 /// </param>
 /// <param name='devicePath'>
 /// Required. Whether the device is primary or secondary.
 /// </param>
 /// <returns>
 /// The Get Dedicated Circuit Peering Route Table Info operation
 /// response.
 /// </returns>
 public static DedicatedCircuitPeeringRoutingInfoGetResponse Get(this IDedicatedCircuitPeeringRoutingInfoOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IDedicatedCircuitPeeringRoutingInfoOperations)s).GetAsync(serviceKey, accessType, devicePath);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type)
 {
     var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key,type);
     stats.PrimaryBytesIn += tempstats.PrimaryBytesIn;
     stats.PrimaryBytesOut += tempstats.PrimaryBytesOut;
     stats.SecondaryBytesIn += tempstats.SecondaryBytesIn;
     stats.SecondaryBytesOut += tempstats.SecondaryBytesOut;
     return stats;
 }
 public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet,
     string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
 {
     return Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters()
     {
         PeerAsn = peerAsn,
         PrimaryPeerSubnet = primaryPeerSubnet,
         SecondaryPeerSubnet = secondaryPeerSubnet,
         SharedKey = sharedKey,
         VlanId = vlanId
     }).BgpPeering;
 }
 public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey, 
     BgpPeeringAccessType accessType, UInt32 peerAsn, string primaryPeerSubnet,
     string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
 {
     return
        (Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters()
         {
             PeerAsn = peerAsn,
             PrimaryPeerSubnet = primaryPeerSubnet,
             SecondaryPeerSubnet = secondaryPeerSubnet,
             SharedKey = sharedKey,
             VlanId = vlanId,
         })).BgpPeering;
 }
 /// <summary>
 /// The New Dedicated Circuit operation creates a new dedicated circuit.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The service key representing the relationship between Azure and the
 /// customer.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the New Bgp Peering operation.
 /// </param>
 /// <returns>
 /// A standard express route gateway response including an HTTP status
 /// code and request ID.
 /// </returns>
 public static ExpressRouteOperationResponse BeginNew(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters)
 {
     try
     {
         return operations.BeginNewAsync(serviceKey, accessType, parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type)
 {
     try
     {
         AzureBgpPeering peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, type);
         if (peering != null)
         {
             var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key, type);
             stats.PrimaryBytesIn += tempstats.PrimaryBytesIn;
             stats.PrimaryBytesOut += tempstats.PrimaryBytesOut;
             stats.SecondaryBytesIn += tempstats.SecondaryBytesIn;
             stats.SecondaryBytesOut += tempstats.SecondaryBytesOut;
         }
         return stats;
     }
     catch
     {
         // The cirucit might not have corresponding peering
         return stats;
     }
 }
 /// <summary>
 /// The Update Bgp Peering operation updates an existing bgp peering or
 /// creates a new one if one doesn't exist.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The service key representing the relationship between Azure and the
 /// customer.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update Bgp Peering operation.
 /// </param>
 /// <returns>
 /// The Get Bgp Peering Operation Response.
 /// </returns>
 public static BgpPeeringGetResponse Update(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters)
 {
     try
     {
         return operations.UpdateAsync(serviceKey, accessType, parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 /// <summary>
 /// The Remove Bgp Peering operation deletes an existing bgp peering.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Service key associated with the bgp peering to be deleted.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself.  If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request.  If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request, and also includes error
 /// information regarding the failure.
 /// </returns>
 public static ExpressRouteOperationStatusResponse Remove(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     try
     {
         return operations.RemoveAsync(serviceKey, accessType).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 /// <summary>
 /// The Remove Bgp Peering operation deletes an existing bgp peering.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Service key associated with the bgp peering to be deleted.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself.  If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request.  If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request, and also includes error
 /// information regarding the failure.
 /// </returns>
 public static Task<ExpressRouteOperationStatusResponse> RemoveAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     return operations.RemoveAsync(serviceKey, accessType, CancellationToken.None);
 }
 /// <summary>
 /// The Get Bgp Peering operation retrieves the bgp peering for the
 /// dedicated circuit with the specified service key.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The servicee key representing the dedicated circuit.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The Get Bgp Peering Operation Response.
 /// </returns>
 public static BgpPeeringGetResponse Get(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     try
     {
         return operations.GetAsync(serviceKey, accessType).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
 /// <summary>
 /// The Get Bgp Peering operation retrieves the bgp peering for the
 /// dedicated circuit with the specified service key.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The servicee key representing the dedicated circuit.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The Get Bgp Peering Operation Response.
 /// </returns>
 public static Task<BgpPeeringGetResponse> GetAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     return operations.GetAsync(serviceKey, accessType, CancellationToken.None);
 }
 /// <summary>
 /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives
 /// RouteTableSummary.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRouteTableSummaryOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the circuit.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public or microsoft.
 /// </param>
 /// <param name='devicePath'>
 /// Required. Whether the device is primary or secondary.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<ExpressRouteOperationResponse> BeginGetAsync(this IDedicatedCircuitPeeringRouteTableSummaryOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath)
 {
     return operations.BeginGetAsync(serviceKey, accessType, devicePath, CancellationToken.None);
 }
 /// <summary>
 /// The New Dedicated Circuit operation creates a new dedicated circuit.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The service key representing the relationship between Azure and the
 /// customer.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the New Bgp Peering operation.
 /// </param>
 /// <returns>
 /// A standard express route gateway response including an HTTP status
 /// code and request ID.
 /// </returns>
 public static Task<ExpressRouteOperationResponse> BeginNewAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters)
 {
     return operations.BeginNewAsync(serviceKey, accessType, parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Get Dedicated Circuit Stats operation retrieves the
 /// bytesin/bytesout of the dedicated circuit on primary/secondary
 /// devices for specified peering type.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitStatsOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the circuit.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public or microsoft.
 /// </param>
 /// <returns>
 /// The Get DedicatedCircuitStats operation response.
 /// </returns>
 public static Task<DedicatedCircuitStatsGetResponse> GetAsync(this IDedicatedCircuitStatsOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     return operations.GetAsync(serviceKey, accessType, CancellationToken.None);
 }
 public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType)
 {
     return Client.BgpPeering.Get(serviceKey, accessType).BgpPeering;
 }
 public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType)
 {
     return Client.BorderGatewayProtocolPeerings.Get(serviceKey, accessType).BgpPeering;
 }
 /// <summary>
 /// The Get Bgp Peering operation retrieves the bgp peering for the
 /// dedicated circuit with the specified service key.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The servicee key representing the dedicated circuit.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The Get Bgp Peering Operation Response.
 /// </returns>
 public static BgpPeeringGetResponse Get(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IBgpPeeringOperations)s).GetAsync(serviceKey, accessType);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The Remove Border Gateway Protocol Peering operation deletes an
 /// existing border gateway protocol peering.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. Service key associated with the border gateway protocol
 /// peering to be deleted.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself.  If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request.  If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request, and also includes error
 /// information regarding the failure.
 /// </returns>
 public static ExpressRouteOperationStatusResponse Remove(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IBorderGatewayProtocolPeeringOperations)s).RemoveAsync(serviceKey, accessType);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The New Border Gateway Protocol Peering operation creates a new
 /// border gateway protocol peering associated with the dedicated
 /// circuit specified by the service key provided.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the relationship between
 /// Azure and the customer.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the New Bgp Peering operation.
 /// </param>
 /// <returns>
 /// The Get Border Gateway Protocol Peering Operation Response.
 /// </returns>
 public static Task<BorderGatewayProtocolPeeringGetResponse> NewAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringNewParameters parameters)
 {
     return operations.NewAsync(serviceKey, accessType, parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Update Border Gateway Protocol Peering operation updates an
 /// existing bgp peering.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the relationship between
 /// Azure and the customer.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Border Gateway Protocol
 /// Peering operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<ExpressRouteOperationResponse> BeginUpdateAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringUpdateParameters parameters)
 {
     return operations.BeginUpdateAsync(serviceKey, accessType, parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Update Bgp Peering operation updates an existing bgp peering or
 /// creates a new one if one doesn't exist.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// The service key representing the relationship between Azure and the
 /// customer.
 /// </param>
 /// <param name='accessType'>
 /// Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update Bgp Peering operation.
 /// </param>
 /// <returns>
 /// The Get Bgp Peering Operation Response.
 /// </returns>
 public static Task<BgpPeeringGetResponse> UpdateAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters)
 {
     return operations.UpdateAsync(serviceKey, accessType, parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Get Dedicated Circuit Peering Routing Information operation
 /// retrieves the ARP information for specific BGP.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRoutingInfoOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the circuit.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public or microsoft.
 /// </param>
 /// <param name='devicePath'>
 /// Required. Whether the device is primary or secondary.
 /// </param>
 /// <returns>
 /// The Get Dedicated Circuit Peering Route Table Info operation
 /// response.
 /// </returns>
 public static Task<DedicatedCircuitPeeringRoutingInfoGetResponse> GetAsync(this IDedicatedCircuitPeeringRoutingInfoOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath)
 {
     return operations.GetAsync(serviceKey, accessType, devicePath, CancellationToken.None);
 }
 /// <summary>
 /// The Update Border Gateway Protocol Peering operation updates an
 /// existing border gateway protocol peering or creates a new one if
 /// one doesn't exist.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations.
 /// </param>
 /// <param name='serviceKey'>
 /// Required. The service key representing the relationship between
 /// Azure and the customer.
 /// </param>
 /// <param name='accessType'>
 /// Required. Whether the peering is private or public.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Border Gateway Protocol
 /// Peering operation.
 /// </param>
 /// <returns>
 /// The Get Border Gateway Protocol Peering Operation Response.
 /// </returns>
 public static BorderGatewayProtocolPeeringGetResponse Update(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IBorderGatewayProtocolPeeringOperations)s).UpdateAsync(serviceKey, accessType, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType)
 {
     var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey, accessType);
     return result.HttpStatusCode.Equals(HttpStatusCode.OK);
 }