public virtual PSPipeline CreatePSPipeline(CreatePSPipelineParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } PSPipeline pipeline = null; Action createPipeline = () => { pipeline = new PSPipeline(CreateOrUpdatePipeline(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name, parameters.RawJsonContent)) { ResourceGroupName = parameters.ResourceGroupName, DataFactoryName = parameters.DataFactoryName }; if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(pipeline.ProvisioningState)) { string errorMessage = pipeline.Properties == null ? string.Empty : pipeline.Properties.ErrorMessage; throw new ProvisioningFailedException(errorMessage); } }; if (parameters.Force) { // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not. createPipeline(); } else { bool pipelineExists = CheckPipelineExists(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name); parameters.ConfirmAction( !pipelineExists, // prompt only if the linked service exists string.Format( CultureInfo.InvariantCulture, Resources.PipelineExists, parameters.Name, parameters.DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.PipelineCreating, parameters.Name, parameters.DataFactoryName), parameters.Name, createPipeline); } return(pipeline); }
private bool CheckPipelineExists(string resourceGroupName, string dataFactoryName, string pipelineName) { try { PSPipeline pipeline = GetPipeline(resourceGroupName, dataFactoryName, pipelineName); return(pipeline != null); } catch (ErrorResponseException e) { //Get throws Exception message with NotFound Status if (e.Response.StatusCode == HttpStatusCode.NotFound) { return(false); } else { throw; } } }
private bool CheckPipelineExists(string resourceGroupName, string dataFactoryName, string pipelineName) { // ToDo: implement HEAD to check if the pipeline exists try { PSPipeline pipeline = GetPipeline(resourceGroupName, dataFactoryName, pipelineName); return(true); } catch (CloudException e) { //Get throws Exception message with NotFound Status if (e.Response.StatusCode == HttpStatusCode.NotFound) { return(false); } else { throw; } } }
public virtual PSPipeline CreatePSPipeline(CreatePSAdfEntityParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } PSPipeline pipeline = null; Action createPipeline = () => { pipeline = new PSPipeline(CreateOrUpdatePipeline(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name, parameters.RawJsonContent), parameters.ResourceGroupName, parameters.DataFactoryName ); }; parameters.ConfirmAction( parameters.Force, // prompt only if the linked service exists string.Format( CultureInfo.InvariantCulture, Resources.PipelineExists, parameters.Name, parameters.DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.PipelineCreating, parameters.Name, parameters.DataFactoryName), parameters.Name, createPipeline, () => CheckPipelineExists(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name)); return(pipeline); }
public void CanGetPipeline() { // Arrange PSPipeline expected = new PSPipeline() { PipelineName = pipelineName, DataFactoryName = DataFactoryName, ResourceGroupName = ResourceGroupName }; dataFactoriesClientMock .Setup( c => c.FilterPSPipelines( It.Is <PipelineFilterOptions>( options => options.ResourceGroupName == ResourceGroupName && options.DataFactoryName == DataFactoryName && options.Name == pipelineName))) .CallBase() .Verifiable(); dataFactoriesClientMock .Setup(c => c.GetPipeline(ResourceGroupName, DataFactoryName, pipelineName)) .Returns(expected) .Verifiable(); // Action cmdlet.Name = pipelineName; cmdlet.ExecuteCmdlet(); // Assert dataFactoriesClientMock.VerifyAll(); commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once()); }