/// <summary> /// Provides the cmdlet model representation of a specific database secure connection policy /// </summary> public DatabaseSecureConnectionPolicyModel GetDatabaseSecureConnectionPolicy(string resourceGroup, string serverName, string databaseName) { DatabaseSecureConnectionPolicy policy = Communicator.GetDatabaseSecureConnectionPolicy(resourceGroup, serverName, databaseName); DatabaseSecureConnectionPolicyModel dbPolicyModel = ModelizeDatabaseSecureConnectionPolicy(policy); dbPolicyModel.ResourceGroupName = resourceGroup; dbPolicyModel.ServerName = serverName; dbPolicyModel.DatabaseName = databaseName; return(dbPolicyModel); }
/// <summary> /// Transforms a secure connection policy object to its cmdlet model representation /// </summary> private DatabaseSecureConnectionPolicyModel ModelizeDatabaseSecureConnectionPolicy(DatabaseSecureConnectionPolicy policy) { DatabaseSecureConnectionPolicyModel dbPolicyModel = new DatabaseSecureConnectionPolicyModel(); DatabaseSecureConnectionPolicyProperties properties = policy.Properties; dbPolicyModel.ProxyDnsName = properties.ProxyDnsName; dbPolicyModel.ProxyPort = properties.ProxyPort; dbPolicyModel.SecureConnectionState = properties.SecurityEnabledAccess == SecurityConstants.SecureConnectionEndpoint.Required ? SecureConnectionStateType.Required : SecureConnectionStateType.Optional; return(dbPolicyModel); }
/// <summary> /// Sets the secure connection policy of a specific database based on the information provided by the model object /// </summary> public void SetDatabaseSecureConnectionPolicy(DatabaseSecureConnectionPolicyModel model, String clientId) { SecureConnectionPolicyCreateOrUpdateParameters parameters = PolicizeDatabaseSecureConnectionModel(model); Communicator.SetDatabaseSecureConnectionPolicy(model.ResourceGroupName, model.ServerName, model.DatabaseName, clientId, parameters); }
/// <summary> /// Takes the cmdlets model object and transform it to the policy as expected by the endpoint /// </summary> /// <param name="policy">The Secure Connection Policy object</param> /// <returns>The communication model object</returns> private SecureConnectionPolicyCreateOrUpdateParameters PolicizeDatabaseSecureConnectionModel(DatabaseSecureConnectionPolicyModel model) { SecureConnectionPolicyCreateOrUpdateParameters updateParameters = new SecureConnectionPolicyCreateOrUpdateParameters(); SecureConnectionPolicyCreateOrUpdateProperties properties = new SecureConnectionPolicyCreateOrUpdateProperties(); updateParameters.Properties = properties; properties.SecurityEnabledAccess = model.SecureConnectionState == SecureConnectionStateType.Required ? Constants.SecureConnectionEndpoint.Required : Constants.SecureConnectionEndpoint.Optional; return(updateParameters); }
/// <summary> /// No sending is needed as this is a Get cmdlet /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override DatabaseSecureConnectionPolicyModel PersistChanges(DatabaseSecureConnectionPolicyModel model) { return(null); }
/// <summary> /// Updates the given model element with the cmdlet specific operation /// </summary> /// <param name="model">A model object</param> protected override DatabaseSecureConnectionPolicyModel UpdateModel(DatabaseSecureConnectionPolicyModel model) { model.SecureConnectionState = SecureConnectionStateType.Required; return(model); }
/// <summary> /// Updates the given model element with the cmdlet specific operation /// </summary> /// <param name="model">A model object</param> protected override DatabaseSecureConnectionPolicyModel ApplyUserInputToModel(DatabaseSecureConnectionPolicyModel model) { WriteWarning(string.Format(Resources.DeprecatedCmdletUsageWarning, "Enable-AzureSqlDatabaseDirectAccess")); model.SecureConnectionState = SecureConnectionStateType.Optional; return model; }
/// <summary> /// Updates the given model element with the cmdlet specific operation /// </summary> /// <param name="model">A model object</param> protected override DatabaseSecureConnectionPolicyModel ApplyUserInputToModel(DatabaseSecureConnectionPolicyModel model) { model.SecureConnectionState = SecureConnectionStateType.Optional; return(model); }
/// <summary> /// No sending is needed as this is a Get cmdlet /// </summary> /// <param name="model">The model object with the data to be sent to the REST endpoints</param> protected override void SendModel(DatabaseSecureConnectionPolicyModel model) { }