protected IPrivateLinkProvider BuildProvider(string subscription, string privateLinkResourceType) { if (!GenericProvider.SupportsPrivateLinkFeature(privateLinkResourceType)) { throw new AzPSApplicationException(string.Format(Properties.Resources.UnsupportPrivateEndpointConnectionType, privateLinkResourceType)); } return(PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, subscription, privateLinkResourceType)); }
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.SupportsPrivateLinkFeature(privateLinkResourceType)) { return(new GenericProvider(cmdlet, subscription, privateLinkResourceType)); } switch (privateLinkResourceType.ToLower()) { case NETWORKING_TYPE: default: provider = new NetworkingProvider(cmdlet); break; } return(provider); }