Skip to content

Commit 1d22a14

Browse files
author
begoldsm
committed
Add support for returning a set number of jobs
Also remove test package.
1 parent 4c2c694 commit 1d22a14

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics/Commands/GetAzureRmDataLakeAnalyticsJob.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,14 @@ public override void ExecuteCmdlet()
172172
var filterString = string.Join(" and ", filter.ToArray());
173173

174174
// List the jobs with the given filters
175+
bool warnUser;
175176
var list = DataLakeAnalyticsClient.ListJobs(Account,
176-
string.IsNullOrEmpty(filterString) ? null : filterString, Top, null, "submitTime desc");
177+
string.IsNullOrEmpty(filterString) ? null : filterString, Top, null, "submitTime desc", out warnUser);
178+
if (warnUser)
179+
{
180+
WriteWarning(string.Format(Resources.MoreJobsToGetWarning, Top.HasValue ? Top.Value : 500));
181+
}
182+
177183
WriteObject(list, true);
178184
}
179185
}

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics/Models/DataLakeAnalyticsClient.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,27 +971,40 @@ public JobStatistics GetJobStatistics(string accountName, Guid jobId)
971971
}
972972

973973
public List<JobInformation> ListJobs(string accountName, string filter, int? top,
974-
int? skip, string orderBy)
974+
int? skip, string orderBy, out bool moreJobs)
975975
{
976+
moreJobs = false;
977+
// top is used to return a total number, not top per page.
978+
if (!top.HasValue)
979+
{
980+
top = 500;
981+
}
982+
976983
var parameters = new ODataQuery<JobInformation>
977984
{
978985
Filter = filter,
979-
Top = top,
980986
Skip = skip,
981987
OrderBy = orderBy
982988
};
983989

984990
var jobList = new List<JobInformation>();
985991
var response = _jobClient.Job.List(accountName, parameters);
986-
992+
var curCount = 0;
987993
jobList.AddRange(response);
988-
while (!string.IsNullOrEmpty(response.NextPageLink))
994+
curCount = jobList.Count();
995+
while (!string.IsNullOrEmpty(response.NextPageLink) && curCount <= top.Value)
989996
{
990997
response = ListJobsWithNextLink(response.NextPageLink);
991998
jobList.AddRange(response);
999+
curCount = jobList.Count();
1000+
}
1001+
1002+
if (curCount > top.Value || !string.IsNullOrEmpty(response.NextPageLink))
1003+
{
1004+
moreJobs = true;
9921005
}
9931006

994-
return jobList;
1007+
return jobList.GetRange(0, top.Value);
9951008
}
9961009

9971010
#endregion

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,7 @@
231231
<data name="IncorrectOutputTypeWarning" xml:space="preserve">
232232
<value>The output type defined for this cmdlet is incorrect and will be updated to reflect what is actually returned (and defined in the help) in a future release.</value>
233233
</data>
234+
<data name="MoreJobsToGetWarning" xml:space="preserve">
235+
<value>More than {0} jobs exist in the account. Specify -Top with a larger value to retrieve more jobs. Note that large values of -Top will take time to retrieve all items.</value>
236+
</data>
234237
</root>
Binary file not shown.

0 commit comments

Comments
 (0)