public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var vnet = this.GetVirtualNetwork(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(vnet); } else { IPage <Microsoft.Azure.Management.Network.Models.VirtualNetwork> vnetPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { vnetPage = this.VirtualNetworkClient.List(this.ResourceGroupName); } else { vnetPage = this.VirtualNetworkClient.ListAll(); } // Get all resources by polling on next page link var vnetList = ListNextLink <Microsoft.Azure.Management.Network.Models.VirtualNetwork> .GetAllResourcesByPollingNextLink(vnetPage, this.VirtualNetworkClient.ListNext); var psVnets = new List <PSVirtualNetwork>(); foreach (var virtualNetwork in vnetList) { var psVnet = this.ToPsVirtualNetwork(virtualNetwork); psVnet.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(virtualNetwork.Id); psVnets.Add(psVnet); } WriteObject(psVnets, true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var vnetGatewayConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); WriteObject(vnetGatewayConnection); } else if (ShouldListByResourceGroup(ResourceGroupName, Name)) { var connectionPage = this.VirtualNetworkGatewayConnectionClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var connectionList = ListNextLink <VirtualNetworkGatewayConnection> .GetAllResourcesByPollingNextLink(connectionPage, this.VirtualNetworkGatewayConnectionClient.ListNext); var psVnetGatewayConnections = new List <PSVirtualNetworkGatewayConnection>(); foreach (var virtualNetworkGatewayConnection in connectionList) { var psVnetGatewayConnection = this.ToPsVirtualNetworkGatewayConnection(virtualNetworkGatewayConnection); psVnetGatewayConnection.ResourceGroupName = this.ResourceGroupName; psVnetGatewayConnections.Add(psVnetGatewayConnection); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psVnetGatewayConnections), true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var pe = this.GetPrivateEndpoint(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(pe); } else { IPage <PrivateEndpoint> pePage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { pePage = this.PrivateEndpointClient.List(this.ResourceGroupName); } else { pePage = this.PrivateEndpointClient.ListBySubscription(); } var peList = ListNextLink <PrivateEndpoint> .GetAllResourcesByPollingNextLink(pePage, this.PrivateEndpointClient.ListNext); var psPEs = new List <PSPrivateEndpoint>(); foreach (var pe in peList) { var psPE = this.ToPsPrivateEndpoint(pe); psPE.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(pe.Id); psPEs.Add(psPE); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psPEs), true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var localnetGateway = this.GetLocalNetworkGateway(this.ResourceGroupName, this.Name); WriteObject(localnetGateway); } else if (ShouldListByResourceGroup(ResourceGroupName, Name)) { var localnetGatewayPage = this.LocalNetworkGatewayClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var localnetGatewayList = ListNextLink <LocalNetworkGateway> .GetAllResourcesByPollingNextLink(localnetGatewayPage, this.LocalNetworkGatewayClient.ListNext); var psLocalnetGateways = new List <PSLocalNetworkGateway>(); foreach (var localNetworkGateway in localnetGatewayList) { var psLocalnetGateway = this.ToPsLocalNetworkGateway(localNetworkGateway); psLocalnetGateway.ResourceGroupName = this.ResourceGroupName; psLocalnetGateways.Add(psLocalnetGateway); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psLocalnetGateways), true); } }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var vnetGatewayConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); WriteObject(vnetGatewayConnection); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { var connectionPage = this.VirtualNetworkGatewayConnectionClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var connectionList = ListNextLink <VirtualNetworkGatewayConnection> .GetAllResourcesByPollingNextLink(connectionPage, this.VirtualNetworkGatewayConnectionClient.ListNext); var psVnetGatewayConnections = new List <PSVirtualNetworkGatewayConnection>(); foreach (var virtualNetworkGatewayConnection in connectionList) { var psVnetGatewayConnection = this.ToPsVirtualNetworkGatewayConnection(virtualNetworkGatewayConnection); psVnetGatewayConnection.ResourceGroupName = this.ResourceGroupName; psVnetGatewayConnections.Add(psVnetGatewayConnection); } WriteObject(psVnetGatewayConnections, true); } }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var localnetGateway = this.GetLocalNetworkGateway(this.ResourceGroupName, this.Name); WriteObject(localnetGateway); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { var localnetGatewayPage = this.LocalNetworkGatewayClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var localnetGatewayList = ListNextLink <LocalNetworkGateway> .GetAllResourcesByPollingNextLink(localnetGatewayPage, this.LocalNetworkGatewayClient.ListNext); var psLocalnetGateways = new List <PSLocalNetworkGateway>(); foreach (var localNetworkGateway in localnetGatewayList) { var psLocalnetGateway = this.ToPsLocalNetworkGateway(localNetworkGateway); psLocalnetGateway.ResourceGroupName = this.ResourceGroupName; psLocalnetGateways.Add(psLocalnetGateway); } WriteObject(psLocalnetGateways, true); } }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var vnetGateway = this.GetVirtualNetworkGateway(this.ResourceGroupName, this.Name); WriteObject(vnetGateway); } else if (!string.IsNullOrEmpty(this.ResourceGroupName)) { var vnetGatewayPage = this.VirtualNetworkGatewayClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var vnetGatewayList = ListNextLink <Management.Network.Models.VirtualNetworkGateway> .GetAllResourcesByPollingNextLink(vnetGatewayPage, this.VirtualNetworkGatewayClient.ListNext); var psVnetGateways = new List <PSVirtualNetworkGateway>(); foreach (var virtualNetworkGateway in vnetGatewayList) { var psVnetGateway = this.ToPsVirtualNetworkGateway(virtualNetworkGateway); psVnetGateway.ResourceGroupName = this.ResourceGroupName; psVnetGateways.Add(psVnetGateway); } WriteObject(psVnetGateways, true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var circuit = this.GetExpressRouteCircuit(this.ResourceGroupName, this.Name); WriteObject(circuit); } else { IPage <ExpressRouteCircuit> circuitPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { circuitPage = this.ExpressRouteCircuitClient.List(this.ResourceGroupName); } else { circuitPage = this.ExpressRouteCircuitClient.ListAll(); } // Get all resources by polling on next page link var circuitList = ListNextLink <ExpressRouteCircuit> .GetAllResourcesByPollingNextLink(circuitPage, this.ExpressRouteCircuitClient.ListNext); var psCircuits = new List <PSExpressRouteCircuit>(); foreach (var ExpressRouteCircuit in circuitList) { var psVnet = this.ToPsExpressRouteCircuit(ExpressRouteCircuit); psVnet.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(ExpressRouteCircuit.Id); psCircuits.Add(psVnet); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psCircuits), true); } }
public override void Execute() { base.Execute(); if (ShouldGetByName(ResourceGroupName, Name)) { var pls = this.GetPrivateLinkService(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(pls); } else { IPage <PrivateLinkService> plsPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { plsPage = this.PrivateLinkServiceClient.List(this.ResourceGroupName); } else { plsPage = this.PrivateLinkServiceClient.ListBySubscription(); } var plsList = ListNextLink <PrivateLinkService> .GetAllResourcesByPollingNextLink(plsPage, this.PrivateLinkServiceClient.ListNext); var psPLSs = new List <PSPrivateLinkService>(); foreach (var pls in plsList) { var psPls = this.ToPsPrivateLinkService(pls); psPls.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(pls.Id); psPLSs.Add(psPls); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psPLSs), true); } }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var crossConnection = this.GetExpressRouteCrossConnection(this.ResourceGroupName, this.Name); WriteObject(crossConnection); } else { IPage <ExpressRouteCrossConnection> crossConnectionPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { crossConnectionPage = this.ExpressRouteCrossConnectionClient.ListByResourceGroup(this.ResourceGroupName); } else { crossConnectionPage = this.ExpressRouteCrossConnectionClient.List(); } // Get all resources by polling on next page link var crossConnectionList = ListNextLink <ExpressRouteCrossConnection> .GetAllResourcesByPollingNextLink(crossConnectionPage, this.ExpressRouteCrossConnectionClient.ListNext); var psCrossConnections = new List <PSExpressRouteCrossConnection>(); foreach (var crossConnection in crossConnectionList) { var psCrossConnection = this.ToPsExpressRouteCrossConnection(crossConnection); psCrossConnection.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(crossConnection.Id); psCrossConnections.Add(psCrossConnection); } WriteObject(psCrossConnections, true); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldGetByName(ResourceGroupName, Name)) { var azureFirewall = this.GetAzureFirewall(this.ResourceGroupName, this.Name); WriteObject(azureFirewall); } else { IPage <AzureFirewall> azureFirewallPage = ShouldListBySubscription(ResourceGroupName, Name) ? this.AzureFirewallClient.ListAll() : this.AzureFirewallClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var azureFirewallResponseList = ListNextLink <AzureFirewall> .GetAllResourcesByPollingNextLink(azureFirewallPage, this.AzureFirewallClient.ListNext); var psAzureFirewalls = azureFirewallResponseList.Select(firewall => { var psAzureFirewall = this.ToPsAzureFirewall(firewall); psAzureFirewall.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(firewall.Id); return(psAzureFirewall); }).ToList(); WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psAzureFirewalls), true); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (!string.IsNullOrEmpty(this.Name)) { var azureFirewall = this.GetAzureFirewall(this.ResourceGroupName, this.Name); WriteObject(azureFirewall); } else { IPage <AzureFirewall> azureFirewallPage = string.IsNullOrEmpty(this.ResourceGroupName) ? this.AzureFirewallClient.ListAll() : this.AzureFirewallClient.List(this.ResourceGroupName); // Get all resources by polling on next page link var azureFirewallResponseLIst = ListNextLink <AzureFirewall> .GetAllResourcesByPollingNextLink(azureFirewallPage, this.AzureFirewallClient.ListNext); var psAzureFirewalls = azureFirewallResponseLIst.Select(firewall => { var psAzureFirewall = this.ToPsAzureFirewall(firewall); psAzureFirewall.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(firewall.Id); return(psAzureFirewall); }).ToList(); WriteObject(psAzureFirewalls, true); } }
public override void Execute() { base.Execute(); if (!string.IsNullOrEmpty(this.Name)) { var routeTable = this.GetRouteTable(this.ResourceGroupName, this.Name, this.ExpandResource); WriteObject(routeTable); } else { IPage <RouteTable> routeTablePage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { routeTablePage = this.RouteTableClient.List(this.ResourceGroupName); } else { routeTablePage = this.RouteTableClient.ListAll(); } // Get all resources by polling on next page link var routeTableList = ListNextLink <RouteTable> .GetAllResourcesByPollingNextLink(routeTablePage, this.RouteTableClient.ListNext); var psRouteTables = new List <PSRouteTable>(); foreach (var routeTable in routeTableList) { var psRouteTable = this.ToPsRouteTable(routeTable); psRouteTable.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(routeTable.Id); psRouteTables.Add(psRouteTable); } WriteObject(psRouteTables, true); } }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, VirtualRouterParameterSetNames.ByVirtualRouterResourceId, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; RouterName = resourceInfo.ResourceName; } string ipConfigName = "ipconfig1"; if (ShouldGetByName(ResourceGroupName, RouterName)) { var virtualHub = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouterName); var virtualHubModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualHub>(virtualHub); virtualHubModel.ResourceGroupName = this.ResourceGroupName; virtualHubModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); AddBgpConnectionsToPSVirtualHub(virtualHub, virtualHubModel, ResourceGroupName, RouterName); AddIpConfigurtaionToPSVirtualHub(virtualHubModel, this.ResourceGroupName, RouterName, ipConfigName); var virtualRouterModel = new PSVirtualRouter(virtualHubModel); virtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); WriteObject(virtualRouterModel, true); } else { IPage <VirtualHub> virtualHubPage; if (ShouldListByResourceGroup(ResourceGroupName, RouterName)) { virtualHubPage = this.NetworkClient.NetworkManagementClient.VirtualHubs.ListByResourceGroup(this.ResourceGroupName); } else { virtualHubPage = this.NetworkClient.NetworkManagementClient.VirtualHubs.List(); } var virtualHubList = ListNextLink <VirtualHub> .GetAllResourcesByPollingNextLink(virtualHubPage, this.NetworkClient.NetworkManagementClient.VirtualHubs.ListNext); List <PSVirtualRouter> virtualRouterList = new List <PSVirtualRouter>(); foreach (var virtualHub in virtualHubList) { RouterName = virtualHub.Name; var virtualHubModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualHub>(virtualHub); virtualHubModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(virtualHub.Id); virtualHubModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); AddBgpConnectionsToPSVirtualHub(virtualHub, virtualHubModel, ResourceGroupName, RouterName); AddIpConfigurtaionToPSVirtualHub(virtualHubModel, this.ResourceGroupName, RouterName, ipConfigName); var virtualRouterModel = new PSVirtualRouter(virtualHubModel); virtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); virtualRouterList.Add(virtualRouterModel); } WriteObject(virtualRouterList, true); } }
public void AddBgpConnectionsToPSVirtualHub(CNM.PSVirtualHub virtualHubModel, string resourceGroupName, string routerName) { var bgpConnections = this.NetworkClient.NetworkManagementClient.VirtualHubBgpConnections.List(resourceGroupName, routerName); var bgpConnectionList = ListNextLink <BgpConnection> .GetAllResourcesByPollingNextLink(bgpConnections, this.NetworkClient.NetworkManagementClient.VirtualHubBgpConnections.ListNext); foreach (var connection in bgpConnectionList) { virtualHubModel.BgpConnections.Add(NetworkResourceManagerProfile.Mapper.Map <CNM.PSBgpConnection>(connection)); } }
public List <PSPrivateEndpointConnection> ListPrivateEndpointConnections(string resourceGroupName, string serviceName) { var pecPage = BaseCmdlet.NetworkClient.NetworkManagementClient.PrivateLinkServices.ListPrivateEndpointConnections(resourceGroupName, serviceName); var pecList = ListNextLink <MNM.PrivateEndpointConnection> .GetAllResourcesByPollingNextLink(pecPage, BaseCmdlet.NetworkClient.NetworkManagementClient.PrivateLinkServices.ListPrivateEndpointConnectionsNext); var psPECs = new List <PSPrivateEndpointConnection>(); foreach (var pec in pecList) { var psPec = this.ToPsPrivateEndpointConnection(pec); psPECs.Add(psPec); } return(psPECs); }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (ShouldGetByName(this.ResourceGroupName, this.Name)) { PSCustomIpPrefix psModel; psModel = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name); WriteObject(psModel); } else { IPage <CustomIpPrefix> page; if (ShouldListByResourceGroup(this.ResourceGroupName, this.Name)) { page = this.CustomIpPrefixClient.List(this.ResourceGroupName); } else { page = this.CustomIpPrefixClient.ListAll(); } // Get all resources by polling on next page link List <CustomIpPrefix> sdkModelList; sdkModelList = ListNextLink <CustomIpPrefix> .GetAllResourcesByPollingNextLink(page, this.CustomIpPrefixClient.ListNext); var psModelList = new List <PSCustomIpPrefix>(); // populate the publicIpPrefixes with the ResourceGroupName foreach (var sdkModel in sdkModelList) { var psModel = this.ToPsCustomIpPrefix(sdkModel); psModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psModel.Id); psModelList.Add(psModel); } WriteObject(TopLevelWildcardFilter(this.ResourceGroupName, this.Name, psModelList), true); } }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, VirtualRouterParameterSetNames.ByVirtualRouterResourceId, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; RouterName = resourceInfo.ResourceName; } if (ShouldGetByName(ResourceGroupName, RouterName)) { var vVirtualRouter = this.NetworkClient.NetworkManagementClient.VirtualRouters.Get(ResourceGroupName, RouterName); var vVirtualRouterModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualRouter>(vVirtualRouter); vVirtualRouterModel.ResourceGroupName = this.ResourceGroupName; vVirtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(vVirtualRouter.Tags); AddPeeringsToPSVirtualRouter(vVirtualRouter, vVirtualRouterModel, ResourceGroupName, RouterName); WriteObject(vVirtualRouterModel, true); } else { IPage <VirtualRouter> vVirtualRouterPage; if (ShouldListByResourceGroup(ResourceGroupName, RouterName)) { vVirtualRouterPage = this.NetworkClient.NetworkManagementClient.VirtualRouters.ListByResourceGroup(this.ResourceGroupName); } else { vVirtualRouterPage = this.NetworkClient.NetworkManagementClient.VirtualRouters.List(); } var vVirtualRouterList = ListNextLink <VirtualRouter> .GetAllResourcesByPollingNextLink(vVirtualRouterPage, this.NetworkClient.NetworkManagementClient.VirtualRouters.ListNext); List <PSVirtualRouter> psVirtualRouterList = new List <PSVirtualRouter>(); foreach (var vVirtualRouter in vVirtualRouterList) { RouterName = vVirtualRouter.Name; var vVirtualRouterModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualRouter>(vVirtualRouter); vVirtualRouterModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vVirtualRouter.Id); vVirtualRouterModel.Tag = TagsConversionHelper.CreateTagHashtable(vVirtualRouter.Tags); AddPeeringsToPSVirtualRouter(vVirtualRouter, vVirtualRouterModel, ResourceGroupName, RouterName); psVirtualRouterList.Add(vVirtualRouterModel); } WriteObject(psVirtualRouterList, true); } }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (!string.IsNullOrEmpty(this.Name)) { PSPublicIpPrefix publicIpPrefix; publicIpPrefix = this.GetPublicIpPrefix(this.ResourceGroupName, this.Name); WriteObject(publicIpPrefix); } else { IPage <PublicIPPrefix> publicipprefixPage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { publicipprefixPage = this.PublicIpPrefixClient.List(this.ResourceGroupName); } else { publicipprefixPage = this.PublicIpPrefixClient.ListAll(); } // Get all resources by polling on next page link List <PublicIPPrefix> publicIPPrefixList; publicIPPrefixList = ListNextLink <PublicIPPrefix> .GetAllResourcesByPollingNextLink(publicipprefixPage, this.PublicIpPrefixClient.ListNext); var psPublicIpPrefixes = new List <PSPublicIpPrefix>(); // populate the publicIpPrefixes with the ResourceGroupName foreach (var publicIpPrefix in publicIPPrefixList) { var psPublicIpPrefix = this.ToPsPublicIpPrefix(publicIpPrefix); psPublicIpPrefix.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(publicIpPrefix.Id); psPublicIpPrefixes.Add(psPublicIpPrefix); } WriteObject(psPublicIpPrefixes, true); } }
public List <PSPrivateLinkResource> ListPrivateLinkResource(string resourceGroupName, string serviceName) { var plrPage = BaseCmdlet.NetworkClient.SqlManagementClient.PrivateLinkResources.ListByServer(resourceGroupName, serviceName); var plrList = ListNextLink <MSM.PrivateLinkResource> .GetAllResourcesByPollingNextLink(plrPage, BaseCmdlet.NetworkClient.SqlManagementClient.PrivateLinkResources.ListByServerNext); var psPLRs = new List <PSPrivateLinkResource>(); foreach (var plr in plrList) { var psPlr = ToPsPrivateLinkResource(plr); psPLRs.Add(psPlr); } return(psPLRs); }
public override void Execute() { base.Execute(); BackendAddressPool loadBalancerBackendAddressPool = null; if (this.IsParameterBound(c => c.LoadBalancer)) { this.ResourceGroupName = this.LoadBalancer.ResourceGroupName; this.LoadBalancerName = this.LoadBalancer.Name; } if (this.IsParameterBound(p => p.ResourceId)) { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.LoadBalancerName = resourceIdentifier.ParentResource.Split('/')[1]; this.Name = resourceIdentifier.ResourceName; } // Get single backend pool if (ShouldGetByName(this.ResourceGroupName, this.Name)) { loadBalancerBackendAddressPool = this.NetworkClient.NetworkManagementClient.LoadBalancerBackendAddressPools.Get(this.ResourceGroupName, this.LoadBalancerName, this.Name); var loadBalancerBackendAddressPoolModel = NetworkResourceManagerProfile.Mapper.Map <PSBackendAddressPool>(loadBalancerBackendAddressPool); WriteObject(loadBalancerBackendAddressPoolModel); } else { IPage <BackendAddressPool> backendAddressPoolPage = this.NetworkClient.NetworkManagementClient.LoadBalancerBackendAddressPools.List(this.ResourceGroupName, this.LoadBalancerName); // compose list of BackendAddressPools var backendAddressPoolList = ListNextLink <BackendAddressPool> .GetAllResourcesByPollingNextLink(backendAddressPoolPage, this.NetworkClient.NetworkManagementClient.LoadBalancerBackendAddressPools.ListNext); // convert list of BackendAddressPools to a list of Powershell BackendAddressPools List <PSBackendAddressPool> psBackendAddressPoolList = new List <PSBackendAddressPool>(); foreach (var backendAddressPool in backendAddressPoolList) { var backendAddressPoolModel = NetworkResourceManagerProfile.Mapper.Map <PSBackendAddressPool>(backendAddressPool); psBackendAddressPoolList.Add(backendAddressPoolModel); } WriteObject(psBackendAddressPoolList, true); } }
public void AddPeeringsToPSVirtualRouter(VirtualRouter vVirtualRouter, CNM.PSVirtualRouter vVirtualRouterModel, string resourceGroupName, string routerName) { if (vVirtualRouter.Peerings != null && vVirtualRouter.Peerings.Count > 0) { var vVirtualRouterPeering = this.NetworkClient.NetworkManagementClient.VirtualRouterPeerings.List(resourceGroupName, routerName); var vVirtualRouterPeeringList = ListNextLink <VirtualRouterPeering> .GetAllResourcesByPollingNextLink(vVirtualRouterPeering, this.NetworkClient.NetworkManagementClient.VirtualRouterPeerings.ListNext); foreach (var peering in vVirtualRouterPeeringList) { vVirtualRouterModel.Peerings.Add(NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualRouterPeer>(peering)); } } }
internal static IEnumerable <PSAzureFirewallFqdnTag> GetAzureFirewallAllowedFqdnTags(IAzureFirewallFqdnTagsOperations azureFirewallFqdnTagClient) { IPage <AzureFirewallFqdnTag> azureFirewallFqdnTagPage = azureFirewallFqdnTagClient.ListAll(); // Get all resources by polling on next page link var azureFirewallFqdnTagResponseLIst = ListNextLink <AzureFirewallFqdnTag> .GetAllResourcesByPollingNextLink(azureFirewallFqdnTagPage, azureFirewallFqdnTagClient.ListAllNext); var psAzureFirewallFqdnTags = azureFirewallFqdnTagResponseLIst.Select(fqdnTag => { var psFqdnTag = ToPsAzureFirewallFqdnTag(fqdnTag); psFqdnTag.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(fqdnTag.Id); return(psFqdnTag); }).ToList(); return(psAzureFirewallFqdnTags); }
public override void Execute() { base.Execute(); if (this.IsParameterBound(p => p.ResourceId)) { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (!string.IsNullOrEmpty(this.Name)) { var vNetworkProfile = this.NetworkClient.NetworkManagementClient.NetworkProfiles.Get(ResourceGroupName, Name, ExpandResource); var vNetworkProfileModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSNetworkProfile>(vNetworkProfile); vNetworkProfileModel.ResourceGroupName = this.ResourceGroupName; vNetworkProfileModel.Tag = TagsConversionHelper.CreateTagHashtable(vNetworkProfile.Tags); WriteObject(vNetworkProfileModel, true); } else { IPage <NetworkProfile> vNetworkProfilePage; if (!string.IsNullOrEmpty(this.ResourceGroupName)) { vNetworkProfilePage = this.NetworkClient.NetworkManagementClient.NetworkProfiles.List(this.ResourceGroupName); } else { vNetworkProfilePage = this.NetworkClient.NetworkManagementClient.NetworkProfiles.ListAll(); } var vNetworkProfileList = ListNextLink <NetworkProfile> .GetAllResourcesByPollingNextLink(vNetworkProfilePage, this.NetworkClient.NetworkManagementClient.NetworkProfiles.ListNext); List <PSNetworkProfile> psNetworkProfileList = new List <PSNetworkProfile>(); foreach (var vNetworkProfile in vNetworkProfileList) { var vNetworkProfileModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSNetworkProfile>(vNetworkProfile); vNetworkProfileModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vNetworkProfile.Id); vNetworkProfileModel.Tag = TagsConversionHelper.CreateTagHashtable(vNetworkProfile.Tags); psNetworkProfileList.Add(vNetworkProfileModel); } WriteObject(psNetworkProfileList, true); } }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; Name = resourceInfo.ResourceName; } if (ShouldGetByName(ResourceGroupName, Name)) { var vExpressRoutePort = this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.Get(ResourceGroupName, Name); var vExpressRoutePortModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSExpressRoutePort>(vExpressRoutePort); vExpressRoutePortModel.ResourceGroupName = this.ResourceGroupName; vExpressRoutePortModel.Tag = TagsConversionHelper.CreateTagHashtable(vExpressRoutePort.Tags); WriteObject(vExpressRoutePortModel, true); } else { IPage <ExpressRoutePort> vExpressRoutePortPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { vExpressRoutePortPage = this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.ListByResourceGroup(this.ResourceGroupName); } else { vExpressRoutePortPage = this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.List(); } var vExpressRoutePortList = ListNextLink <ExpressRoutePort> .GetAllResourcesByPollingNextLink(vExpressRoutePortPage, this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.ListNext); List <PSExpressRoutePort> psExpressRoutePortList = new List <PSExpressRoutePort>(); foreach (var vExpressRoutePort in vExpressRoutePortList) { var vExpressRoutePortModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSExpressRoutePort>(vExpressRoutePort); vExpressRoutePortModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vExpressRoutePort.Id); vExpressRoutePortModel.Tag = TagsConversionHelper.CreateTagHashtable(vExpressRoutePort.Tags); psExpressRoutePortList.Add(vExpressRoutePortModel); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psExpressRoutePortList), true); } }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (ShouldGetByName(this.ResourceGroupName, this.Name)) { var vNatGateway = this.NetworkClient.NetworkManagementClient.NatGateways.Get(ResourceGroupName, Name); var vNatGatewayModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSNatGateway>(vNatGateway); vNatGatewayModel.ResourceGroupName = this.ResourceGroupName; vNatGatewayModel.Tag = TagsConversionHelper.CreateTagHashtable(vNatGateway.Tags); WriteObject(vNatGatewayModel, true); } else { IPage <NatGateway> vNatGatewayPage; if (ShouldListByResourceGroup(this.ResourceGroupName, this.Name)) { vNatGatewayPage = this.NetworkClient.NetworkManagementClient.NatGateways.List(this.ResourceGroupName); } else { vNatGatewayPage = this.NetworkClient.NetworkManagementClient.NatGateways.ListAll(); } var vNatGatewayList = ListNextLink <NatGateway> .GetAllResourcesByPollingNextLink(vNatGatewayPage, this.NetworkClient.NetworkManagementClient.NatGateways.ListNext); List <PSNatGateway> psNatGatewayList = new List <PSNatGateway>(); foreach (var vNatGateway in vNatGatewayList) { var vNatGatewayModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSNatGateway>(vNatGateway); vNatGatewayModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vNatGateway.Id); vNatGatewayModel.Tag = TagsConversionHelper.CreateTagHashtable(vNatGateway.Tags); psNatGatewayList.Add(vNatGatewayModel); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psNatGatewayList), true); } }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (ShouldGetByName(ResourceGroupName, Name)) { var vVirtualNetworkTap = this.NetworkClient.NetworkManagementClient.VirtualNetworkTaps.Get(ResourceGroupName, Name); var vVirtualNetworkTapModel = NetworkResourceManagerProfile.Mapper.Map <CNM.PSVirtualNetworkTap>(vVirtualNetworkTap); vVirtualNetworkTapModel.ResourceGroupName = this.ResourceGroupName; vVirtualNetworkTapModel.Tag = TagsConversionHelper.CreateTagHashtable(vVirtualNetworkTap.Tags); WriteObject(vVirtualNetworkTapModel, true); } else { IPage <VirtualNetworkTap> vtapPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { vtapPage = this.NetworkClient.NetworkManagementClient.VirtualNetworkTaps.ListByResourceGroup(this.ResourceGroupName); } else { vtapPage = this.NetworkClient.NetworkManagementClient.VirtualNetworkTaps.ListAll(); } // Get all resources by polling on next page link var vtapList = ListNextLink <VirtualNetworkTap> .GetAllResourcesByPollingNextLink(vtapPage, this.NetworkClient.NetworkManagementClient.VirtualNetworkTaps.ListByResourceGroupNext); var psVtaps = new List <PSVirtualNetworkTap>(); foreach (var vtap in vtapList) { var psVtap = this.ToPsVirtualNetworkTap(vtap); psVtap.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vtap.Id); psVtaps.Add(psVtap); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psVtaps), true); } }
public void AddIpConfigurtaionToPSVirtualHub(CNM.PSVirtualHub virtualHubModel, string resourceGroupName, string routerName) { var ipConfigModels = this.NetworkClient.NetworkManagementClient.VirtualHubIpConfiguration.List(resourceGroupName, routerName); var ipConfigList = ListNextLink <HubIpConfiguration> .GetAllResourcesByPollingNextLink(ipConfigModels, this.NetworkClient.NetworkManagementClient.VirtualHubIpConfiguration.ListNext); HubIpConfiguration ipConfigModel = null; if (ipConfigList.Count > 0) { ipConfigModel = ipConfigList[0]; } var ipconfig = NetworkResourceManagerProfile.Mapper.Map <CNM.PSHubIpConfiguration>(ipConfigModel); virtualHubModel.IpConfigurations = new List <CNM.PSHubIpConfiguration>(); virtualHubModel.IpConfigurations.Add(ipconfig); }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } if (ShouldGetByName(ResourceGroupName, Name)) { var allocation = this.GetIpAllocation(this.ResourceGroupName, this.Name); WriteObject(allocation); } else { IPage <Microsoft.Azure.Management.Network.Models.IpAllocation> allocationPage; if (ShouldListByResourceGroup(ResourceGroupName, Name)) { allocationPage = this.IpAllocationClient.ListByResourceGroup(this.ResourceGroupName); } else { allocationPage = this.IpAllocationClient.List(); } // Get all resources by polling on next page link var allocationList = ListNextLink <Microsoft.Azure.Management.Network.Models.IpAllocation> .GetAllResourcesByPollingNextLink(allocationPage, this.IpAllocationClient.ListNext); var psAllocations = new List <PSIpAllocation>(); foreach (var allocation in allocationList) { var psAllocation = this.ToPsIpAllocation(allocation); psAllocation.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psAllocation.Id); psAllocations.Add(psAllocation); } WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, psAllocations), true); } }
public override void ExecuteCmdlet() { if (!this.IsIpGroupsPresent(this.ResourceGroupName, this.Name)) { throw new System.ArgumentException(string.Format(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound, this.Name)); } base.ExecuteCmdlet(); if (string.Equals(this.ParameterSetName, IpGroupParameterSetNames.ByResourceId, System.StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; Name = resourceInfo.ResourceName; } if (ShouldGetByName(ResourceGroupName, Name)) { var ipGroups = this.GetIpGroup(this.ResourceGroupName, this.Name); WriteObject(ipGroups); } else { var ipGroupsPage = ShouldListBySubscription(ResourceGroupName, Name) ? this.IpGroupsClient.List() : this.IpGroupsClient.ListByResourceGroup(this.ResourceGroupName); // Get all resources by polling on next page link var ipGroupsResponseList = ListNextLink <IpGroup> .GetAllResourcesByPollingNextLink(ipGroupsPage, this.IpGroupsClient.ListNext); var PSIpGroups = ipGroupsResponseList.Select(ipGroups => { var PSIpGroup = this.ToPSIpGroup(ipGroups); PSIpGroup.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(ipGroups.Id); return(PSIpGroup); }).ToList(); WriteObject(TopLevelWildcardFilter(ResourceGroupName, Name, PSIpGroups), true); } }