public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.PrivateLinkResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.ServiceName = resourceIdentifier.ResourceName; this.PrivateLinkResourceType = resourceIdentifier.ResourceType; this.Subscription = resourceIdentifier.Subscription; } else { this.Subscription = DefaultProfile.DefaultContext.Subscription.Id; this.PrivateLinkResourceType = DynamicParameters[privateEndpointTypeName].Value as string; } IPrivateLinkProvider provider = PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, Subscription, PrivateLinkResourceType); if (provider == null) { throw new ArgumentException(string.Format(Properties.Resources.InvalidResourceId, this.PrivateLinkResourceId)); } if (this.IsParameterBound(c => c.Name)) { var plr = provider.GetPrivateLinkResource(ResourceGroupName, ServiceName, Name); WriteObject(plr); } else { var plrs = provider.ListPrivateLinkResource(ResourceGroupName, ServiceName); WriteObject(plrs, 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; this.Subscription = resourceIdentifier.Subscription; this.PrivateLinkResourceType = resourceIdentifier.ResourceType.Substring(0, resourceIdentifier.ResourceType.LastIndexOf('/')); this.ServiceName = resourceIdentifier.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); } IPrivateLinkProvider provider = BuildProvider(this.Subscription, this.PrivateLinkResourceType); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.RemovingResource, ServiceName), Properties.Resources.RemoveResourceMessage, ServiceName, () => { provider.DeletePrivateEndpointConnection(this.ResourceGroupName, this.ServiceName, this.Name); if (PassThru) { WriteObject(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; this.Subscription = resourceIdentifier.Subscription; this.PrivateLinkResourceType = resourceIdentifier.ResourceType.Substring(0, resourceIdentifier.ResourceType.LastIndexOf('/')); this.ServiceName = resourceIdentifier.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); } else if (this.IsParameterBound(c => c.PrivateLinkResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Subscription = resourceIdentifier.Subscription; this.PrivateLinkResourceType = resourceIdentifier.ResourceType; this.ServiceName = resourceIdentifier.ResourceName; } IPrivateLinkProvider provider = BuildProvider(this.Subscription, this.PrivateLinkResourceType); if (ShouldGetByName(this.ResourceGroupName, this.Name)) { var pec = provider.GetPrivateEndpointConnection(this.ResourceGroupName, this.ServiceName, this.Name); WriteObject(pec); } else { var pecs = provider.ListPrivateEndpointConnections(this.ResourceGroupName, this.ServiceName); WriteObject(SubResourceWildcardFilter(Name, pecs), true); } }
protected IPrivateLinkProvider BuildProvider(string resourceType) { IPrivateLinkProvider provider = null; switch (resourceType.ToLower()) { case "microsoft.sql/servers": provider = new SqlProvider(this); break; default: break; } return(provider); }
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; this.PrivateLinkResourceType = resourceIdentifier.ResourceType.Substring(0, resourceIdentifier.ResourceType.LastIndexOf('/')); this.ServiceName = resourceIdentifier.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); } IPrivateLinkProvider provider = BuildProvider(this.PrivateLinkResourceType); var pec = provider.UpdatePrivateEndpointConnectionStatus(this.ResourceGroupName, this.ServiceName, this.Name, "Approved", this.Description); WriteObject(pec); }
public override void Execute() { base.Execute(); var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId); string ResourceGroupName = resourceIdentifier.ResourceGroupName; string Name = resourceIdentifier.ResourceName; string ResourceType = resourceIdentifier.ResourceType; IPrivateLinkProvider provider = PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, resourceIdentifier.Subscription, ResourceType); if (provider == null) { throw new ArgumentException(string.Format(Properties.Resources.InvalidResourceId, this.PrivateLinkResourceId)); } var plrs = provider.ListPrivateLinkResource(ResourceGroupName, Name); WriteObject(plrs, true); }
public override void Execute() { base.Execute(); if (this.IsParameterBound(c => c.PrivateLinkResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.ServiceName = resourceIdentifier.ResourceName; this.PrivateLinkResourceType = resourceIdentifier.ResourceType; this.Subscription = resourceIdentifier.Subscription; } else { this.Subscription = DefaultProfile.DefaultContext.Subscription.Id; this.PrivateLinkResourceType = DynamicParameters[privateEndpointTypeName].Value as string; } // First check resource type whether support private link feature, if support then check whether support private link resource feature. if (!GenericProvider.SupportsPrivateLinkFeature(this.PrivateLinkResourceType) || !ProviderConfiguration.GetProviderConfiguration(this.PrivateLinkResourceType).SupportListPrivateLinkResource) { throw new AzPSApplicationException(string.Format(Properties.Resources.UnsupportPrivateLinkResourceType, this.PrivateLinkResourceType)); } IPrivateLinkProvider provider = PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, Subscription, PrivateLinkResourceType); if (provider == null) { throw new ArgumentException(string.Format(Properties.Resources.InvalidResourceId, this.PrivateLinkResourceId)); } if (this.IsParameterBound(c => c.Name)) { var plr = provider.GetPrivateLinkResource(ResourceGroupName, ServiceName, Name); WriteObject(plr); } else { var plrs = provider.ListPrivateLinkResource(ResourceGroupName, ServiceName); WriteObject(plrs, true); } }
public static IPrivateLinkProvider CreatePrivateLinkProvder(NetworkBaseCmdlet cmdlet, string subscription, string privateLinkResourceType) { IPrivateLinkProvider provider = null; if (privateLinkResourceType == null) { return(new NetworkingProvider(cmdlet)); } if (GenericProvider.SupportsPrivateLinkResourceType(privateLinkResourceType)) { return(new GenericProvider(cmdlet, subscription, privateLinkResourceType)); } switch (privateLinkResourceType.ToLower()) { case NETWORKING_TYPE: default: provider = new NetworkingProvider(cmdlet); break; } return(provider); }