public virtual PSTable CreatePSTable(CreatePSTableParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } PSTable table = null; Action createTable = () => { table = new PSTable(CreateOrUpdateTable( parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name, parameters.RawJsonContent)) { ResourceGroupName = parameters.ResourceGroupName, DataFactoryName = parameters.DataFactoryName }; if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(table.ProvisioningState)) { string errorMessage = table.Properties == null ? string.Empty : table.Properties.ErrorMessage; throw new ProvisioningFailedException(errorMessage); } }; if (parameters.Force) { // If user decides to overwrite anyway, then there is no need to check if the table exists or not. createTable(); } else { bool tableExists = CheckTableExists(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name); parameters.ConfirmAction( !tableExists, // prompt only if the table exists string.Format( CultureInfo.InvariantCulture, Resources.TableExists, parameters.Name, parameters.DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.TableCreating, parameters.Name, parameters.DataFactoryName), parameters.Name, createTable); } return(table); }
public virtual PSHub CreatePSHub(CreatePSHubParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } PSHub hub = null; Action createHub = () => { hub = new PSHub( this.CreateOrUpdateHub( parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name, parameters.RawJsonContent)) { DataFactoryName = parameters.DataFactoryName, ResourceGroupName = parameters.ResourceGroupName }; if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(hub.ProvisioningState)) { // ToDo: service side should set the error message for provisioning failures. throw new ProvisioningFailedException(Resources.HubProvisioningFailed); } }; if (parameters.Force) { createHub(); } else { bool hubExists = this.CheckHubExists( parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name); parameters.ConfirmAction( !hubExists, string.Format( CultureInfo.InvariantCulture, Resources.HubExists, parameters.Name, parameters.DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.HubCreating, parameters.Name, parameters.DataFactoryName), parameters.Name, createHub); } return(hub); }
public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters) { PSDataFactory dataFactory = null; Action createDataFactory = () => { Dictionary <string, string> tags = new Dictionary <string, string>(); if (parameters.Tags != null) { tags = parameters.Tags.ToDictionary(); } dataFactory = new PSDataFactory( CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Location, tags)) { ResourceGroupName = parameters.ResourceGroupName }; }; if (parameters.Force) { // If user decides to overwrite anyway, then there is no need to check if the data factory exists or not. createDataFactory(); } else { bool dataFactoryExists = CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName); parameters.ConfirmAction( !dataFactoryExists, // prompt only if the data factory exists string.Format( CultureInfo.InvariantCulture, Resources.DataFactoryExists, parameters.DataFactoryName, parameters.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.DataFactoryCreating, parameters.DataFactoryName, parameters.ResourceGroupName), parameters.DataFactoryName, createDataFactory); } if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataFactory.ProvisioningState)) { string errorMessage = dataFactory.Properties == null ? string.Empty : dataFactory.Properties.ErrorMessage; throw new ProvisioningFailedException(errorMessage); } return(dataFactory); }
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); } }; 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 virtual PSDataset CreatePSDataset(CreatePSDatasetParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } PSDataset dataset = null; Action createDataset = () => { dataset = new PSDataset(this.CreateOrUpdateDataset( parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name, parameters.RawJsonContent)) { ResourceGroupName = parameters.ResourceGroupName, DataFactoryName = parameters.DataFactoryName }; if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataset.ProvisioningState)) { string errorMessage = dataset.Properties == null ? string.Empty : dataset.Properties.ErrorMessage; throw new ProvisioningFailedException(errorMessage); } }; parameters.ConfirmAction( parameters.Force, // prompt only if the dataset exists string.Format( CultureInfo.InvariantCulture, Resources.DatasetExists, parameters.Name, parameters.DataFactoryName), string.Format( CultureInfo.InvariantCulture, Resources.DatasetCreating, parameters.Name, parameters.DataFactoryName), parameters.Name, createDataset, () => this.CheckDatasetExists(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Name)); return(dataset); }
public virtual PSDataFactory CreatePSDataFactory(CreatePSDataFactoryParameters parameters) { PSDataFactory dataFactory = null; Action createDataFactory = () => { Dictionary <string, string> tags = new Dictionary <string, string>(); if (parameters.Tags != null) { tags = parameters.Tags.ToDictionary(); } dataFactory = new PSDataFactory( CreateOrUpdateDataFactory(parameters.ResourceGroupName, parameters.DataFactoryName, parameters.Location, tags)) { ResourceGroupName = parameters.ResourceGroupName }; }; parameters.ConfirmAction( parameters.Force, // prompt only if the data factory exists string.Format( CultureInfo.InvariantCulture, Resources.DataFactoryExists, parameters.DataFactoryName, parameters.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.DataFactoryCreating, parameters.DataFactoryName, parameters.ResourceGroupName), parameters.DataFactoryName, createDataFactory, () => CheckDataFactoryExists(parameters.ResourceGroupName, parameters.DataFactoryName, out dataFactory)); if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataFactory.ProvisioningState)) { string errorMessage = dataFactory.Properties == null ? string.Empty : dataFactory.Properties.ErrorMessage; throw new ProvisioningFailedException(errorMessage); } return(dataFactory); }
public virtual PSDataFactoryGateway CreateOrUpdateGateway(string resourceGroupName, string dataFactoryName, PSDataFactoryGateway gateway) { if (gateway == null) { throw new ArgumentNullException("gateway"); } var response = DataPipelineManagementClient.Gateways.CreateOrUpdate( resourceGroupName, dataFactoryName, new GatewayCreateOrUpdateParameters { Gateway = gateway.ToGatewayDefinition() }); Gateway createdGateway = response.Gateway; if (createdGateway.Properties != null && !DataFactoryCommonUtilities.IsSucceededProvisioningState(createdGateway.Properties.ProvisioningState)) { // ToDo: service side should set the error message for provisioning failures. throw new ProvisioningFailedException(Resources.GatewayProvisioningFailed); } return(new PSDataFactoryGateway(createdGateway)); }