/// <summary> /// Creates a new restore point /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The output entity</returns> protected override IEnumerable <AzureSqlDatabaseRestorePointModel> PersistChanges(IEnumerable <AzureSqlDatabaseRestorePointModel> entity) { return(ModelAdapter.NewRestorePoint(entity)); }
/// <summary> /// No changes to persist to server /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlElasticPoolModel> PersistChanges(IEnumerable <AzureSqlElasticPoolModel> entity) { ModelAdapter.RemoveElasticPool(this.ResourceGroupName, this.ServerName, this.ElasticPoolName); return(entity); }
protected override AzureSqlManagedDatabaseRestoreDetailsResultModel GetEntity() { return(ModelAdapter.GetManagedDatabaseLogReplay(ResourceGroupName, InstanceName, Name)); }
/// <summary> /// No changes to persist to Azure SQL Server /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureReplicationLinkModel> PersistChanges(IEnumerable <AzureReplicationLinkModel> entity) { ModelAdapter.RemoveLink(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.PartnerResourceGroupName, this.PartnerServerName); return(entity); }
/// <summary> /// Provides the model element that this cmdlet operates on /// </summary> /// <returns>A model object</returns> protected override DatabaseDataMaskingPolicyModel GetEntity() { return(ModelAdapter.GetDatabaseDataMaskingPolicy(ResourceGroupName, ServerName, DatabaseName)); }
/// <summary> /// Create the model from user input /// </summary> /// <param name="model">Model retrieved from service</param> /// <returns>The model that was passed in</returns> protected override IEnumerable <AzureSqlDatabaseModel> ApplyUserInputToModel(IEnumerable <AzureSqlDatabaseModel> model) { List <Model.AzureSqlDatabaseModel> newEntity = new List <AzureSqlDatabaseModel>(); AzureSqlDatabaseModel newDbModel = new AzureSqlDatabaseModel() { ResourceGroupName = ResourceGroupName, ServerName = ServerName, DatabaseName = DatabaseName, MaxSizeBytes = MaxSizeBytes, Tags = TagsConversionHelper.ReadOrFetchTags(this, model.FirstOrDefault().Tags), ElasticPoolName = ElasticPoolName, Location = model.FirstOrDefault().Location, ReadScale = ReadScale, ZoneRedundant = ZoneRedundant != null ? (bool?)ZoneRedundant.ToBool() : null, LicenseType = LicenseType ?? model.FirstOrDefault().LicenseType, // set to original license type AutoPauseDelayInMinutes = MyInvocation.BoundParameters.ContainsKey("AutoPauseDelayInMinutes") ? AutoPauseDelayInMinutes : (int?)null, MinimumCapacity = MyInvocation.BoundParameters.ContainsKey("MinimumCapacity") ? MinimumCapacity : (double?)null, }; var database = ModelAdapter.GetDatabase(ResourceGroupName, ServerName, DatabaseName); Management.Sql.Models.Sku databaseCurrentSku = new Management.Sql.Models.Sku() { Name = database.SkuName, Tier = database.Edition, Family = database.Family, Capacity = database.Capacity }; // check if current db is serverless string databaseCurrentComputeModel = database.CurrentServiceObjectiveName.Contains("_S_") ? DatabaseComputeModel.Serverless : DatabaseComputeModel.Provisioned; if (this.ParameterSetName == UpdateParameterSetName) { newDbModel.SkuName = string.IsNullOrWhiteSpace(RequestedServiceObjectiveName) ? AzureSqlDatabaseAdapter.GetDatabaseSkuName(Edition) : RequestedServiceObjectiveName; newDbModel.Edition = Edition; newEntity.Add(newDbModel); } else if (this.ParameterSetName == VcoreDatabaseParameterSet) { if (!string.IsNullOrWhiteSpace(Edition) || !string.IsNullOrWhiteSpace(ComputeGeneration) || MyInvocation.BoundParameters.ContainsKey("VCore")) { string skuTier = string.IsNullOrWhiteSpace(Edition) ? databaseCurrentSku.Tier : Edition; string requestedComputeModel = string.IsNullOrWhiteSpace(ComputeModel) ? databaseCurrentComputeModel : ComputeModel; newDbModel.SkuName = AzureSqlDatabaseAdapter.GetDatabaseSkuName(skuTier, requestedComputeModel == DatabaseComputeModel.Serverless); newDbModel.Edition = skuTier; newDbModel.Family = string.IsNullOrWhiteSpace(ComputeGeneration) ? databaseCurrentSku.Family : ComputeGeneration; newDbModel.Capacity = MyInvocation.BoundParameters.ContainsKey("VCore") ? VCore : databaseCurrentSku.Capacity; } newEntity.Add(newDbModel); } return(newEntity); }
/// <summary> /// Provides the model element that this cmdlet operates on /// </summary> /// <returns>A model object</returns> protected override DatabaseSecureConnectionPolicyModel GetEntity() { return(ModelAdapter.GetDatabaseSecureConnectionPolicy(ResourceGroupName, ServerName, DatabaseName, clientRequestId)); }
/// <summary> /// No sending is needed as this is a convert cmdlet /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override DatabaseVulnerabilityAssessmentScanExportModel PersistChanges(DatabaseVulnerabilityAssessmentScanExportModel model) { return(ModelAdapter.ConvertDatabaseVulnerabilityAssessmentScan(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.ScanId)); }
/// <summary> /// Send the restore request /// </summary> /// <returns>The list of entities</returns> protected override AzureSqlManagedDatabaseModel GetEntity() { AzureSqlManagedDatabaseModel model = new AzureSqlManagedDatabaseModel() { CreateMode = "PointInTimeRestore", Name = TargetInstanceDatabaseName, RestorePointInTime = PointInTime, }; switch (ParameterSetName) { case PointInTimeDeletedDatabasesCrossInstanceRestoreFromNameAndResourceGroupParameterSet: case PointInTimeDeletedDatabasesSameInstanceRestoreFromNameAndResourceGroupParameterSet: model.RestorableDroppedDatabaseId = ModelAdapter.GetDeletedManagedDatabaseResourceId(this.ResourceGroupName, this.InstanceName, this.Name + "," + this.DeletionDate.ToFileTimeUtc()); break; case PointInTimeCrossInstanceRestoreFromNameAndResourceGroupParameterSet: case PointInTimeSameInstanceRestoreFromNameAndResourceGroupParameterSet: model.SourceDatabaseId = ModelAdapter.GetManagedDatabaseResourceId(this.ResourceGroupName, this.InstanceName, this.Name); break; case PointInTimeSameInstanceRestoreFromInputObjectParameterSet: case PointInTimeCrossInstanceRestoreFromInputObjectParameterSet: ResourceGroupName = InputObject.ResourceGroupName; InstanceName = InputObject.ManagedInstanceName; if (InputObject is AzureSqlDeletedManagedDatabaseBackupModel) { model.RestorableDroppedDatabaseId = InputObject.Id; } else { model.SourceDatabaseId = InputObject.Id; } break; case PointInTimeSameInstanceRestoreFromResourceIdParameterSet: case PointInTimeCrossInstanceRestoreFromResourceIdParameterSet: var resourceInfo = new ResourceIdentifier(ResourceId); ResourceGroupName = resourceInfo.ResourceGroupName; InstanceName = resourceInfo.ParentResource.Split(new[] { '/' })[1]; if (resourceInfo.ResourceType.Equals("Microsoft.Sql/managedInstances/restorableDroppedDatabases", StringComparison.InvariantCulture)) { model.RestorableDroppedDatabaseId = ResourceId; } else { model.SourceDatabaseId = ResourceId; } break; case GeoRestoreFromGeoBackupSetNameFromGeoBackupObjectParameterSet: ResourceGroupName = GeoBackupObject.ResourceGroupName; InstanceName = GeoBackupObject.ManagedInstanceName; model.RecoverableDatabaseId = GeoBackupObject.Id; model.CreateMode = "Recovery"; model.RestorePointInTime = null; break; case GeoRestoreFromGeoBackupSetNameFromNameAndResourceGroupParameterSet: model.RecoverableDatabaseId = "/subscriptions/" + ModelAdapter.Context.Subscription.Id + "/resourceGroups/" + ResourceGroupName + "/providers/Microsoft.Sql/managedInstances/" + InstanceName + "/recoverableDatabases/" + Name; model.CreateMode = "Recovery"; model.RestorePointInTime = null; break; case GeoRestoreFromGeoBackupSetNameFromResourceIdParameterSet: model.CreateMode = "Recovery"; model.RecoverableDatabaseId = ResourceId; model.RestorePointInTime = null; break; default: throw new ArgumentException("No ParameterSet name"); } if (String.IsNullOrEmpty(TargetInstanceName)) { TargetInstanceName = InstanceName; } if (String.IsNullOrEmpty(TargetResourceGroupName)) { TargetResourceGroupName = ResourceGroupName; } model.ManagedInstanceName = TargetInstanceName; model.ResourceGroupName = TargetResourceGroupName; model.Location = ModelAdapter.GetManagedInstanceLocation(model.ResourceGroupName, model.ManagedInstanceName); return(ModelAdapter.RestoreManagedDatabase(model)); }
/// <summary> /// Create the model from user input /// </summary> /// <param name="model">Model retrieved from service</param> /// <returns>The model that was passed in</returns> protected override IEnumerable <AzureSqlElasticPoolModel> ApplyUserInputToModel(IEnumerable <AzureSqlElasticPoolModel> model) { string location = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName); List <AzureSqlElasticPoolModel> newEntity = new List <AzureSqlElasticPoolModel>(); AzureSqlElasticPoolModel newModel = new AzureSqlElasticPoolModel() { ResourceGroupName = ResourceGroupName, ServerName = ServerName, ElasticPoolName = ElasticPoolName, Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true), Location = location, ZoneRedundant = MyInvocation.BoundParameters.ContainsKey("ZoneRedundant") ? (bool?)ZoneRedundant.ToBool() : null, MaxSizeBytes = MyInvocation.BoundParameters.ContainsKey("StorageMB") ? (long?)(StorageMB * Megabytes) : null }; var elasticPool = ModelAdapter.GetElasticPool(ResourceGroupName, ServerName, ElasticPoolName); Management.Sql.Models.Sku poolCurrentSku = new Management.Sql.Models.Sku() { Name = elasticPool.SkuName, Tier = elasticPool.Edition, Family = elasticPool.Family, Capacity = elasticPool.Capacity }; Management.Sql.Models.ElasticPoolPerDatabaseSettings poolCurrentDbSetting = new Management.Sql.Models.ElasticPoolPerDatabaseSettings() { MinCapacity = elasticPool.DatabaseCapacityMin, MaxCapacity = elasticPool.DatabaseCapacityMax }; if (ParameterSetName == DtuPoolParameterSet) { if (!string.IsNullOrWhiteSpace(Edition) || MyInvocation.BoundParameters.ContainsKey("Dtu")) { string edition = string.IsNullOrWhiteSpace(Edition) ? poolCurrentSku.Tier : Edition; newModel.SkuName = AzureSqlElasticPoolAdapter.GetPoolSkuName(edition); newModel.Edition = edition; newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("Dtu") ? (int?)Dtu : null; } if (MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax")) { newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") ? (double?)DatabaseDtuMin : null; newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null; } } else { if (!string.IsNullOrWhiteSpace(Edition) || MyInvocation.BoundParameters.ContainsKey("VCore") || !string.IsNullOrWhiteSpace(ComputeGeneration)) { string skuTier = string.IsNullOrWhiteSpace(Edition) ? poolCurrentSku.Tier : Edition; newModel.SkuName = AzureSqlElasticPoolAdapter.GetPoolSkuName(skuTier); newModel.Edition = skuTier; newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("VCore") ? VCore : poolCurrentSku.Capacity; newModel.Family = string.IsNullOrWhiteSpace(ComputeGeneration) ? poolCurrentSku.Family : ComputeGeneration; } if (MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax")) { newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") ? (double?)DatabaseVCoreMin : null; newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax") ? (double?)DatabaseVCoreMax : null; } } newEntity.Add(newModel); return(newEntity); }
/// <summary> /// This method is responsible to call the right API in the communication layer that will eventually send the information in the /// object to the REST endpoint /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override DatabaseAuditingPolicyModel PersistChanges(DatabaseAuditingPolicyModel model) { ModelAdapter.SetDatabaseAuditingPolicy(model, clientRequestId, DefaultContext.Environment.Endpoints[AzureEnvironment.Endpoint.StorageEndpointSuffix]); return(null); }
/// <summary> /// This method is responsible to call the right API in the communication layer that will eventually send the information in the /// object to the REST endpoint /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override DatabaseThreatDetectionPolicyModel PersistChanges(DatabaseThreatDetectionPolicyModel model) { ModelAdapter.SetDatabaseThreatDetectionPolicy(model, clientRequestId, DefaultContext.Environment.GetEndpoint(AzureEnvironment.Endpoint.StorageEndpointSuffix)); return(null); }
protected override SqlPoolSensitivityClassificationModel PersistChanges(SqlPoolSensitivityClassificationModel entity) { ModelAdapter.DisableSensitivityRecommendations(entity); return(null); }
/// <summary> /// No changes to persist to server /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlServerActiveDirectoryAdministratorModel> PersistChanges(IEnumerable <AzureSqlServerActiveDirectoryAdministratorModel> entity) { ModelAdapter.RemoveServerActiveDirectoryAdministrator(this.ResourceGroupName, this.ServerName); return(entity); }
/// <summary> /// This method is responsible to call the right API in the communication layer that will eventually send the information in the /// object to the REST endpoint /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override IEnumerable <DatabaseDataMaskingRuleModel> PersistChanges(IEnumerable <DatabaseDataMaskingRuleModel> rules) { ModelAdapter.SetDatabaseDataMaskingRule(rules.First(r => r.RuleId == RuleId), clientRequestId); return(null); }
/// <summary> /// Get the entities from the service /// </summary> /// <returns>The list of entities</returns> protected override IEnumerable <UpgradeRecommendedElasticPoolProperties> GetEntity() { return(ModelAdapter.ListRecommendedElasticPoolProperties(this.ResourceGroupName, this.ServerName)); }
/// <summary> /// Persist deletion /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlFailoverGroupModel> PersistChanges(IEnumerable <AzureSqlFailoverGroupModel> entity) { ModelAdapter.RemoveFailoverGroup(this.ResourceGroupName, this.ServerName, this.FailoverGroupName); return(entity); }
/// <summary> /// Преобразует значение поля из модели к виду, подлежащему преобразованию в хэш /// </summary> /// <param name="model"> /// Модель /// </param> /// <param name="binaryWriter"> /// The binary Writer. /// </param> public abstract void WriteField(ModelAdapter model, BinaryWriter binaryWriter);
/// <summary> /// Cancel the synchronization of the specified sync group. /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlSyncGroupModel> PersistChanges(IEnumerable <AzureSqlSyncGroupModel> entity) { ModelAdapter.StopSynchronization(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.SyncGroupName); return(entity); }
/// <summary> /// Deletes the mi link. /// </summary> /// <param name="entity">The link being deleted</param> /// <returns>The instance that was deleted</returns> protected override IEnumerable <AzureSqlManagedInstanceLinkModel> PersistChanges(IEnumerable <AzureSqlManagedInstanceLinkModel> entity) { ModelAdapter.RemoveManagedInstanceLink(ResourceGroupName, InstanceName, Name); return(entity); }
/// <summary> /// Sends the Firewall Rule update request to the service /// </summary> /// <param name="entity">The update parameters</param> /// <returns>The response object from the service</returns> protected override IEnumerable <Model.AzureRmSqlServerTransparentDataEncryptionCertificateModel> PersistChanges(IEnumerable <Model.AzureRmSqlServerTransparentDataEncryptionCertificateModel> entity) { ModelAdapter.AddAzureRmSqlServerTransparentDataEncryptionCertificate(entity.First()); return(entity); }
} // intentionally overriding the parent's Masking function property, to defined it here as a mandatory property /// <summary> /// Provides the model element that this cmdlet operates on /// </summary> /// <returns>A model object</returns> protected override IEnumerable <DatabaseDataMaskingRuleModel> GetEntity() { return(ModelAdapter.GetDatabaseDataMaskingRules(ResourceGroupName, ServerName, DatabaseName, clientRequestId)); }
/// <summary> /// Gets a Transparent Data Encryption Acitvity for the database. /// </summary> /// <returns>A single Transparent Data Encryption</returns> protected override IEnumerable <AzureSqlDatabaseTransparentDataEncryptionActivityModel> GetEntity() { return(ModelAdapter.ListTransparentDataEncryptionActivity(this.ResourceGroupName, this.ServerName, this.DatabaseName)); }
/// <summary> /// No changes to persist to server /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlDatabaseModel> PersistChanges(IEnumerable <AzureSqlDatabaseModel> entity) { ModelAdapter.FailoverDatabase(this.ResourceGroupName, this.ServerName, this.DatabaseName); return(entity); }
/// <summary> /// This method is responsible to call the right API in the communication layer that will eventually send the information in the /// object to the REST endpoint /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override DatabaseDataMaskingPolicyModel PersistChanges(DatabaseDataMaskingPolicyModel model) { ModelAdapter.SetDatabaseDataMaskingPolicy(model); return(null); }
/// <summary> /// Get the entities from the service /// </summary> /// <returns>The list of entities</returns> protected override IEnumerable <AzureReplicationLinkModel> GetEntity() { return(ModelAdapter.ListLinks(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.PartnerResourceGroupName)); }
/// <summary> /// Deletes the allowed FQDN from the list of outbound firewall rules for a Azure Sql Database Server. /// </summary> /// <param name="entity">The server being deleted</param> /// <returns>The server that was deleted</returns> protected override IEnumerable <Model.AzureSqlServerOutboundFirewallRulesModel> PersistChanges(IEnumerable <Model.AzureSqlServerOutboundFirewallRulesModel> entity) { ModelAdapter.RemoveFirewallRule(this.ResourceGroupName, this.ServerName, this.AllowedFQDN); return(entity); }
/// <summary> /// Deletes the server. /// </summary> /// <param name="entity">The server being deleted</param> /// <returns>The server that was deleted</returns> protected override IEnumerable <Model.AzureSqlServerModel> PersistChanges(IEnumerable <Model.AzureSqlServerModel> entity) { ModelAdapter.RemoveServer(this.ResourceGroupName, this.ServerName); return(entity); }
/// <summary> /// No changes to persist to server /// </summary> /// <param name="entity">The output of apply user input to model</param> /// <returns>The input entity</returns> protected override IEnumerable <AzureSqlServerDisasterRecoveryConfigurationModel> PersistChanges(IEnumerable <AzureSqlServerDisasterRecoveryConfigurationModel> entity) { ModelAdapter.RemoveServerDisasterRecoveryConfiguration(this.ResourceGroupName, this.ServerName, this.VirtualEndpointName); return(entity); }
/// <summary> /// Get the entities from the service /// </summary> /// <returns>The list of entities</returns> protected override IEnumerable <AzureSqlDatabaseRestorePointModel> GetEntity() { return(ModelAdapter.ListRestorePoints(this.ResourceGroupName, this.ServerName, this.DatabaseName)); }