Skip to content

Commit

Permalink
Exposing expand on ListAtContext as well in preparation to expose tha…
Browse files Browse the repository at this point in the history
…t in each of the generated ListAsGeneric methods in autorest (#22351)

* Updating GenericResourceList to return GenericResourceExpanded

* Added missing expand and related test cases.

* Adding missing test recordings.

* Exposing expand on ListAtContext as well in preparation to expose that in each of the generated ListAsGeneric methods in autorest
  • Loading branch information
allenjzhang authored Jul 1, 2021
1 parent ff7dc59 commit 3ab3261
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ public static class ResourceListOperations
/// </summary>
/// <param name="resourceGroup"> The <see cref="ResourceGroupOperations"/> instance to use for the list. </param>
/// <param name="resourceFilters"> Optional filters for results. </param>
/// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. </param>
/// <param name="top"> The number of results to return. </param>
/// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
/// <returns> A collection of resource operations that may take multiple service requests to iterate over. </returns>
public static Pageable<GenericResourceExpanded> ListAtContext(
ResourceGroupOperations resourceGroup,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
return ListAtContextInternal(
resourceGroup,
resourceGroup.Id.Name,
resourceFilters,
expand,
top,
cancellationToken);
}
Expand All @@ -37,19 +40,22 @@ public static Pageable<GenericResourceExpanded> ListAtContext(
/// </summary>
/// <param name="resourceGroup"> The <see cref="ResourceGroupOperations"/> instance to use for the list. </param>
/// <param name="resourceFilters"> Optional filters for results. </param>
/// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. </param>
/// <param name="top"> The number of results to return. </param>
/// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
/// <returns>An async collection of resource operations that may take multiple service requests to iterate over. </returns>
public static AsyncPageable<GenericResourceExpanded> ListAtContextAsync(
ResourceGroupOperations resourceGroup,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
return ListAtContextInternalAsync(
resourceGroup,
resourceGroup.Id.Name,
resourceFilters,
expand,
top,
cancellationToken);
}
Expand All @@ -59,19 +65,22 @@ public static AsyncPageable<GenericResourceExpanded> ListAtContextAsync(
/// </summary>
/// <param name="subscription"> The <see cref="SubscriptionOperations"/> instance to use for the list. </param>
/// <param name="resourceFilters"> Optional filters for results. </param>
/// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. </param>
/// <param name="top"> The number of results to return. </param>
/// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
/// <returns> A collection of resource operations that may take multiple service requests to iterate over. </returns>
public static Pageable<GenericResourceExpanded> ListAtContext(
SubscriptionOperations subscription,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
return ListAtContextInternal(
subscription,
null,
resourceFilters,
expand,
top,
cancellationToken);
}
Expand All @@ -81,19 +90,22 @@ public static Pageable<GenericResourceExpanded> ListAtContext(
/// </summary>
/// <param name="subscription"> The <see cref="SubscriptionOperations"/> instance to use for the list. </param>
/// <param name="resourceFilters"> Optional filters for results. </param>
/// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. </param>
/// <param name="top"> The number of results to return. </param>
/// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
/// <returns> An async collection of resource operations that may take multiple service requests to iterate over. </returns>
public static AsyncPageable<GenericResourceExpanded> ListAtContextAsync(
SubscriptionOperations subscription,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
return ListAtContextInternalAsync(
subscription,
null,
resourceFilters,
expand,
top,
cancellationToken);
}
Expand All @@ -108,21 +120,22 @@ private static AsyncPageable<GenericResourceExpanded> ListAtContextInternalAsync
ResourceOperationsBase resourceOperations,
string scopeFilter,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
var restClient = GetGenericResourceContainer(resourceOperations);
AsyncPageable<GenericResourceExpanded> result;
if (scopeFilter == null)
{
result = restClient.ListAsync(resourceFilters?.ToString(), null, top, cancellationToken);
result = restClient.ListAsync(resourceFilters?.ToString(), expand, top, cancellationToken);
}
else
{
result = restClient.ListByResourceGroupAsync(
scopeFilter,
resourceFilters?.ToString(),
null,
expand,
top,
cancellationToken);
}
Expand All @@ -134,21 +147,22 @@ private static Pageable<GenericResourceExpanded> ListAtContextInternal(
ResourceOperationsBase resourceOperations,
string scopeFilter = null,
ResourceFilterCollection resourceFilters = null,
string expand = null,
int? top = null,
CancellationToken cancellationToken = default)
{
var restClient = GetGenericResourceContainer(resourceOperations);
Pageable<GenericResourceExpanded> result;
if (scopeFilter == null)
{
result = restClient.List(resourceFilters?.ToString(), null, top, cancellationToken);
result = restClient.List(resourceFilters?.ToString(), expand, top, cancellationToken);
}
else
{
result = restClient.ListByResourceGroup(
scopeFilter,
resourceFilters?.ToString(),
null,
expand,
top,
cancellationToken);
}
Expand Down

0 comments on commit 3ab3261

Please sign in to comment.