public override void ExecuteCmdlet() { if (ShouldProcess(this.Name, Resources.stopService)) { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.Name = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.Name = ids.ServiceName; } bool result = false; try { DataMigrationClient.Services.StopWithHttpMessagesAsync(ResourceGroupName, Name).GetAwaiter().GetResult(); result = true; } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } if (PassThru.IsPresent) { WriteObject(result); } } }
public PSDataMigrationService(DataMigrationService service) { if (service == null) { throw new ArgumentNullException("service"); } this.service = service; this.ids = new DmsResourceIdentifier(service.Id); this.ResourceGroupName = ids.ResourceGroupName; }
public PSProject(Project project) { if (project == null) { throw new ArgumentNullException("project"); } this.project = project; this.ids = new DmsResourceIdentifier(project.Id); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; }
public override void ExecuteCmdlet() { if (taskCmdlet != null) { if (ShouldProcess(this.Name, Resources.createTask)) { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; } ProjectTask response = null; try { ProjectTaskProperties properties = taskCmdlet.ProcessTaskCmdlet(); var utcStartedOn = System.DateTime.UtcNow; ProjectTask taskInput = new ProjectTask { Properties = properties }; response = DataMigrationClient.ServiceTasks.CreateOrUpdate(taskInput, ResourceGroupName, ServiceName, Name); // wait for the task to finish: not queued or running state: while (this.Wait.IsPresent && response != null && response.Properties != null && (response.Properties.State == "Queued" || response.Properties.State == "Running")) { System.Threading.Thread.Sleep(System.TimeSpan.FromSeconds(TaskWaitSleepIntervalInSeconds)); WriteVerbose($"{response.Id} {response.Name} {response.Properties.State} Elapsed: {System.DateTime.UtcNow - utcStartedOn}"); response = DataMigrationClient.ServiceTasks.Get(ResourceGroupName, ServiceName, Name, this.expandParameterOfTask); } } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } WriteObject(new PSProjectTask(response)); } } else { throw new PSArgumentException("Invalid Argument List"); } }
public PSProjectTask(ProjectTask task) { if (task == null) { throw new ArgumentNullException("project"); } this.task = task; this.ids = new DmsResourceIdentifier(task.Id); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; this.ProjectName = ids.ProjectName; }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.Name = ids.ServiceName; } IList <PSDataMigrationService> results = new List <PSDataMigrationService>(); if ((MyInvocation.BoundParameters.ContainsKey("Name") || !string.IsNullOrEmpty(Name)) && (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(ResourceGroupName))) { results.Add(new PSDataMigrationService(DataMigrationClient.Services.Get(this.ResourceGroupName, this.Name))); } else if (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(ResourceGroupName)) { DataMigrationClient.Services.EnumerateServicesByResouceGroup(ResourceGroupName) .ForEach(item => { results.Add(new PSDataMigrationService(item)); }); } else if (!MyInvocation.BoundParameters.ContainsKey("Name") || string.IsNullOrEmpty(Name)) { DataMigrationClient.Services.EnumerateServicesBySubcription() .ForEach(item => { results.Add(new PSDataMigrationService(item)); }); } else { throw new PSArgumentException("When specifying the ServiceName parameter the ResourceGroup parameter must also be used"); } foreach (var item in results) { if (DmsConstants.DeprecatingSkuNames.Contains(item.Service.Sku.Size)) { WriteWarning(string.Format(Resources.SKUDeprecationWarningMessage, item.Service.Sku.Size, item.Service.Name)); } } WriteObject(results, true); }
public override void ExecuteCmdlet() { if (taskCmdlet != null) { if (ShouldProcess(this.Name, Resources.createTask)) { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.ServiceName; this.ProjectName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; this.ProjectName = ids.ProjectName; } ProjectTask response = null; try { ProjectTask taskInput = new ProjectTask() { Properties = taskCmdlet.ProcessTaskCmdlet() }; response = DataMigrationClient.Tasks.CreateOrUpdate(taskInput, ResourceGroupName, ServiceName, ProjectName, Name); } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } WriteObject(new PSProjectTask(response)); } } else { throw new PSArgumentException("Invalid Argument List"); } }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.ServiceName; this.ProjectName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; this.ProjectName = ids.ProjectName; } IList <PSProjectTask> results = new List <PSProjectTask>(); if ((MyInvocation.BoundParameters.ContainsKey("ServiceName") || !string.IsNullOrEmpty(this.ServiceName)) && (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(this.ResourceGroupName)) && (MyInvocation.BoundParameters.ContainsKey("ProjectName") || !string.IsNullOrEmpty(this.ProjectName)) && (MyInvocation.BoundParameters.ContainsKey("Name") || !string.IsNullOrEmpty(this.Name))) { results.Add(new PSProjectTask(DataMigrationClient.Tasks.Get(this.ResourceGroupName, this.ServiceName, this.ProjectName, this.Name, this.ExpandFilter()))); } else if ((MyInvocation.BoundParameters.ContainsKey("ServiceName") || !string.IsNullOrEmpty(this.ServiceName)) && (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(this.ResourceGroupName)) && (MyInvocation.BoundParameters.ContainsKey("ProjectName") || !string.IsNullOrEmpty(this.ProjectName))) { string taskType = TaskType?.ToString(); DataMigrationClient.Tasks.EnumerateTaskByProjects(ResourceGroupName, ServiceName, ProjectName, taskType) .ForEach(item => { results.Add(new PSProjectTask(item)); }); } else { throw new PSArgumentException("Invalid Argument List"); } WriteObject(results, true); }
public override void ExecuteCmdlet() { ConfirmAction(Force.IsPresent, string.Format(Resources.removingTask, Name), Resources.removeTask, Name, () => { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.ServiceName; this.ProjectName = InputObject.ProjectName; this.Name = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; this.ProjectName = ids.ProjectName; this.Name = ids.TaskName; } bool result = false; try { DataMigrationClient.Tasks.DeleteWithHttpMessagesAsync(ResourceGroupName, ServiceName, ProjectName, Name).GetAwaiter().GetResult(); result = true; } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } if (PassThru.IsPresent) { WriteObject(result); } }); }
public override void ExecuteCmdlet() { if (ShouldProcess(this.Name, Resources.createProject)) { base.ExecuteCmdlet(); if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; } WriteObject(new PSProject(CreateProject())); } }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; } IList <PSProject> results = new List <PSProject>(); if ((MyInvocation.BoundParameters.ContainsKey("ServiceName") || !string.IsNullOrEmpty(ServiceName)) && (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(ResourceGroupName)) && (MyInvocation.BoundParameters.ContainsKey("Name") || !string.IsNullOrEmpty(Name))) { results.Add(new PSProject(DataMigrationClient.Projects.Get(this.ResourceGroupName, this.ServiceName, this.Name))); } else if ((MyInvocation.BoundParameters.ContainsKey("ServiceName") || !string.IsNullOrEmpty(ServiceName)) && (MyInvocation.BoundParameters.ContainsKey("ResourceGroupName") || !string.IsNullOrEmpty(ResourceGroupName))) { DataMigrationClient.Projects.EnumerateProjects(ResourceGroupName, ServiceName) .ForEach(item => { results.Add(new PSProject(item)); }); } else { throw new PSArgumentException("When specifying the ServiceName parameter the ResourceGroup parameter must also be used"); } WriteObject(results, true); }
public override void ExecuteCmdlet() { if (taskCmdlet != null) { if (ShouldProcess(this.Name, Resources.createTask)) { if (this.ParameterSetName.Equals(ComponentObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroupName; this.ServiceName = InputObject.ServiceName; this.ProjectName = InputObject.Name; } if (this.ParameterSetName.Equals(ResourceIdParameterSet)) { DmsResourceIdentifier ids = new DmsResourceIdentifier(this.ResourceId); this.ResourceGroupName = ids.ResourceGroupName; this.ServiceName = ids.ServiceName; this.ProjectName = ids.ProjectName; } ProjectTask response = null; try { ProjectTaskProperties properties = taskCmdlet.ProcessTaskCmdlet(); var utcStartedOn = System.DateTime.UtcNow; // need swagger of -pr line 64 of tasks.json add. // uncomment the following line once we get new sdk. // give all tasks a start time, so that portal can calculate how long it is running. // properties.ClientData.Add("startedOn", utcStartedOn.ToString("o")); ProjectTask taskInput = new ProjectTask() { Properties = properties }; response = DataMigrationClient.Tasks.CreateOrUpdate(taskInput, ResourceGroupName, ServiceName, ProjectName, Name); // wait for the task to finish: not queued or running state: while (this.Wait.IsPresent && response != null && response.Properties != null && (response.Properties.State == "Queued" || response.Properties.State == "Running")) { System.Threading.Thread.Sleep(System.TimeSpan.FromSeconds(TaskWaitSleepIntervalInSeconds)); WriteVerbose($"{taskInput.Id} {taskInput.Name} {taskInput.Properties.State} Elapsed: {System.DateTime.UtcNow - utcStartedOn}"); response = DataMigrationClient.Tasks.Get(ResourceGroupName, ServiceName, ProjectName, Name, this.expandParameterOfTask); } } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } WriteObject(new PSProjectTask(response)); } } else { throw new PSArgumentException("Invalid Argument List"); } }