-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(adf):
DataFactoryResource.GetPipelineRuns
cannot do pagination (#…
…42247) - add customization codes to implement the non-standard pagination logic of `DataFactoryResource.GetPipelineRuns` - add test fix #39438 --------- Co-authored-by: Mingzhe Huang (from Dev Box) <[email protected]>
- Loading branch information
Showing
4 changed files
with
157 additions
and
64 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
sdk/datafactory/Azure.ResourceManager.DataFactory/src/Customized/DataFactoryResource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading; | ||
using Autorest.CSharp.Core; | ||
using Azure.Core; | ||
using Azure.ResourceManager.DataFactory.Models; | ||
|
||
namespace Azure.ResourceManager.DataFactory | ||
{ | ||
public partial class DataFactoryResource : ArmResource | ||
{ | ||
/// <summary> | ||
/// Query pipeline runs in the factory based on input filter conditions. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>PipelineRuns_QueryByFactory</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2018-06-01</description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="content"> Parameters to filter the pipeline run. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> | ||
/// <returns> An async collection of <see cref="DataFactoryPipelineRunInfo"/> that may take multiple service requests to iterate over. </returns> | ||
public virtual AsyncPageable<DataFactoryPipelineRunInfo> GetPipelineRunsAsync(RunFilterContent content, CancellationToken cancellationToken = default) | ||
{ | ||
if (content == null) | ||
{ | ||
throw new ArgumentNullException(nameof(content)); | ||
} | ||
|
||
HttpMessage FirstPageRequest(int? pageSizeHint) => _pipelineRunsRestClient.CreateQueryByFactoryRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content); | ||
HttpMessage NextPageRequest(int? pageSizeHint, string continuationToken) => _pipelineRunsRestClient.CreateQueryByFactoryNextPageRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, continuationToken); | ||
return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DataFactoryPipelineRunInfo.DeserializeDataFactoryPipelineRunInfo(e), _pipelineRunsClientDiagnostics, Pipeline, "DataFactoryResource.GetPipelineRuns", "value", "continuationToken", cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// Query pipeline runs in the factory based on input filter conditions. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>PipelineRuns_QueryByFactory</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2018-06-01</description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="content"> Parameters to filter the pipeline run. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> | ||
/// <returns> A collection of <see cref="DataFactoryPipelineRunInfo"/> that may take multiple service requests to iterate over. </returns> | ||
public virtual Pageable<DataFactoryPipelineRunInfo> GetPipelineRuns(RunFilterContent content, CancellationToken cancellationToken = default) | ||
{ | ||
if (content == null) | ||
{ | ||
throw new ArgumentNullException(nameof(content)); | ||
} | ||
|
||
HttpMessage FirstPageRequest(int? pageSizeHint) => _pipelineRunsRestClient.CreateQueryByFactoryRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content); | ||
HttpMessage NextPageRequest(int? pageSizeHint, string continuationToken) => _pipelineRunsRestClient.CreateQueryByFactoryNextPageRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, continuationToken); | ||
return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DataFactoryPipelineRunInfo.DeserializeDataFactoryPipelineRunInfo(e), _pipelineRunsClientDiagnostics, Pipeline, "DataFactoryResource.GetPipelineRuns", "value", "continuationToken", cancellationToken); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...e.ResourceManager.DataFactory/src/Customized/RestOperations/PipelineRunsRestOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
using Azure.ResourceManager.DataFactory.Models; | ||
|
||
namespace Azure.ResourceManager.DataFactory | ||
{ | ||
internal partial class PipelineRunsRestOperations | ||
{ | ||
internal HttpMessage CreateQueryByFactoryNextPageRequest(string subscriptionId, string resourceGroupName, string factoryName, RunFilterContent content, string continuationToken) | ||
{ | ||
var message = _pipeline.CreateMessage(); | ||
var request = message.Request; | ||
request.Method = RequestMethod.Post; | ||
var uri = new RawRequestUriBuilder(); | ||
uri.Reset(_endpoint); | ||
uri.AppendPath("/subscriptions/", false); | ||
uri.AppendPath(subscriptionId, true); | ||
uri.AppendPath("/resourceGroups/", false); | ||
uri.AppendPath(resourceGroupName, true); | ||
uri.AppendPath("/providers/Microsoft.DataFactory/factories/", false); | ||
uri.AppendPath(factoryName, true); | ||
uri.AppendPath("/queryPipelineRuns", false); | ||
uri.AppendQuery("api-version", _apiVersion, true); | ||
request.Uri = uri; | ||
request.Headers.Add("Accept", "application/json"); | ||
request.Headers.Add("Content-Type", "application/json"); | ||
var content0 = new Utf8JsonRequestContent(); | ||
// copy filter parameters, and set continuation token | ||
content0.JsonWriter.WriteObjectValue(new RunFilterContent(continuationToken, content.LastUpdatedAfter, content.LastUpdatedBefore, content.Filters, content.OrderBy, null)); | ||
request.Content = content0; | ||
_userAgent.Apply(message); | ||
return message; | ||
} | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
sdk/datafactory/Azure.ResourceManager.DataFactory/src/Generated/DataFactoryResource.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...tafactory/Azure.ResourceManager.DataFactory/tests/Scenario/DataFactoryPipelineRunTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Azure.Core; | ||
using Azure.Core.TestFramework; | ||
using Azure.ResourceManager.DataFactory.Models; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.ResourceManager.DataFactory.Tests.Scenario | ||
{ | ||
internal class DataFactoryPipelineRunTests : DataFactoryManagementTestBase | ||
{ | ||
public DataFactoryPipelineRunTests(bool isAsync) : base(isAsync) | ||
{ | ||
} | ||
|
||
[Test] | ||
[RecordedTest] | ||
[Ignore("Pending recording")] | ||
public async Task GetPipelineRuns() | ||
{ | ||
string subscriptionId = "xxx"; | ||
string resourceGroupName = "test"; | ||
string factoryName = "test"; | ||
ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); | ||
DataFactoryResource dataFactory = GetArmClient().GetDataFactoryResource(dataFactoryResourceId); | ||
|
||
RunFilterContent content = new RunFilterContent(DateTimeOffset.Parse("2024-02-27T00:36:44.3345758Z"), DateTimeOffset.Parse("2024-06-16T00:49:48.3686473Z")); | ||
int count = 0; | ||
await foreach (DataFactoryPipelineRunInfo item in dataFactory.GetPipelineRunsAsync(content)) | ||
{ | ||
count++; | ||
} | ||
|
||
Console.WriteLine($"Total count: {count}"); | ||
} | ||
} | ||
} |