/// <summary>
        /// Lists the subtasks matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for subtasks.</param>
        /// <returns>The subtasks matching the specified filter options.</returns>
        public IEnumerable <PSSubtaskInformation> ListSubtasks(ListSubtaskOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string taskId           = options.Task == null ? options.TaskId : options.Task.Id;
            string verboseLogString = string.Format(Resources.GetSubtaskNoFilter, taskId);

            WriteVerbose(verboseLogString);

            IPagedEnumerable <SubtaskInformation> subtasks = null;

            if (options.Task != null)
            {
                subtasks = options.Task.omObject.ListSubtasks(additionalBehaviors: options.AdditionalBehaviors);
            }
            else
            {
                JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                subtasks = jobOperations.ListSubtasks(options.JobId, options.TaskId, additionalBehaviors: options.AdditionalBehaviors);
            }
            Func <SubtaskInformation, PSSubtaskInformation> mappingFunction = s => { return(new PSSubtaskInformation(s)); };

            return(PSPagedEnumerable <PSSubtaskInformation, SubtaskInformation> .CreateWithMaxCount(
                       subtasks, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
        }
Example #2
0
        /// <summary>
        /// Lists the job prep and release status matching the specified filter options.
        /// </summary>
        /// <param name="options">The Batch account context.</param>
        public IEnumerable <PSJobPreparationAndReleaseTaskExecutionInformation> ListJobPreparationAndReleaseStatus(ListJobPreparationAndReleaseStatusOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            string jobId = options.JobId ?? options.Job.Id;

            if (jobId == null)
            {
                throw new ArgumentNullException(nameof(jobId));
            }

            WriteVerbose(string.Format(Resources.GetJobPreparationAndReleaseStatus, jobId));
            JobOperations    jobOperations  = options.Context.BatchOMClient.JobOperations;
            ODATADetailLevel getDetailLevel = new ODATADetailLevel(filterClause: options.Filter, selectClause: options.Select, expandClause: options.Expand);
            IPagedEnumerable <JobPreparationAndReleaseTaskExecutionInformation> jobPrepAndReleaseDetails =
                jobOperations.ListJobPreparationAndReleaseTaskStatus(jobId, getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);

            Func <JobPreparationAndReleaseTaskExecutionInformation, PSJobPreparationAndReleaseTaskExecutionInformation> mappingFunction =
                j => new PSJobPreparationAndReleaseTaskExecutionInformation(j);

            return(PSPagedEnumerable <PSJobPreparationAndReleaseTaskExecutionInformation, JobPreparationAndReleaseTaskExecutionInformation> .CreateWithMaxCount(
                       jobPrepAndReleaseDetails, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
        }
Example #3
0
        /// <summary>
        /// Lists the pool node counts matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when listing pool node counts.</param>
        /// <returns>The pool node counts matching the specified filter.</returns>
        public IEnumerable <PSPoolNodeCounts> ListPoolNodeCounts(ListPoolNodeCountsOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            ODATADetailLevel detailLevel = null;

            const string filterStringFormat = "(poolId eq '{0}')";

            if (!string.IsNullOrEmpty(options.PoolId))
            {
                detailLevel = new ODATADetailLevel(string.Format(filterStringFormat, options.PoolId));
            }
            else if (options.Pool != null)
            {
                detailLevel = new ODATADetailLevel(string.Format(filterStringFormat, options.Pool.Id));
            }

            IPagedEnumerable <PoolNodeCounts> poolNodeCounts = options.Context.BatchOMClient.PoolOperations.ListPoolNodeCounts(
                detailLevel, options.AdditionalBehaviors);

            Func <PoolNodeCounts, PSPoolNodeCounts> mappingFunction = p => { return(new PSPoolNodeCounts(p)); };

            return(PSPagedEnumerable <PSPoolNodeCounts, PoolNodeCounts> .CreateWithMaxCount(poolNodeCounts, mappingFunction,
                                                                                            options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
        }
Example #4
0
        /// <summary>
        /// Lists the jobs matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for jobs.</param>
        /// <returns>The jobs matching the specified filter options.</returns>
        public IEnumerable <PSCloudJob> ListJobs(ListJobOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single job matching the specified id
            if (!string.IsNullOrEmpty(options.JobId))
            {
                WriteVerbose(string.Format(Resources.GetJobById, options.JobId));
                JobOperations    jobOperations  = options.Context.BatchOMClient.JobOperations;
                ODATADetailLevel getDetailLevel = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                CloudJob         job            = jobOperations.GetJob(options.JobId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCloudJob       psJob          = new PSCloudJob(job);
                return(new PSCloudJob[] { psJob });
            }
            // List jobs using the specified filter
            else
            {
                string           jobScheduleId       = options.JobSchedule == null ? options.JobScheduleId : options.JobSchedule.Id;
                bool             filterByJobSchedule = !string.IsNullOrEmpty(jobScheduleId);
                ODATADetailLevel listDetailLevel     = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);

                string verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = filterByJobSchedule ? Resources.GetJobByOData : string.Format(Resources.GetJobByODataAndJobSChedule, jobScheduleId);
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = filterByJobSchedule ? Resources.GetJobNoFilter : string.Format(Resources.GetJobByJobScheduleNoFilter, jobScheduleId);
                }
                WriteVerbose(verboseLogString);

                IPagedEnumerable <CloudJob> jobs = null;
                if (filterByJobSchedule)
                {
                    JobScheduleOperations jobScheduleOperations = options.Context.BatchOMClient.JobScheduleOperations;
                    jobs = jobScheduleOperations.ListJobs(jobScheduleId, listDetailLevel, options.AdditionalBehaviors);
                }
                else
                {
                    JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                    jobs = jobOperations.ListJobs(listDetailLevel, options.AdditionalBehaviors);
                }
                Func <CloudJob, PSCloudJob> mappingFunction = j => { return(new PSCloudJob(j)); };
                return(PSPagedEnumerable <PSCloudJob, CloudJob> .CreateWithMaxCount(
                           jobs, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        private IEnumerable <PSNodeVMExtension> ListExtensions(string poolId, string nodeId, PoolOperations poolOperations, ListComputeNodeExtensionParameters options)
        {
            WriteVerbose(string.Format(Resources.GetComputeNodeExtensions, poolId, nodeId));

            IPagedEnumerable <NodeVMExtension> extensions = poolOperations.ListComputeNodeExtensions(poolId, nodeId, options.AdditionalBehaviors);

            return(PSPagedEnumerable <PSNodeVMExtension, NodeVMExtension> .CreateWithMaxCount
                   (
                       extensions,
                       e => { return new PSNodeVMExtension(e); },
                       options.MaxCount,
                       () => WriteMaxCount(options.MaxCount)
                   ));
        }
        /// <summary>
        /// Lists the tasks matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for tasks.</param>
        /// <returns>The tasks matching the specified filter options.</returns>
        public IEnumerable <PSCloudTask> ListTasks(ListTaskOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single task matching the specified id
            if (!string.IsNullOrEmpty(options.TaskId))
            {
                WriteVerbose(string.Format(Resources.GetTaskById, options.TaskId, options.JobId));
                JobOperations    jobOperations  = options.Context.BatchOMClient.JobOperations;
                ODATADetailLevel getDetailLevel = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                CloudTask        task           = jobOperations.GetTask(options.JobId, options.TaskId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCloudTask      psTask         = new PSCloudTask(task);
                return(new PSCloudTask[] { psTask });
            }
            // List tasks using the specified filter
            else
            {
                string           jobId            = options.Job == null ? options.JobId : options.Job.Id;
                string           verboseLogString = null;
                ODATADetailLevel listDetailLevel  = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = string.Format(Resources.GetTaskByOData, jobId);
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = string.Format(Resources.GetTaskNoFilter, jobId);
                }
                WriteVerbose(verboseLogString);

                IPagedEnumerable <CloudTask> tasks = null;
                if (options.Job != null)
                {
                    tasks = options.Job.omObject.ListTasks(listDetailLevel, options.AdditionalBehaviors);
                }
                else
                {
                    JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                    tasks = jobOperations.ListTasks(options.JobId, listDetailLevel, options.AdditionalBehaviors);
                }
                Func <CloudTask, PSCloudTask> mappingFunction = t => { return(new PSCloudTask(t)); };
                return(PSPagedEnumerable <PSCloudTask, CloudTask> .CreateWithMaxCount(
                           tasks, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        /// <summary>
        /// Lists the node agent SKUs matching the specified filter options.
        /// </summary>
        /// <param name="context">The account to use.</param>
        /// <param name="filterClause">The level of detail</param>
        /// <param name="maxCount">The number of results.</param>
        /// <param name="additionalBehaviors">Additional client behaviors to perform.</param>
        /// <returns>The node agent SKUs matching the specified filter.</returns>
        public IEnumerable <PSImageInformation> ListSupportedImages(
            BatchAccountContext context,
            string filterClause = default(string),
            int maxCount        = default(int),
            IEnumerable <BatchClientBehavior> additionalBehaviors = null)
        {
            PoolOperations   poolOperations = context.BatchOMClient.PoolOperations;
            ODATADetailLevel filterLevel    = new ODATADetailLevel(filterClause: filterClause);

            IPagedEnumerable <ImageInformation>         supportedImages = poolOperations.ListSupportedImages(filterLevel, additionalBehaviors);
            Func <ImageInformation, PSImageInformation> mappingFunction = p => { return(new PSImageInformation(p)); };

            return(PSPagedEnumerable <PSImageInformation, ImageInformation> .CreateWithMaxCount(supportedImages, mappingFunction,
                                                                                                maxCount, () => WriteVerbose(string.Format(Resources.MaxCount, maxCount))));
        }
        internal static IEnumerable <T1> CreateWithMaxCount(
            IPagedEnumerable <T2> omAsyncEnumerable, Func <T2, T1> mappingFunction, int maxCount, Action logMaxCount = null)
        {
            PSPagedEnumerable <T1, T2> asyncEnumerable = new PSPagedEnumerable <T1, T2>(omAsyncEnumerable, mappingFunction);

            if (maxCount <= 0)
            {
                return(asyncEnumerable);
            }
            else
            {
                logMaxCount?.Invoke();
                return(asyncEnumerable.Take(maxCount));
            }
        }
Example #9
0
        /// <summary>
        /// Lists the compute nodes matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for compute nodes.</param>
        /// <returns>The compute nodes matching the specified filter options.</returns>
        public IEnumerable <PSComputeNode> ListComputeNodes(ListComputeNodeOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string poolId = options.Pool == null ? options.PoolId : options.Pool.Id;

            // Get the single compute node matching the specified id
            if (!string.IsNullOrEmpty(options.ComputeNodeId))
            {
                WriteVerbose(string.Format(Resources.GetComputeNodeById, options.ComputeNodeId, poolId));
                PoolOperations   poolOperations = options.Context.BatchOMClient.PoolOperations;
                ODATADetailLevel getDetailLevel = new ODATADetailLevel(selectClause: options.Select);
                ComputeNode      computeNode    = poolOperations.GetComputeNode(poolId, options.ComputeNodeId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSComputeNode    psComputeNode  = new PSComputeNode(computeNode);
                return(new PSComputeNode[] { psComputeNode });
            }
            // List compute nodes using the specified filter
            else
            {
                string           verboseLogString = null;
                ODATADetailLevel listDetailLevel  = new ODATADetailLevel(selectClause: options.Select);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = string.Format(Resources.GetComputeNodeByOData, poolId);
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = string.Format(Resources.GetComputeNodeNoFilter, poolId);
                }
                WriteVerbose(verboseLogString);

                PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations;
                IPagedEnumerable <ComputeNode> computeNodes = poolOperations.ListComputeNodes(poolId, listDetailLevel, options.AdditionalBehaviors);
                return(PSPagedEnumerable <PSComputeNode, ComputeNode> .CreateWithMaxCount
                       (
                           computeNodes,
                           c => { return new PSComputeNode(c); },
                           options.MaxCount,
                           () => WriteMaxCount(options.MaxCount)
                       ));
            }
        }
        // Lists the node files under a task.
        private IEnumerable <PSNodeFile> ListNodeFilesByTask(ListNodeFileOptions options)
        {
            // Get the single node file matching the specified name
            if (!string.IsNullOrEmpty(options.NodeFileName))
            {
                WriteVerbose(string.Format(Resources.GetNodeFileByTaskByName, options.NodeFileName, options.TaskId));
                JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                NodeFile      nodeFile      = jobOperations.GetNodeFile(options.JobId, options.TaskId, options.NodeFileName, options.AdditionalBehaviors);
                PSNodeFile    psNodeFile    = new PSNodeFile(nodeFile);
                return(new PSNodeFile[] { psNodeFile });
            }
            // List node files using the specified filter
            else
            {
                string           taskId           = options.Task == null ? options.TaskId : options.Task.Id;
                ODATADetailLevel odata            = null;
                string           verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = string.Format(Resources.GetNodeFileByTaskByOData, taskId);
                    odata            = new ODATADetailLevel(filterClause: options.Filter);
                }
                else
                {
                    verboseLogString = string.Format(Resources.GetNodeFileByTaskNoFilter, taskId);
                }
                WriteVerbose(verboseLogString);

                IPagedEnumerable <NodeFile> nodeFiles = null;
                if (options.Task != null)
                {
                    nodeFiles = options.Task.omObject.ListNodeFiles(options.Recursive, odata, options.AdditionalBehaviors);
                }
                else
                {
                    JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                    nodeFiles = jobOperations.ListNodeFiles(options.JobId, options.TaskId, options.Recursive, odata, options.AdditionalBehaviors);
                }
                Func <NodeFile, PSNodeFile> mappingFunction = f => { return(new PSNodeFile(f)); };
                return(PSPagedEnumerable <PSNodeFile, NodeFile> .CreateWithMaxCount(
                           nodeFiles, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        /// <summary>
        /// Lists the certificates matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for certificates.</param>
        /// <returns>The certificates matching the specified filter options.</returns>
        public IEnumerable <PSCertificate> ListCertificates(ListCertificateOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single certificate matching the specified thumbprint
            if (!string.IsNullOrWhiteSpace(options.Thumbprint))
            {
                WriteVerbose(string.Format(Resources.GetCertificateByThumbprint, options.Thumbprint));
                CertificateOperations certOperations = options.Context.BatchOMClient.CertificateOperations;
                ODATADetailLevel      getDetailLevel = new ODATADetailLevel(selectClause: options.Select);
                Certificate           certificate    = certOperations.GetCertificate(options.ThumbprintAlgorithm, options.Thumbprint,
                                                                                     detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCertificate psCertificate = new PSCertificate(certificate);
                return(new PSCertificate[] { psCertificate });
            }
            // List certificates using the specified filter
            else
            {
                string           verboseLogString = null;
                ODATADetailLevel listDetailLevel  = new ODATADetailLevel(selectClause: options.Select);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = Resources.GetCertificatesByFilter;
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = Resources.GetCertificatesNoFilter;
                }
                WriteVerbose(verboseLogString);

                CertificateOperations             certOperations  = options.Context.BatchOMClient.CertificateOperations;
                IPagedEnumerable <Certificate>    certificates    = certOperations.ListCertificates(listDetailLevel, options.AdditionalBehaviors);
                Func <Certificate, PSCertificate> mappingFunction = c => { return(new PSCertificate(c)); };
                return(PSPagedEnumerable <PSCertificate, Certificate> .CreateWithMaxCount(
                           certificates, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        /// <summary>
        /// Lists the compute nodes matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for compute nodes.</param>
        /// <returns>The compute nodes matching the specified filter options.</returns>
        public IEnumerable <PSComputeNode> ListComputeNodes(ListComputeNodeOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string poolId = options.Pool == null ? options.PoolId : options.Pool.Id;

            // Get the single compute node matching the specified id
            if (!string.IsNullOrEmpty(options.ComputeNodeId))
            {
                WriteVerbose(string.Format(Resources.GBCN_GetById, options.ComputeNodeId, poolId));
                PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations;
                ComputeNode    computeNode    = poolOperations.GetComputeNode(poolId, options.ComputeNodeId, additionalBehaviors: options.AdditionalBehaviors);
                PSComputeNode  psComputeNode  = new PSComputeNode(computeNode);
                return(new PSComputeNode[] { psComputeNode });
            }
            // List compute nodes using the specified filter
            else
            {
                ODATADetailLevel odata            = null;
                string           verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = string.Format(Resources.GBCN_GetByOData, poolId);
                    odata            = new ODATADetailLevel(filterClause: options.Filter);
                }
                else
                {
                    verboseLogString = string.Format(Resources.GBCN_NoFilter, poolId);
                }
                WriteVerbose(verboseLogString);

                PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations;
                IPagedEnumerable <ComputeNode>    computeNodes    = poolOperations.ListComputeNodes(poolId, odata, options.AdditionalBehaviors);
                Func <ComputeNode, PSComputeNode> mappingFunction = c => { return(new PSComputeNode(c)); };
                return(PSPagedEnumerable <PSComputeNode, ComputeNode> .CreateWithMaxCount(
                           computeNodes, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        /// <summary>
        /// Lists the pools matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for pools.</param>
        /// <returns>The pools matching the specified filter options.</returns>
        public IEnumerable <PSCloudPool> ListPools(ListPoolOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single pool matching the specified id
            if (!string.IsNullOrWhiteSpace(options.PoolId))
            {
                WriteVerbose(string.Format(Resources.GetPoolById, options.PoolId));
                PoolOperations   poolOperations = options.Context.BatchOMClient.PoolOperations;
                ODATADetailLevel getDetailLevel = new ODATADetailLevel(selectClause: options.Select, expandClause: options.Expand);
                CloudPool        pool           = poolOperations.GetPool(options.PoolId, detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCloudPool      psPool         = new PSCloudPool(pool);
                return(new PSCloudPool[] { psPool });
            }
            // List pools 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.GetPoolByOData;
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = Resources.GetPoolNoFilter;
                }
                WriteVerbose(verboseLogString);

                PoolOperations poolOperations                 = options.Context.BatchOMClient.PoolOperations;
                IPagedEnumerable <CloudPool>  pools           = poolOperations.ListPools(listDetailLevel, options.AdditionalBehaviors);
                Func <CloudPool, PSCloudPool> mappingFunction = p => { return(new PSCloudPool(p)); };
                return(PSPagedEnumerable <PSCloudPool, CloudPool> .CreateWithMaxCount(
                           pools, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
Example #14
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))));
            }
        }
Example #15
0
        /// <summary>
        /// Lists the usage metrics, aggregated by pool across individual time intervals, for the specified account.
        /// </summary>
        /// <param name="options">The options to use when aggregating usage for pools.</param>
        public IEnumerable <PSPoolUsageMetrics> ListPoolUsageMetrics(ListPoolUsageOptions options)
        {
            string           verboseLogString = null;
            ODATADetailLevel detailLevel      = null;

            if (!string.IsNullOrEmpty(options.Filter))
            {
                verboseLogString = Resources.GetPoolUsageMetricsByFilter;
                detailLevel      = new ODATADetailLevel(filterClause: options.Filter);
            }
            else
            {
                verboseLogString = Resources.GetPoolUsageMetricsByNoFilter;
            }

            PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations;
            IPagedEnumerable <PoolUsageMetrics> poolUsageMetrics =
                poolOperations.ListPoolUsageMetrics(options.StartTime, options.EndTime, detailLevel, options.AdditionalBehaviors);

            return(PSPagedEnumerable <PSPoolUsageMetrics, PoolUsageMetrics> .CreateWithMaxCount(
                       poolUsageMetrics, p => new PSPoolUsageMetrics(p), Int32.MaxValue, () => WriteVerbose(verboseLogString)));
        }