Ejemplo n.º 1
0
        /// <summary>
        /// Commits all pending changes to this <see cref="CloudJobSchedule" /> to the Azure Batch service.
        /// </summary>
        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/>.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
        /// <remarks>
        /// <para>
        /// Updates an existing <see cref="CloudJobSchedule"/> on the Batch service by replacing its properties with the properties of this <see cref="CloudJobSchedule"/> which have been changed.
        /// Unchanged properties are ignored.
        /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refresh"/>, <see cref="JobScheduleOperations.GetJobSchedule"/>,
        /// or <see cref="JobScheduleOperations.ListJobSchedules"/>) are applied.
        /// Properties which are explicitly set to null will cause an exception because the Batch service does not support partial updates which set a property to null.
        /// If you need to set a property to null, use <see cref="Commit"/>.
        /// </para>
        /// <para>This operation runs asynchronously.</para>
        /// </remarks>
        public async System.Threading.Tasks.Task CommitChangesAsync(
            IEnumerable <BatchClientBehavior> additionalBehaviors = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);

            // after this no prop access is allowed
            this.propertyContainer.IsReadOnly = true;

            // craft the bahavior manager for this call
            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);

            Models.JobSpecification jobSpecification = this.propertyContainer.JobSpecificationProperty.GetTransportObjectIfChanged <JobSpecification, Models.JobSpecification>();
            Models.Schedule         schedule         = this.propertyContainer.ScheduleProperty.GetTransportObjectIfChanged <Schedule, Models.Schedule>();
            Models.MetadataItem[]   metadata         = this.propertyContainer.MetadataProperty.GetTransportObjectIfChanged <MetadataItem, Models.MetadataItem>();

            System.Threading.Tasks.Task asyncJobScheduleUpdate =
                this.parentBatchClient.ProtocolLayer.PatchJobSchedule(
                    this.Id,
                    jobSpecification,
                    metadata,
                    schedule,
                    bhMgr,
                    cancellationToken);

            await asyncJobScheduleUpdate.ConfigureAwait(continueOnCapturedContext : false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds a CloudJobScheduleGetResponse object
        /// </summary>
        public static ProxyModels.CloudJobScheduleGetResponse CreateCloudJobScheduleGetResponse(string jobScheduleId)
        {
            ProxyModels.CloudJobScheduleGetResponse response = new ProxyModels.CloudJobScheduleGetResponse();
            response.StatusCode = HttpStatusCode.OK;

            ProxyModels.JobSpecification jobSpec  = new ProxyModels.JobSpecification();
            ProxyModels.Schedule         schedule = new ProxyModels.Schedule();

            ProxyModels.CloudJobSchedule jobSchedule = new ProxyModels.CloudJobSchedule(jobScheduleId, schedule, jobSpec);
            response.JobSchedule = jobSchedule;

            return(response);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds a CloudJobScheduleGetResponse object
        /// </summary>
        public static AzureOperationResponse <ProxyModels.CloudJobSchedule, ProxyModels.JobScheduleGetHeaders> CreateCloudJobScheduleGetResponse(string jobScheduleId)
        {
            var response = new AzureOperationResponse <ProxyModels.CloudJobSchedule, ProxyModels.JobScheduleGetHeaders>();

            response.Response = new HttpResponseMessage(HttpStatusCode.OK);

            ProxyModels.JobSpecification jobSpec  = new ProxyModels.JobSpecification();
            ProxyModels.Schedule         schedule = new ProxyModels.Schedule();

            ProxyModels.CloudJobSchedule jobSchedule = new ProxyModels.CloudJobSchedule(id: jobScheduleId, schedule: schedule, jobSpecification: jobSpec);
            response.Body = jobSchedule;

            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds a CloudJobScheduleListResponse object
        /// </summary>
        public static ProxyModels.CloudJobScheduleListResponse CreateCloudJobScheduleListResponse(IEnumerable <string> jobScheduleIds)
        {
            ProxyModels.CloudJobScheduleListResponse response = new ProxyModels.CloudJobScheduleListResponse();
            response.StatusCode = HttpStatusCode.OK;;

            List <ProxyModels.CloudJobSchedule> jobSchedules = new List <ProxyModels.CloudJobSchedule>();

            ProxyModels.JobSpecification jobSpec  = new ProxyModels.JobSpecification();
            ProxyModels.Schedule         schedule = new ProxyModels.Schedule();

            foreach (string id in jobScheduleIds)
            {
                jobSchedules.Add(new ProxyModels.CloudJobSchedule(id, schedule, jobSpec));
            }

            response.JobSchedules = jobSchedules;

            return(response);
        }
Ejemplo n.º 5
0
 public PropertyContainer(Models.Schedule protocolObject) : base(BindingState.Bound)
 {
     this.DoNotRunAfterProperty = this.CreatePropertyAccessor(
         protocolObject.DoNotRunAfter,
         "DoNotRunAfter",
         BindingAccess.Read | BindingAccess.Write);
     this.DoNotRunUntilProperty = this.CreatePropertyAccessor(
         protocolObject.DoNotRunUntil,
         "DoNotRunUntil",
         BindingAccess.Read | BindingAccess.Write);
     this.RecurrenceIntervalProperty = this.CreatePropertyAccessor(
         protocolObject.RecurrenceInterval,
         "RecurrenceInterval",
         BindingAccess.Read | BindingAccess.Write);
     this.StartWindowProperty = this.CreatePropertyAccessor(
         protocolObject.StartWindow,
         "StartWindow",
         BindingAccess.Read | BindingAccess.Write);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Builds a CloudJobScheduleListResponse object
        /// </summary>
        public static AzureOperationResponse <IPage <ProxyModels.CloudJobSchedule>, ProxyModels.JobScheduleListHeaders> CreateCloudJobScheduleListResponse(IEnumerable <string> jobScheduleIds)
        {
            var response = new AzureOperationResponse <IPage <ProxyModels.CloudJobSchedule>, ProxyModels.JobScheduleListHeaders>();

            response.Response = new HttpResponseMessage(HttpStatusCode.OK);

            List <ProxyModels.CloudJobSchedule> jobSchedules = new List <ProxyModels.CloudJobSchedule>();

            ProxyModels.JobSpecification jobSpec  = new ProxyModels.JobSpecification();
            ProxyModels.Schedule         schedule = new ProxyModels.Schedule();

            foreach (string id in jobScheduleIds)
            {
                jobSchedules.Add(new ProxyModels.CloudJobSchedule(id: id, schedule: schedule, jobSpecification: jobSpec));
            }

            response.Body = new MockPagedEnumerable <ProxyModels.CloudJobSchedule>(jobSchedules);

            return(response);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Commits this <see cref="CloudJobSchedule" /> to the Azure Batch service.
        /// </summary>
        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/>.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
        /// <remarks>
        /// <para>The commit operation runs asynchronously.</para>
        /// </remarks>
        public async System.Threading.Tasks.Task CommitAsync(
            IEnumerable <BatchClientBehavior> additionalBehaviors = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            // after this no prop access is allowed
            this.propertyContainer.IsReadOnly = true;

            // craft the behavior manager for this call
            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);

            // fetch props with admin rights so we can make calls, etc.

            if (BindingState.Unbound == this.propertyContainer.BindingState)
            {
                // take all property changes and create a job schedule
                Models.JobScheduleAddParameter protoJobSchedule = this.GetTransportObject <Models.JobScheduleAddParameter>();

                System.Threading.Tasks.Task <AzureOperationHeaderResponse <Models.JobScheduleAddHeaders> > asyncTask =
                    this.parentBatchClient.ProtocolLayer.AddJobSchedule(protoJobSchedule, bhMgr, cancellationToken);

                await asyncTask.ConfigureAwait(continueOnCapturedContext : false);
            }
            else
            {
                Models.JobSpecification jobSpecification = UtilitiesInternal.CreateObjectWithNullCheck(this.JobSpecification, o => o.GetTransportObject());
                Models.Schedule         schedule         = UtilitiesInternal.CreateObjectWithNullCheck(this.Schedule, o => o.GetTransportObject());
                Models.MetadataItem[]   metadata         = UtilitiesInternal.ConvertToProtocolArray(this.Metadata);

                System.Threading.Tasks.Task <AzureOperationHeaderResponse <Models.JobScheduleUpdateHeaders> > asyncJobScheduleUpdate =
                    this.parentBatchClient.ProtocolLayer.UpdateJobSchedule(
                        this.Id,
                        jobSpecification,
                        metadata,
                        schedule,
                        bhMgr,
                        cancellationToken);

                await asyncJobScheduleUpdate.ConfigureAwait(continueOnCapturedContext : false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Builds a CloudJobScheduleListResponse object
        /// </summary>
        public static ProxyModels.CloudJobScheduleListResponse CreateCloudJobScheduleListResponse(IEnumerable<string> jobScheduleIds)
        {
            ProxyModels.CloudJobScheduleListResponse response = new ProxyModels.CloudJobScheduleListResponse();
            response.StatusCode = HttpStatusCode.OK;;

            List<ProxyModels.CloudJobSchedule> jobSchedules = new List<ProxyModels.CloudJobSchedule>();
            ProxyModels.JobSpecification jobSpec = new ProxyModels.JobSpecification();
            ProxyModels.Schedule schedule = new ProxyModels.Schedule();

            foreach (string id in jobScheduleIds)
            {
                jobSchedules.Add(new ProxyModels.CloudJobSchedule(id, schedule, jobSpec));
            }

            response.JobSchedules = jobSchedules;

            return response;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Builds a CloudJobScheduleGetResponse object
        /// </summary>
        public static ProxyModels.CloudJobScheduleGetResponse CreateCloudJobScheduleGetResponse(string jobScheduleId)
        {
            ProxyModels.CloudJobScheduleGetResponse response = new ProxyModels.CloudJobScheduleGetResponse();
            response.StatusCode = HttpStatusCode.OK;

            ProxyModels.JobSpecification jobSpec = new ProxyModels.JobSpecification();
            ProxyModels.Schedule schedule = new ProxyModels.Schedule();

            ProxyModels.CloudJobSchedule jobSchedule = new ProxyModels.CloudJobSchedule(jobScheduleId, schedule, jobSpec);
            response.JobSchedule = jobSchedule;

            return response;
        }