/// <summary>
 /// Updates the properties of the specified Job Schedule.
 /// </summary>
 /// <remarks>
 /// This fully replaces all the updatable properties of the Job Schedule. For
 /// example, if the schedule property is not specified with this request, then
 /// the Batch service will remove the existing schedule. Changes to a Job
 /// Schedule only impact Jobs created by the schedule after the update has
 /// taken place; currently running Jobs are unaffected.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobScheduleId'>
 /// The ID of the Job Schedule to update.
 /// </param>
 /// <param name='jobScheduleUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobScheduleUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <JobScheduleUpdateHeaders> UpdateAsync(this IJobScheduleOperations operations, string jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions = default(JobScheduleUpdateOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(jobScheduleId, jobScheduleUpdateParameter, jobScheduleUpdateOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
 /// <summary>
 /// Updates the properties of the specified Job Schedule.
 /// </summary>
 /// <remarks>
 /// This fully replaces all the updatable properties of the Job Schedule. For
 /// example, if the schedule property is not specified with this request, then
 /// the Batch service will remove the existing schedule. Changes to a Job
 /// Schedule only impact Jobs created by the schedule after the update has
 /// taken place; currently running Jobs are unaffected.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobScheduleId'>
 /// The ID of the Job Schedule to update.
 /// </param>
 /// <param name='jobScheduleUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobScheduleUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobScheduleUpdateHeaders Update(this IJobScheduleOperations operations, string jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions = default(JobScheduleUpdateOptions))
 {
     return(operations.UpdateAsync(jobScheduleId, jobScheduleUpdateParameter, jobScheduleUpdateOptions).GetAwaiter().GetResult());
 }
Example #3
0
        public void SetBatchJobScheduleParametersGetPassedToRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.JobSchedule = new PSCloudJobSchedule(BatchTestHelpers.CreateFakeBoundJobSchedule(context));

            // Make changes to the job schedule
            PSJobSpecification jobSpec = new PSJobSpecification()
            {
                DisplayName = "job display name",
                CommonEnvironmentSettings = new List <PSEnvironmentSetting>()
                {
                    new PSEnvironmentSetting("common1", "val1"),
                    new PSEnvironmentSetting("common2", "val2")
                },
                JobManagerTask     = new PSJobManagerTask("job manager", "cmd /c echo job manager"),
                JobPreparationTask = new PSJobPreparationTask("cmd /c echo job prep"),
                JobReleaseTask     = new PSJobReleaseTask("cmd /c echo job release"),
                PoolInformation    = new PSPoolInformation()
                {
                    PoolId = "myPool"
                }
            };

            cmdlet.JobSchedule.JobSpecification = jobSpec;

            PSSchedule schedule = new PSSchedule()
            {
                DoNotRunAfter      = DateTime.Now.AddYears(1),
                DoNotRunUntil      = DateTime.Now.AddDays(1),
                RecurrenceInterval = TimeSpan.FromDays(1),
                StartWindow        = TimeSpan.FromHours(1)
            };

            cmdlet.JobSchedule.Schedule = schedule;

            cmdlet.JobSchedule.Metadata = new List <PSMetadataItem>()
            {
                new PSMetadataItem("metadata1", "value1")
            };

            // Store the request parameters
            JobScheduleUpdateParameter requestParameters = null;
            RequestInterceptor         interceptor       = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                JobScheduleUpdateParameter,
                JobScheduleUpdateOptions,
                AzureOperationHeaderResponse <JobScheduleUpdateHeaders> >(requestAction: (r) =>
            {
                requestParameters = r.Parameters;
            });

            cmdlet.AdditionalBehaviors = new BatchClientBehavior[] { interceptor };
            cmdlet.ExecuteCmdlet();

            // Verify that the request parameters contain the updated properties
            Assert.Equal(jobSpec.CommonEnvironmentSettings.Count, requestParameters.JobSpecification.CommonEnvironmentSettings.Count);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[0].Name, requestParameters.JobSpecification.CommonEnvironmentSettings[0].Name);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[0].Value, requestParameters.JobSpecification.CommonEnvironmentSettings[0].Value);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[1].Name, requestParameters.JobSpecification.CommonEnvironmentSettings[1].Name);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[1].Value, requestParameters.JobSpecification.CommonEnvironmentSettings[1].Value);
            Assert.Equal(jobSpec.JobManagerTask.Id, requestParameters.JobSpecification.JobManagerTask.Id);
            Assert.Equal(jobSpec.JobPreparationTask.CommandLine, requestParameters.JobSpecification.JobPreparationTask.CommandLine);
            Assert.Equal(jobSpec.JobReleaseTask.CommandLine, requestParameters.JobSpecification.JobReleaseTask.CommandLine);
            Assert.Equal(jobSpec.PoolInformation.PoolId, requestParameters.JobSpecification.PoolInfo.PoolId);
            Assert.Equal(schedule.DoNotRunAfter, requestParameters.Schedule.DoNotRunAfter);
            Assert.Equal(schedule.DoNotRunUntil, requestParameters.Schedule.DoNotRunUntil);
            Assert.Equal(schedule.RecurrenceInterval, requestParameters.Schedule.RecurrenceInterval);
            Assert.Equal(schedule.StartWindow, requestParameters.Schedule.StartWindow);
            Assert.Equal(cmdlet.JobSchedule.Metadata.Count, requestParameters.Metadata.Count);
            Assert.Equal(cmdlet.JobSchedule.Metadata[0].Name, requestParameters.Metadata[0].Name);
            Assert.Equal(cmdlet.JobSchedule.Metadata[0].Value, requestParameters.Metadata[0].Value);
        }
Example #4
0
 public virtual Response Update(string jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions, CancellationToken cancellationToken = default)
 {
     return(RestClient.Update(jobScheduleId, jobScheduleUpdateParameter, jobScheduleUpdateOptions, cancellationToken).GetRawResponse());
 }
Example #5
0
 public virtual async Task <Response> UpdateAsync(string jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions, CancellationToken cancellationToken = default)
 {
     return((await RestClient.UpdateAsync(jobScheduleId, jobScheduleUpdateParameter, jobScheduleUpdateOptions, cancellationToken).ConfigureAwait(false)).GetRawResponse());
 }
 /// <summary>
 /// Updates the properties of the specified job schedule.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobScheduleId'>
 /// The id of the job schedule to update.
 /// </param>
 /// <param name='jobScheduleUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobScheduleUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobScheduleUpdateHeaders Update(this IJobScheduleOperations operations, string jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions = default(JobScheduleUpdateOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IJobScheduleOperations)s).UpdateAsync(jobScheduleId, jobScheduleUpdateParameter, jobScheduleUpdateOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }