/// <summary> /// Gets the InputObject Resource by ResourceGroupName and InputObject Name /// </summary> /// <returns>InputObject Resource</returns> public object GetPeeringByResourceAndName() { var ic = this.PeeringClient.Get(this.ResourceGroupName, this.Name); var peer = this.ToPeeringPs(ic); if (peer.Exchange != null) { var obj = new PSExchangePeeringModelView(peer); return(obj); } if (peer.Direct != null) { var obj = new PSDirectPeeringModelView(peer); return(obj); } return(null); }
/// <summary> /// The convert classic to direct peering. /// </summary> /// <param name="this.LegacyPeering"> /// The classic peering. /// </param> /// <returns> /// The <see cref="object"/>. /// </returns> private PSPeering ConvertClassicToDirectPeering(PSDirectPeeringModelView peering) { if (peering == null) { throw new PSArgumentNullException(string.Format(Resources.Error_UnableToConvertLegacy, "LegacyPeering")); } if (peering.Connections == null) { throw new PSArgumentNullException(string.Format(Resources.Error_UnableToConvertLegacy, "Connection")); } var connections = peering.Connections.ToList(); var newPeering = new PSPeering { Location = this.GetAzureRegion(peering.PeeringLocation, Constants.Direct), PeeringLocation = peering.PeeringLocation, Kind = peering.Kind ?? Constants.Direct, Sku = peering.Sku ?? new PSPeeringSku(Constants.BasicDirectFree), Direct = new PSPeeringPropertiesDirect { Connections = connections, PeerAsn = new PSSubResource(this.PeerAsnResourceId) }, Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, true), }; foreach (var connection in newPeering.Direct.Connections) { connection.ConnectionIdentifier = Guid.NewGuid().ToString(); connection.BandwidthInMbps = connection.ProvisionedBandwidthInMbps ?? 10000; } try { return((PSPeering)this.PutNewPeering(newPeering)); } catch (ErrorResponseException ex) { var error = this.GetErrorCodeAndMessageFromArmOrErm(ex); throw new ErrorResponseException(string.Format(Resources.Error_CloudError, error.Code, error.Message)); } }