private bool IsValidReleaseCriteria(BatchReleaseCriteria releaseCriteria) { return(this.MyInvocation.BoundParameters.ContainsKey("MessageCount") || this.MyInvocation.BoundParameters.ContainsKey("BatchSize") || (this.MyInvocation.BoundParameters.ContainsKey("ScheduleInterval") && !string.IsNullOrWhiteSpace(releaseCriteria.Recurrence?.Frequency))); }
/// <summary> /// Executes the integration account batch configuration update command. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (this.ParameterSetName) { case ParameterSet.ByInputObjectAndJson: case ParameterSet.ByInputObjectAndFilePath: case ParameterSet.ByInputObjectAndParameters: { var parsedResourceId = new ResourceIdentifier(this.InputObject.Id); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ParentName = parsedResourceId.ResourceName; break; } case ParameterSet.ByResourceIdAndJson: case ParameterSet.ByResourceIdAndFilePath: case ParameterSet.ByResourceIdAndParameters: { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ParentName = parsedResourceId.ResourceName; break; } } var batchConfiguration = new BatchConfiguration(); switch (this.ParameterSetName) { case ParameterSet.ByInputObjectAndJson: case ParameterSet.ByResourceIdAndJson: case ParameterSet.ByIntegrationAccountAndJson: { batchConfiguration.Properties = CmdletHelper.ConvertToBatchConfigurationProperties(this.BatchConfigurationDefinition); break; } case ParameterSet.ByInputObjectAndFilePath: case ParameterSet.ByResourceIdAndFilePath: case ParameterSet.ByIntegrationAccountAndFilePath: { batchConfiguration.Properties = CmdletHelper.ConvertToBatchConfigurationProperties(CmdletHelper.GetStringContentFromFile(this.TryResolvePath(this.BatchConfigurationFilePath))); break; } case ParameterSet.ByInputObjectAndParameters: case ParameterSet.ByResourceIdAndParameters: case ParameterSet.ByIntegrationAccountAndParameters: { var releaseCriteria = new BatchReleaseCriteria(); if (this.MyInvocation.BoundParameters.ContainsKey("MessageCount")) { releaseCriteria.MessageCount = this.MessageCount; } if (this.MyInvocation.BoundParameters.ContainsKey("BatchSize")) { releaseCriteria.BatchSize = this.BatchSize; } if (this.MyInvocation.BoundParameters.ContainsKey("ScheduleInterval")) { releaseCriteria.Recurrence = new WorkflowTriggerRecurrence { Interval = this.ScheduleInterval, Frequency = this.ScheduleFrequency, TimeZone = !string.IsNullOrWhiteSpace(this.ScheduleTimeZone) ? this.ScheduleTimeZone : null, StartTime = this.ScheduleStartTime?.ToShortDateString() }; } batchConfiguration.Properties = new BatchConfigurationProperties { BatchGroupName = this.BatchGroupName, ReleaseCriteria = releaseCriteria }; if (!this.IsValidReleaseCriteria(releaseCriteria)) { throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, Resource.BatchConfigurationParameterNeedsToBeSpecified)); } break; } } batchConfiguration.Properties.Metadata = this.Metadata; if (this.ShouldProcess(this.Name, string.Format(CultureInfo.InvariantCulture, Resource.UpdateIntegrationAccountArtifactMessage, Resource.BatchConfiguration, this.Name, this.ResourceGroupName))) { var updatedBatchConfiguration = IntegrationAccountClient.UpdateIntegrationAccountBatchConfiguration(this.ResourceGroupName, this.ParentName, this.Name, batchConfiguration); this.WriteObject(updatedBatchConfiguration); } }