示例#1
0
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            // validation of encryption parameters
            if (Encryption != null)
            {
                var identity = new EncryptionIdentity
                {
                    Type = EncryptionIdentityType.SystemAssigned,
                };
                var config = new EncryptionConfig
                {
                    Type = Encryption.Value,
                };

                if (Encryption.Value == EncryptionConfigType.UserManaged)
                {
                    if (string.IsNullOrEmpty(KeyVaultId) ||
                        string.IsNullOrEmpty(KeyName) ||
                        string.IsNullOrEmpty(KeyVersion))
                    {
                        throw new PSArgumentException(Resources.MissingKeyVaultParams);
                    }

                    config.KeyVaultMetaInfo = new KeyVaultMetaInfo
                    {
                        KeyVaultResourceId   = KeyVaultId,
                        EncryptionKeyName    = KeyName,
                        EncryptionKeyVersion = KeyVersion
                    };
                }
                else
                {
                    if (!string.IsNullOrEmpty(KeyVaultId) ||
                        !string.IsNullOrEmpty(KeyName) ||
                        !string.IsNullOrEmpty(KeyVersion))
                    {
                        WriteWarning(Resources.IgnoredKeyVaultParams);
                    }
                }

                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags, identity, config));
            }
            else
            {
                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
            }
        }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.EnableKeyVault, Account),
         Account,
         () => DataLakeStoreClient.EnableKeyVault(ResourceGroupName, Account));
 }
        public override void ExecuteCmdlet()
        {
            try
            {
                if (DataLakeStoreClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeStoreAccountExists, Name));
                }
            }
            catch (CloudException ex)
            {
                if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                    ex.Message.Contains("ResourceNotFound"))
                {
                    // account does not exists so go ahead and create one
                }
                else if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) &&
                         ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                {
                    // resource group not found, let create throw error don't throw from here
                }
                else
                {
                    // all other exceptions should be thrown
                    throw;
                }
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags));
        }
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            if (!TrustedIdProviderState.HasValue)
            {
                TrustedIdProviderState = currentAccount.TrustedIdProviderState;
            }

            if (!FirewallState.HasValue)
            {
                FirewallState = currentAccount.FirewallState;
            }

            WriteObject(new PSDataLakeStoreAccount(DataLakeStoreClient.UpdateAccount(ResourceGroupName, Name, DefaultGroup, TrustedIdProviderState.GetValueOrDefault(), FirewallState.GetValueOrDefault(), Tags)));
        }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.AddDataLakeVirtualNetworkRule, Name),
         Name,
         () =>
         WriteObject(new DataLakeStoreVirtualNetworkRule(DataLakeStoreClient.AddOrUpdateVirtualNetworkRule(
                                                             Account, Name, SubnetId, this)))
         );
 }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.AddDataLakeFirewallRule, Name),
         Name,
         () =>
         WriteObject(new DataLakeStoreFirewallRule(DataLakeStoreClient.AddOrUpdateFirewallRule(
                                                       ResourceGroupName, Account, Name, StartIpAddress, EndIpAddress, this)))
         );
 }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.SetDataLakeTrustedIdProvider, Name),
         Name,
         () =>
         WriteObject(new DataLakeStoreTrustedIdProvider(DataLakeStoreClient.AddOrUpdateTrustedProvider(
                                                            ResourceGroupName, Account, Name, ProviderEndpoint, this)))
         );
 }
示例#8
0
 public override void ExecuteCmdlet()
 {
     // get the current firewall rule
     if (string.IsNullOrEmpty(Name))
     {
         WriteObject(DataLakeStoreClient.ListFirewallRules(ResourceGroupName, Account)
                     .Select(element => new DataLakeStoreFirewallRule(element))
                     .ToList(), true);
     }
     else
     {
         WriteObject(new DataLakeStoreFirewallRule(DataLakeStoreClient.GetFirewallRule(ResourceGroupName, Account, Name)));
     }
 }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.RemoveDataLakeStoreFirewallRule, Name),
         Name,
         () =>
     {
         DataLakeStoreClient.DeleteFirewallRule(ResourceGroupName, Account, Name);
         if (PassThru)
         {
             WriteObject(true);
         }
     });
 }
示例#10
0
 public override void ExecuteCmdlet()
 {
     // get the current virtual network rule
     if (string.IsNullOrEmpty(Name))
     {
         WriteObject(DataLakeStoreClient.ListVirtualNetworkRules(Account)
                     .Select(element => new DataLakeStoreVirtualNetworkRule(element))
                     .ToList(), true);
     }
     else
     {
         WriteObject(new DataLakeStoreVirtualNetworkRule(DataLakeStoreClient.GetVirtualNetworkRule(Account, Name)));
     }
 }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.RemoveDataLakeStoreTrustedProvider, Name),
         Name,
         () =>
     {
         DataLakeStoreClient.DeleteTrustedProvider(ResourceGroupName, Account, Name, this);
         if (PassThru)
         {
             WriteObject(true);
         }
     });
 }
示例#12
0
 public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get for single account
         WriteObject(DataLakeStoreClient.GetAccount(ResourceGroupName, Name));
     }
     else
     {
         // List all accounts in given resource group if avaliable otherwise all accounts in the subscription
         var list = DataLakeStoreClient.ListAccounts(ResourceGroupName, null, null, null);
         WriteObject(list, true);
     }
 }
 public override void ExecuteCmdlet()
 {
     ConfirmAction(
         string.Format(Resources.RemoveDataLakeStoreVirtualNetworkRule, Name),
         Name,
         () =>
     {
         DataLakeStoreClient.DeleteVirtualNetworkRule(Account, Name, this);
         if (PassThru)
         {
             WriteObject(true);
         }
     });
 }
示例#14
0
 public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get for single account
         WriteObject(new PSDataLakeStoreAccount(DataLakeStoreClient.GetAccount(ResourceGroupName, Name)));
     }
     else
     {
         // List all accounts in given resource group if avaliable otherwise all accounts in the subscription
         WriteObject(DataLakeStoreClient.ListAccounts(ResourceGroupName, null, null, null)
                     .Select(element => new PSDataLakeStoreAccountBasic(element))
                     .ToList(), true);
     }
 }
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            if (!TrustedIdProviderState.HasValue)
            {
                TrustedIdProviderState = currentAccount.TrustedIdProviderState;
            }

            if (!FirewallState.HasValue)
            {
                FirewallState = currentAccount.FirewallState;
            }

            if (AllowAzureIpState.HasValue && FirewallState.Value == Management.DataLake.Store.Models.FirewallState.Disabled)
            {
                WriteWarning(string.Format(Resources.FirewallDisabledWarning, Name));
            }

            if (!AllowAzureIpState.HasValue)
            {
                AllowAzureIpState = currentAccount.FirewallAllowAzureIps;
            }

            WriteObject(
                new PSDataLakeStoreAccount(
                    DataLakeStoreClient.UpdateAccount(
                        ResourceGroupName,
                        Name,
                        DefaultGroup,
                        TrustedIdProviderState.GetValueOrDefault(),
                        FirewallState.GetValueOrDefault(),
                        AllowAzureIpState.GetValueOrDefault(),
                        Tags,
                        tier: Tier)));
        }
示例#16
0
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
        protected override void ProcessRecord()
        {
            // TODO: Define what can be updated for DataLakeStore accounts
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null || Tags.Length == 0)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
示例#18
0
 public override void ExecuteCmdlet()
 {
     try
     {
         DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
         WriteObject(true);
     }
     catch (CloudException e)
     {
         if (e.Response.StatusCode == HttpStatusCode.NotFound)
         {
             WriteObject(false);
         }
         else
         {
             throw;
         }
     }
 }
示例#19
0
 protected override void ProcessRecord()
 {
     try
     {
         DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
         WriteObject(true);
     }
     catch (CloudException e)
     {
         if (e.Response.StatusCode == HttpStatusCode.NotFound)
         {
             WriteObject(false);
         }
         else
         {
             throw;
         }
     }
 }
        public override void ExecuteCmdlet()
        {
            // get the current virtual network rule
            VirtualNetworkRule rule = DataLakeStoreClient.GetVirtualNetworkRule(Account, Name);

            if (rule == null)
            {
                throw new PSInvalidOperationException(string.Format(Resources.VirtualNetworkRuleNotFound, Name));
            }

            var subnetId = SubnetId ?? rule.SubnetId;

            ConfirmAction(
                string.Format(Resources.SetDataLakeVirtualNetworkRule, Name),
                Name,
                () =>
                WriteObject(new DataLakeStoreVirtualNetworkRule(DataLakeStoreClient.AddOrUpdateVirtualNetworkRule(
                                                                    Account, Name, subnetId, this)))
                );
        }
        public override void ExecuteCmdlet()
        {
            // get the current firewall rule
            var rule = DataLakeStoreClient.GetFirewallRule(ResourceGroupName, Account, Name);

            if (rule == null)
            {
                throw new PSInvalidOperationException(string.Format(Resources.FirewallRuleNotFound, Name));
            }

            var endIp   = EndIpAddress ?? rule.Properties.EndIpAddress;
            var startIp = StartIpAddress ?? rule.Properties.StartIpAddress;

            ConfirmAction(
                string.Format(Resources.SetDataLakeFirewallRule, Name),
                Name,
                () =>
                WriteObject(new DataLakeStoreFirewallRule(DataLakeStoreClient.AddOrUpdateFirewallRule(
                                                              ResourceGroupName, Account, Name, startIp, endIp)))
                );
        }
示例#22
0
        public override void ExecuteCmdlet()
        {
            if (!Force.IsPresent)
            {
                ConfirmAction(
                    Force.IsPresent,
                    string.Format(Resources.RemovingDataLakeStoreAccount, Name),
                    string.Format(Resources.RemoveDataLakeStoreAccount, Name),
                    Name,
                    () => DataLakeStoreClient.DeleteAccount(ResourceGroupName, Name));
            }
            else
            {
                DataLakeStoreClient.DeleteAccount(ResourceGroupName, Name);
            }

            if (PassThru)
            {
                WriteObject(true);
            }
        }
示例#23
0
        public override void ExecuteCmdlet()
        {
            if (Tags != null && Tags.Length > 0)
            {
                WriteWarningWithTimestamp(Properties.Resources.TagsWarning);
            }

            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null || Tags.Length == 0)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
 public override void ExecuteCmdlet()
 {
     WriteObject(DataLakeStoreClient.TestAccount(ResourceGroupName, Name));
 }
示例#25
0
        public override void ExecuteCmdlet()
        {
            try
            {
                if (DataLakeStoreClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeStoreAccountExists, Name));
                }
            }
            catch (CloudException ex)
            {
                if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                    ex.Message.Contains("ResourceNotFound"))
                {
                    // account does not exists so go ahead and create one
                }
                else if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) &&
                         ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                {
                    // resource group not found, let create throw error don't throw from here
                }
                else
                {
                    // all other exceptions should be thrown
                    throw;
                }
            }

            // validation of encryption parameters
            if (Encryption != null)
            {
                var identity = new EncryptionIdentity
                {
                    Type = EncryptionIdentityType.SystemAssigned,
                };
                var config = new EncryptionConfig
                {
                    Type = Encryption.Value,
                };

                if (Encryption.Value == EncryptionConfigType.UserManaged)
                {
                    if (string.IsNullOrEmpty(KeyVaultId) ||
                        string.IsNullOrEmpty(KeyName) ||
                        string.IsNullOrEmpty(KeyVersion))
                    {
                        throw new PSArgumentException(Resources.MissingKeyVaultParams);
                    }

                    config.KeyVaultMetaInfo = new KeyVaultMetaInfo
                    {
                        KeyVaultResourceId   = KeyVaultId,
                        EncryptionKeyName    = KeyName,
                        EncryptionKeyVersion = KeyVersion
                    };
                }
                else
                {
                    if (!string.IsNullOrEmpty(KeyVaultId) ||
                        !string.IsNullOrEmpty(KeyName) ||
                        !string.IsNullOrEmpty(KeyVersion))
                    {
                        WriteWarning(Resources.IgnoredKeyVaultParams);
                    }
                }

                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags, identity, config));
            }
            else
            {
                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags));
            }
        }
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            if (!TrustedIdProviderState.HasValue)
            {
                TrustedIdProviderState = currentAccount.TrustedIdProviderState;
            }

            if (!FirewallState.HasValue)
            {
                FirewallState = currentAccount.FirewallState;
            }

            if (AllowAzureIpState.HasValue && FirewallState.Value == Management.DataLake.Store.Models.FirewallState.Disabled)
            {
                WriteWarning(string.Format(Resources.FirewallDisabledWarning, Name));
            }

            if (!AllowAzureIpState.HasValue)
            {
                AllowAzureIpState = currentAccount.FirewallAllowAzureIps;
            }

            UpdateEncryptionConfig updateConfig = null;

            if (!string.IsNullOrEmpty(KeyVersion))
            {
                if (currentAccount.EncryptionConfig.Type == EncryptionConfigType.ServiceManaged)
                {
                    throw new ArgumentException(Resources.IncorrectEncryptionTypeForUpdate);
                }

                updateConfig = new UpdateEncryptionConfig
                {
                    KeyVaultMetaInfo = new UpdateKeyVaultMetaInfo
                    {
                        EncryptionKeyVersion = KeyVersion
                    }
                };
            }

            WriteObject(
                new PSDataLakeStoreAccount(
                    DataLakeStoreClient.UpdateAccount(
                        ResourceGroupName,
                        Name,
                        DefaultGroup,
                        TrustedIdProviderState.GetValueOrDefault(),
                        FirewallState.GetValueOrDefault(),
                        AllowAzureIpState.GetValueOrDefault(),
                        Tags,
                        tier: Tier,
                        userConfig: updateConfig)));
        }