/// <summary> /// Upserts a Transparent Data Encryption /// </summary> /// <param name="resourceGroup">The name of the resource group</param> /// <param name="serverName">The name of ther server</param> /// <param name="model">The Transparent Data Encryption to create</param> /// <returns>The updated server model</returns> public AzureSqlDatabaseTransparentDataEncryptionModel UpsertTransparentDataEncryption(AzureSqlDatabaseTransparentDataEncryptionModel model) { var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.ServerName, model.DatabaseName, Util.GenerateTracingId(), new TransparentDataEncryptionCreateOrUpdateParameters() { Properties = new TransparentDataEncryptionCreateOrUpdateProperties() { State = model.State.ToString(), } }); return CreateTransparentDataEncryptionModelFromResponse(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp); }
/// <summary> /// Convert a Management.Sql.Models.TransparentDataEncryption to AzureSqlDatabaseTransparentDataEncryptionModel /// </summary> /// <param name="resourceGroup">The resource group the server is in</param> /// <param name="serverName">The name of the server</param> /// <param name="resp">The management client server response to convert</param> /// <returns>The converted server model</returns> private static AzureSqlDatabaseTransparentDataEncryptionModel CreateTransparentDataEncryptionModelFromResponse(string resourceGroup, string serverName, string databaseName, Management.Sql.Models.TransparentDataEncryption resp) { AzureSqlDatabaseTransparentDataEncryptionModel TransparentDataEncryption = new AzureSqlDatabaseTransparentDataEncryptionModel(); TransparentDataEncryption.ResourceGroupName = resourceGroup; TransparentDataEncryption.ServerName = serverName; TransparentDataEncryption.DatabaseName = databaseName; TransparentDataEncryptionStateType State = TransparentDataEncryptionStateType.Disabled; Enum.TryParse<TransparentDataEncryptionStateType>(resp.Properties.State, true, out State); TransparentDataEncryption.State = State; return TransparentDataEncryption; }