public NodeFileOperationParameters(BatchAccountContext context, string jobId, string taskId, string poolId, string computeNodeId, string nodeFileName, PSNodeFile nodeFile, IEnumerable<BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors) { PSNodeFileType? nodeFileType = null; if (nodeFile != null) { nodeFileType = PSNodeFileType.PSNodeFileInstance; } else if (!string.IsNullOrWhiteSpace(nodeFileName)) { if (!string.IsNullOrWhiteSpace(jobId) && !string.IsNullOrWhiteSpace(taskId)) { nodeFileType = PSNodeFileType.Task; } else if (!string.IsNullOrWhiteSpace(poolId) && !string.IsNullOrWhiteSpace(computeNodeId)) { nodeFileType = PSNodeFileType.ComputeNode; } } if (nodeFileType == null) { throw new ArgumentException(Resources.NoNodeFile); } this.NodeFileType = nodeFileType.Value; this.JobId = jobId; this.TaskId = taskId; this.PoolId = poolId; this.ComputeNodeId = computeNodeId; this.NodeFileName = nodeFileName; this.NodeFile = nodeFile; }
public NodeFileOperationParameters(BatchAccountContext context, string jobId, string taskId, string poolId, string computeNodeId, string nodeFileName, PSNodeFile nodeFile, IEnumerable <BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors) { PSNodeFileType?nodeFileType = null; if (nodeFile != null) { nodeFileType = PSNodeFileType.PSNodeFileInstance; } else if (!string.IsNullOrWhiteSpace(nodeFileName)) { if (!string.IsNullOrWhiteSpace(jobId) && !string.IsNullOrWhiteSpace(taskId)) { nodeFileType = PSNodeFileType.Task; } else if (!string.IsNullOrWhiteSpace(poolId) && !string.IsNullOrWhiteSpace(computeNodeId)) { nodeFileType = PSNodeFileType.ComputeNode; } } if (nodeFileType == null) { throw new ArgumentException(Resources.NoNodeFile); } this.NodeFileType = nodeFileType.Value; this.JobId = jobId; this.TaskId = taskId; this.PoolId = poolId; this.ComputeNodeId = computeNodeId; this.NodeFileName = nodeFileName; this.NodeFile = nodeFile; }
public DownloadNodeFileOptions(BatchAccountContext context, string jobId, string taskId, string poolId, string computeNodeId, string nodeFileName, PSNodeFile nodeFile, string destinationPath, Stream stream, IEnumerable <BatchClientBehavior> additionalBehaviors = null) : base(context, jobId, taskId, poolId, computeNodeId, nodeFileName, nodeFile, additionalBehaviors) { if (string.IsNullOrWhiteSpace(destinationPath) && stream == null) { throw new ArgumentNullException(Resources.NoDownloadDestination); } this.DestinationPath = destinationPath; this.Stream = stream; }
public DownloadNodeFileOptions(BatchAccountContext context, string jobId, string taskId, string poolId, string computeNodeId, string nodeFileName, PSNodeFile nodeFile, string destinationPath, Stream stream, IEnumerable<BatchClientBehavior> additionalBehaviors = null) : base(context, jobId, taskId, poolId, computeNodeId, nodeFileName, nodeFile, additionalBehaviors) { if (string.IsNullOrWhiteSpace(destinationPath) && stream == null) { throw new ArgumentNullException(Resources.NoDownloadDestination); } this.DestinationPath = destinationPath; this.Stream = stream; }
// 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)))); } }
// 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.GBTF_GetByName, 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.GBTF_GetByOData, taskId); odata = new ODATADetailLevel(filterClause: options.Filter); } else { verboseLogString = string.Format(Resources.GBTF_NoFilter, 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))); } }