/// <summary> /// Update a sync group /// </summary> /// <param name="model">AzureSqlSyncGroupModel object</param> /// <returns>Updated AzureSqlSyncGroupModel object</returns> internal AzureSqlSyncGroupModel UpdateSyncGroup(AzureSqlSyncGroupModel model) { var updateResp = Communicator.UpdateSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, new Management.Sql.Models.SyncGroup() { Interval = model.IntervalInSeconds, HubDatabaseUserName = model.HubDatabaseUserName, HubDatabasePassword = model.HubDatabasePassword == null ? null: AzureSqlServerAdapter.Decrypt(model.HubDatabasePassword), Schema = model.Schema == null ? null : model.Schema.ToSyncGroupSchema(), UsePrivateLinkConnection = model.UsePrivateLinkConnection, }); // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed var resp = Communicator.GetSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName); return(CreateSyncGroupModelFromResponse(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp)); }
/// <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 <AzureSqlSyncGroupModel> ApplyUserInputToModel(IEnumerable <AzureSqlSyncGroupModel> model) { List <Model.AzureSqlSyncGroupModel> newEntity = new List <AzureSqlSyncGroupModel>(); AzureSqlSyncGroupModel newModel = new AzureSqlSyncGroupModel() { ResourceGroupName = this.ResourceGroupName, ServerName = this.ServerName, DatabaseName = this.DatabaseName, SyncGroupName = this.Name, ConflictResolutionPolicy = this.ConflictResolutionPolicy != null?this.ConflictResolutionPolicy.ToString() : null, HubDatabaseUserName = this.DatabaseCredential != null ? this.DatabaseCredential.UserName : null, HubDatabasePassword = this.DatabaseCredential != null ? this.DatabaseCredential.Password : null }; if (MyInvocation.BoundParameters.ContainsKey("IntervalInSeconds")) { newModel.IntervalInSeconds = this.IntervalInSeconds; } newModel.UsePrivateLinkConnection = UsePrivateLinkConnection.IsPresent; if (MyInvocation.BoundParameters.ContainsKey("SyncDatabaseResourceGroupName") && MyInvocation.BoundParameters.ContainsKey("SyncDatabaseServerName") && MyInvocation.BoundParameters.ContainsKey("SyncDatabaseName")) { this.syncDatabaseId = string.Format("resourceGroups/{0}/providers/Microsoft.Sql/servers/{1}/databases/{2}", this.SyncDatabaseResourceGroupName, this.SyncDatabaseServerName, this.SyncDatabaseName); } // if schema file is specified if (MyInvocation.BoundParameters.ContainsKey("SchemaFile")) { try { newModel.Schema = ConstructSchemaFromFile(this.SchemaFile); } catch (CloudException ex) { // There are problems with schema file throw new PSArgumentException(ex.Response.ToString(), "SchemaFile"); } } newEntity.Add(newModel); return(newEntity); }
/// <summary> /// Update a sync group /// </summary> /// <param name="model">AzureSqlSyncGroupModel object</param> /// <returns>Updated AzureSqlSyncGroupModel object</returns> internal AzureSqlSyncGroupModel UpdateSyncGroup(AzureSqlSyncGroupModel model) { var resp = Communicator.UpdateSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, new SyncGroupCreateOrUpdateParameters() { SyncGroupName = model.SyncGroupName, Properties = new SyncGroupCreateOrUpdateProperties { Interval = model.IntervalInSeconds, HubDatabaseUserName = model.HubDatabaseUserName, HubDatabasePassword = model.HubDatabasePassword == null ? null: AzureSqlServerAdapter.Decrypt(model.HubDatabasePassword), Schema = model.Schema == null ? null : model.Schema.ToSyncGroupSchema(), }, }); // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed resp = Communicator.GetSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName); return(CreateSyncGroupModelFromResponse(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp)); }
/// <summary> /// Create a sync group /// </summary> /// <param name="model">AzureSqlSyncGroupModel object</param> /// <returns>Created AzureSqlSyncGroupModel object</returns> internal AzureSqlSyncGroupModel CreateSyncGroup(AzureSqlSyncGroupModel model, string syncDatabaseId) { var resp = Communicator.CreateSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, syncDatabaseId, new SyncGroupCreateOrUpdateParameters() { SyncGroupName = model.SyncGroupName, Properties = new SyncGroupCreateOrUpdateProperties { ConflictResolutionPolicy = (ConflictResolutionPolicyType)(model.ConflictResolutionPolicy != null ? Enum.Parse(typeof(ConflictResolutionPolicyType), model.ConflictResolutionPolicy, true) : null), Interval = model.IntervalInSeconds, HubDatabaseUserName = model.HubDatabaseUserName, HubDatabasePassword = model.HubDatabasePassword == null ? null : AzureSqlServerAdapter.Decrypt(model.HubDatabasePassword), Schema = model.Schema == null ? null : model.Schema.ToSyncGroupSchema(), }, }); // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed resp = Communicator.GetSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName); return(CreateSyncGroupModelFromResponse(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp)); }
/// <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 <AzureSqlSyncGroupModel> ApplyUserInputToModel(IEnumerable <AzureSqlSyncGroupModel> model) { AzureSqlSyncGroupModel newModel = model.First(); if (MyInvocation.BoundParameters.ContainsKey("IntervalInSeconds")) { newModel.IntervalInSeconds = this.IntervalInSeconds; } if (MyInvocation.BoundParameters.ContainsKey(nameof(UsePrivateLinkConnection))) { newModel.UsePrivateLinkConnection = this.UsePrivateLinkConnection; } if (MyInvocation.BoundParameters.ContainsKey("DatabaseCredential")) { newModel.HubDatabaseUserName = this.DatabaseCredential.UserName; newModel.HubDatabasePassword = this.DatabaseCredential.Password; } else { newModel.HubDatabaseUserName = null; newModel.HubDatabasePassword = null; } // if schema file is specified if (MyInvocation.BoundParameters.ContainsKey("SchemaFile")) { try { newModel.Schema = ConstructSchemaFromFile(this.SchemaFile); } catch (CloudException ex) { // There are problems with schema file throw new PSArgumentException(ex.Response.ToString(), "SchemaFile"); } } return(model); }