public virtual PSOutput CreatePSOutput(CreatePSOutputParameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } PSOutput output = null; Action createOutput = () => { output = new PSOutput(CreateOrUpdatePSOutput(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName, parameter.RawJsonContent)) { ResourceGroupName = parameter.ResourceGroupName, JobName = parameter.JobName }; }; if (parameter.Force) { // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not. createOutput(); } else { bool outputExists = CheckOutputExists(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName); parameter.ConfirmAction( !outputExists, string.Format( CultureInfo.InvariantCulture, Resources.OutputExists, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.OutputCreating, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), parameter.OutputName, createOutput); } return(output); }
public virtual PSOutput CreatePSOutput(CreatePSOutputParameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } PSOutput output = null; Action createOutput = () => { output = new PSOutput(CreateOrUpdatePSOutput(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName, parameter.RawJsonContent)) { ResourceGroupName = parameter.ResourceGroupName, JobName = parameter.JobName }; }; if (parameter.Force) { // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not. createOutput(); } else { bool outputExists = CheckOutputExists(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName); parameter.ConfirmAction( !outputExists, string.Format( CultureInfo.InvariantCulture, Resources.OutputExists, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.OutputCreating, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), parameter.OutputName, createOutput); } return output; }
private bool CheckOutputExists(string resourceGroupName, string jobName, string outputName) { try { PSOutput output = GetOutput(resourceGroupName, jobName, outputName); return(true); } catch (CloudException e) { //Get throws Exception message with NotFound Status if (e.Response.StatusCode == HttpStatusCode.NotFound) { return(false); } else { throw; } } }
public virtual PSOutput CreatePSOutput(CreatePSOutputParameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } PSOutput output = null; parameter.ConfirmAction( parameter.Force, string.Format( CultureInfo.InvariantCulture, Resources.OutputExists, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.OutputCreating, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), parameter.OutputName, () => { output = new PSOutput(CreateOrUpdatePSOutput(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName, parameter.RawJsonContent)) { ResourceGroupName = parameter.ResourceGroupName, JobName = parameter.JobName }; }, () => CheckOutputExists(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName)); return(output); }
public virtual PSOutput CreatePSOutput(CreatePSOutputParameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } PSOutput output = null; parameter.ConfirmAction( parameter.Force, string.Format( CultureInfo.InvariantCulture, Resources.OutputExists, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), string.Format( CultureInfo.InvariantCulture, Resources.OutputCreating, parameter.OutputName, parameter.JobName, parameter.ResourceGroupName), parameter.OutputName, () => { output = new PSOutput(CreateOrUpdatePSOutput(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName, parameter.RawJsonContent)) { ResourceGroupName = parameter.ResourceGroupName, JobName = parameter.JobName }; }, () => CheckOutputExists(parameter.ResourceGroupName, parameter.JobName, parameter.OutputName)); return output; }