public JobScheduleOperationParameters(BatchAccountContext context, string jobScheduleId, PSCloudJobSchedule jobSchedule,
        IEnumerable<BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors)
    {
        if (string.IsNullOrWhiteSpace(jobScheduleId) && jobSchedule == null)
        {
            throw new ArgumentNullException(Resources.NoJobSchedule);
        }

        this.JobScheduleId = jobScheduleId;
        this.JobSchedule = jobSchedule;
    }
예제 #2
0
        /// <summary>
        /// Commits changes to a PSCloudJobSchedule object to the Batch Service.
        /// </summary>
        /// <param name="context">The account to use.</param>
        /// <param name="jobSchedule">The PSCloudJobSchedule object representing the job schedule to update.</param>
        /// <param name="additionBehaviors">Additional client behaviors to perform.</param>
        public void UpdateJobSchedule(BatchAccountContext context, PSCloudJobSchedule jobSchedule, IEnumerable <BatchClientBehavior> additionBehaviors = null)
        {
            if (jobSchedule == null)
            {
                throw new ArgumentNullException("jobSchedule");
            }

            WriteVerbose(string.Format(Resources.UpdatingJobSchedule, jobSchedule.Id));

            Utils.Utils.BoundJobScheduleSyncCollections(jobSchedule);
            jobSchedule.omObject.Commit(additionBehaviors);
        }
        /// <summary>
        /// Lists the job schedules matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for job schedules.</param>
        /// <returns>The workitems matching the specified filter options.</returns>
        public IEnumerable<PSCloudJobSchedule> ListJobSchedules(ListJobScheduleOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single job schedule matching the specified id
            if (!string.IsNullOrWhiteSpace(options.JobScheduleId))
            {
                WriteVerbose(string.Format(Resources.GetJobScheduleById, options.JobScheduleId));
                JobScheduleOperations jobScheduleOperations = options.Context.BatchOMClient.JobScheduleOperations;
                ODATADetailLevel getDetailLevel = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                CloudJobSchedule jobSchedule = jobScheduleOperations.GetJobSchedule(options.JobScheduleId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCloudJobSchedule psJobSchedule = new PSCloudJobSchedule(jobSchedule);
                return new PSCloudJobSchedule[] { psJobSchedule };
            }
            // List job schedules using the specified filter
            else
            {
                string verboseLogString = null;
                ODATADetailLevel listDetailLevel = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = Resources.GetJobScheduleByOData;
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = Resources.GetJobScheduleNoFilter;
                }
                WriteVerbose(verboseLogString);

                JobScheduleOperations jobScheduleOperations = options.Context.BatchOMClient.JobScheduleOperations;
                IPagedEnumerable<CloudJobSchedule> workItems = jobScheduleOperations.ListJobSchedules(listDetailLevel, options.AdditionalBehaviors);
                Func<CloudJobSchedule, PSCloudJobSchedule> mappingFunction = j => { return new PSCloudJobSchedule(j); };
                return PSPagedEnumerable<PSCloudJobSchedule, CloudJobSchedule>.CreateWithMaxCount(
                    workItems, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount)));
            }
        }
예제 #4
0
        /// <summary>
        /// Lists the job schedules matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for job schedules.</param>
        /// <returns>The workitems matching the specified filter options.</returns>
        public IEnumerable <PSCloudJobSchedule> ListJobSchedules(ListJobScheduleOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single job schedule matching the specified id
            if (!string.IsNullOrWhiteSpace(options.JobScheduleId))
            {
                WriteVerbose(string.Format(Resources.GetJobScheduleById, options.JobScheduleId));
                JobScheduleOperations jobScheduleOperations = options.Context.BatchOMClient.JobScheduleOperations;
                ODATADetailLevel      getDetailLevel        = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                CloudJobSchedule      jobSchedule           = jobScheduleOperations.GetJobSchedule(options.JobScheduleId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCloudJobSchedule    psJobSchedule         = new PSCloudJobSchedule(jobSchedule);
                return(new PSCloudJobSchedule[] { psJobSchedule });
            }
            // List job schedules using the specified filter
            else
            {
                string           verboseLogString = null;
                ODATADetailLevel listDetailLevel  = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = Resources.GetJobScheduleByOData;
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = Resources.GetJobScheduleNoFilter;
                }
                WriteVerbose(verboseLogString);

                JobScheduleOperations jobScheduleOperations                 = options.Context.BatchOMClient.JobScheduleOperations;
                IPagedEnumerable <CloudJobSchedule>         workItems       = jobScheduleOperations.ListJobSchedules(listDetailLevel, options.AdditionalBehaviors);
                Func <CloudJobSchedule, PSCloudJobSchedule> mappingFunction = j => { return(new PSCloudJobSchedule(j)); };
                return(PSPagedEnumerable <PSCloudJobSchedule, CloudJobSchedule> .CreateWithMaxCount(
                           workItems, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        /// <summary>
        /// Commits changes to a PSCloudJobSchedule object to the Batch Service.
        /// </summary>
        /// <param name="context">The account to use.</param>
        /// <param name="jobSchedule">The PSCloudJobSchedule object representing the job schedule to update.</param>
        /// <param name="additionBehaviors">Additional client behaviors to perform.</param>
        public void UpdateJobSchedule(BatchAccountContext context, PSCloudJobSchedule jobSchedule, IEnumerable<BatchClientBehavior> additionBehaviors = null)
        {
            if (jobSchedule == null)
            {
                throw new ArgumentNullException("jobSchedule");
            }

            WriteVerbose(string.Format(Resources.UpdatingJobSchedule, jobSchedule.Id));

            Utils.Utils.BoundJobScheduleSyncCollections(jobSchedule);
            jobSchedule.omObject.Commit(additionBehaviors);
        }
        public JobScheduleOperationParameters(BatchAccountContext context, string jobScheduleId, PSCloudJobSchedule jobSchedule,
                                              IEnumerable <BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors)
        {
            if (string.IsNullOrWhiteSpace(jobScheduleId) && jobSchedule == null)
            {
                throw new ArgumentNullException(Resources.NoJobSchedule);
            }

            this.JobScheduleId = jobScheduleId;
            this.JobSchedule   = jobSchedule;
        }