Skip to content

Commit 0e694ff

Browse files
authored
Update generator to use latest paginator model file
1 parent 9d94bde commit 0e694ff

File tree

60 files changed

+4033
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4033
-21
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "RDS",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Update paginators to use the latest paginators model file."
8+
]
9+
},
10+
{
11+
"serviceName": "DynamoDBv2",
12+
"type": "patch",
13+
"changeLogMessages": [
14+
"Update paginators to use the latest paginators model file."
15+
]
16+
}
17+
]
18+
}

generator/ServiceClientGeneratorLib/GenerationManifest.cs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,11 @@ void LoadServiceConfigurations(JsonData manifest, JsonData serviceVersions, Gene
226226
/// <returns></returns>
227227
private static string GetLatestModel(string serviceDirectory)
228228
{
229-
string latestModelName = string.Empty;
230-
231-
foreach (string modelName in Directory.GetFiles(serviceDirectory, "*.normal.json", SearchOption.TopDirectoryOnly))
232-
{
233-
if (string.Compare(latestModelName, modelName) < 0)
234-
{
235-
latestModelName = modelName;
236-
}
237-
}
238-
229+
string latestModelName = Directory.GetFiles(serviceDirectory, "*.normal.json", SearchOption.TopDirectoryOnly).OrderBy(x => x).LastOrDefault();
239230
if (string.IsNullOrEmpty(latestModelName))
240-
{
241231
throw new FileNotFoundException("Failed to find a model file in " + serviceDirectory);
242-
}
243232

244-
return Path.GetFileName(latestModelName);
233+
return latestModelName;
245234
}
246235

247236
/// <summary>
@@ -253,7 +242,7 @@ private static string GetLatestModel(string serviceDirectory)
253242
private static string GetLatestPaginators(string serviceDirectory)
254243
{
255244
var latestPaginatorsName = Directory.GetFiles(serviceDirectory, "*.paginators.json", SearchOption.TopDirectoryOnly)
256-
.OrderBy(x => x).FirstOrDefault() ?? "";
245+
.OrderBy(x => x).LastOrDefault() ?? "";
257246
return Path.GetFileName(latestPaginatorsName);
258247
}
259248

@@ -262,17 +251,16 @@ private static string GetLatestPaginators(string serviceDirectory)
262251

263252
private ServiceConfiguration CreateServiceConfiguration(JsonData modelNode, JsonData serviceVersions, string serviceDirectoryPath, string serviceModelFileName, string servicePaginatorsFileName)
264253
{
265-
var modelFullPath = Utils.PathCombineAlt(serviceDirectoryPath, serviceModelFileName);
266254
var paginatorsFullPath = Utils.PathCombineAlt(serviceDirectoryPath, servicePaginatorsFileName);
267255

268-
JsonData metadata = JsonMapper.ToObject(File.ReadAllText(modelFullPath))[ServiceModel.MetadataKey];
256+
JsonData metadata = JsonMapper.ToObject(File.ReadAllText(serviceModelFileName))[ServiceModel.MetadataKey];
269257

270258
// A new config that the api generates from
271259
var modelName = Path.GetFileName(serviceDirectoryPath);
272260
var config = new ServiceConfiguration
273261
{
274262
ModelName = modelName,
275-
ModelPath = modelFullPath,
263+
ModelPath = serviceModelFileName,
276264
PaginatorsPath = paginatorsFullPath,
277265
Namespace = Utils.JsonDataToString(modelNode[ModelsSectionKeys.NamespaceKey]), // Namespace of the service if it's different from basename
278266
ClassNameOverride = Utils.JsonDataToString(modelNode[ModelsSectionKeys.BaseNameKey]),
@@ -282,8 +270,8 @@ private ServiceConfiguration CreateServiceConfiguration(JsonData modelNode, Json
282270
};
283271

284272
// Load endpoints ruleset and tests if present
285-
var rulesetFileName = Directory.GetFiles(serviceDirectoryPath, "*." + EndpointRuleSetFile, SearchOption.TopDirectoryOnly).FirstOrDefault();
286-
var testsFileName = Directory.GetFiles(serviceDirectoryPath, "*." + EndpointRuleSetTestsFile, SearchOption.TopDirectoryOnly).FirstOrDefault();
273+
var rulesetFileName = Directory.GetFiles(serviceDirectoryPath, "*." + EndpointRuleSetFile, SearchOption.TopDirectoryOnly).LastOrDefault();
274+
var testsFileName = Directory.GetFiles(serviceDirectoryPath, "*." + EndpointRuleSetTestsFile, SearchOption.TopDirectoryOnly).LastOrDefault();
287275

288276
// We have found tests but not rules, something is wrong!
289277
if (rulesetFileName == null && testsFileName != null)
@@ -478,8 +466,8 @@ private static string DetermineCustomizationsPath(string serviceKey)
478466
{
479467
return null;
480468
}
481-
var files = Directory.GetFiles("customizations", serviceKey + ".customizations.json").OrderByDescending(x => x);
482-
return !files.Any() ? null : files.Single();
469+
var customizationFile = Directory.GetFiles("customizations", serviceKey + ".customizations.json").OrderBy(x => x).LastOrDefault();
470+
return customizationFile;
483471
}
484472

485473
/// <summary>

sdk/src/Services/DynamoDBv2/Generated/Model/_bcl45+netstandard/DynamoDBv2PaginatorFactory.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ public IBatchGetItemPaginator BatchGetItem(BatchGetItemRequest request)
4444
return new BatchGetItemPaginator(this.client, request);
4545
}
4646

47+
/// <summary>
48+
/// Paginator for ListContributorInsights operation
49+
///</summary>
50+
public IListContributorInsightsPaginator ListContributorInsights(ListContributorInsightsRequest request)
51+
{
52+
return new ListContributorInsightsPaginator(this.client, request);
53+
}
54+
55+
/// <summary>
56+
/// Paginator for ListExports operation
57+
///</summary>
58+
public IListExportsPaginator ListExports(ListExportsRequest request)
59+
{
60+
return new ListExportsPaginator(this.client, request);
61+
}
62+
63+
/// <summary>
64+
/// Paginator for ListImports operation
65+
///</summary>
66+
public IListImportsPaginator ListImports(ListImportsRequest request)
67+
{
68+
return new ListImportsPaginator(this.client, request);
69+
}
70+
4771
/// <summary>
4872
/// Paginator for ListTables operation
4973
///</summary>

sdk/src/Services/DynamoDBv2/Generated/Model/_bcl45+netstandard/IDynamoDBv2PaginatorFactory.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ public interface IDynamoDBv2PaginatorFactory
3131
///</summary>
3232
IBatchGetItemPaginator BatchGetItem(BatchGetItemRequest request);
3333

34+
/// <summary>
35+
/// Paginator for ListContributorInsights operation
36+
///</summary>
37+
IListContributorInsightsPaginator ListContributorInsights(ListContributorInsightsRequest request);
38+
39+
/// <summary>
40+
/// Paginator for ListExports operation
41+
///</summary>
42+
IListExportsPaginator ListExports(ListExportsRequest request);
43+
44+
/// <summary>
45+
/// Paginator for ListImports operation
46+
///</summary>
47+
IListImportsPaginator ListImports(ListImportsRequest request);
48+
3449
/// <summary>
3550
/// Paginator for ListTables operation
3651
///</summary>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the dynamodb-2012-08-10.normal.json service model.
18+
*/
19+
using Amazon.Runtime;
20+
21+
#pragma warning disable CS0612,CS0618
22+
namespace Amazon.DynamoDBv2.Model
23+
{
24+
/// <summary>
25+
/// Paginator for the ListContributorInsights operation
26+
///</summary>
27+
public interface IListContributorInsightsPaginator
28+
{
29+
/// <summary>
30+
/// Enumerable containing all full responses for the operation
31+
/// </summary>
32+
IPaginatedEnumerable<ListContributorInsightsResponse> Responses { get; }
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the dynamodb-2012-08-10.normal.json service model.
18+
*/
19+
using Amazon.Runtime;
20+
21+
#pragma warning disable CS0612,CS0618
22+
namespace Amazon.DynamoDBv2.Model
23+
{
24+
/// <summary>
25+
/// Paginator for the ListExports operation
26+
///</summary>
27+
public interface IListExportsPaginator
28+
{
29+
/// <summary>
30+
/// Enumerable containing all full responses for the operation
31+
/// </summary>
32+
IPaginatedEnumerable<ListExportsResponse> Responses { get; }
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the dynamodb-2012-08-10.normal.json service model.
18+
*/
19+
using Amazon.Runtime;
20+
21+
#pragma warning disable CS0612,CS0618
22+
namespace Amazon.DynamoDBv2.Model
23+
{
24+
/// <summary>
25+
/// Paginator for the ListImports operation
26+
///</summary>
27+
public interface IListImportsPaginator
28+
{
29+
/// <summary>
30+
/// Enumerable containing all full responses for the operation
31+
/// </summary>
32+
IPaginatedEnumerable<ListImportsResponse> Responses { get; }
33+
}
34+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the dynamodb-2012-08-10.normal.json service model.
18+
*/
19+
20+
using System;
21+
using System.Collections.Generic;
22+
using System.Text;
23+
using System.Collections;
24+
using System.Threading;
25+
using System.Threading.Tasks;
26+
using Amazon.Runtime;
27+
28+
#pragma warning disable CS0612,CS0618
29+
namespace Amazon.DynamoDBv2.Model
30+
{
31+
/// <summary>
32+
/// Base class for ListContributorInsights paginators.
33+
/// </summary>
34+
internal sealed partial class ListContributorInsightsPaginator : IPaginator<ListContributorInsightsResponse>, IListContributorInsightsPaginator
35+
{
36+
private readonly IAmazonDynamoDB _client;
37+
private readonly ListContributorInsightsRequest _request;
38+
private int _isPaginatorInUse = 0;
39+
40+
/// <summary>
41+
/// Enumerable containing all full responses for the operation
42+
/// </summary>
43+
public IPaginatedEnumerable<ListContributorInsightsResponse> Responses => new PaginatedResponse<ListContributorInsightsResponse>(this);
44+
45+
internal ListContributorInsightsPaginator(IAmazonDynamoDB client, ListContributorInsightsRequest request)
46+
{
47+
this._client = client;
48+
this._request = request;
49+
}
50+
#if BCL
51+
IEnumerable<ListContributorInsightsResponse> IPaginator<ListContributorInsightsResponse>.Paginate()
52+
{
53+
if (Interlocked.Exchange(ref _isPaginatorInUse, 1) != 0)
54+
{
55+
throw new System.InvalidOperationException("Paginator has already been consumed and cannot be reused. Please create a new instance.");
56+
}
57+
PaginatorUtils.SetUserAgentAdditionOnRequest(_request);
58+
var nextToken = _request.NextToken;
59+
ListContributorInsightsResponse response;
60+
do
61+
{
62+
_request.NextToken = nextToken;
63+
response = _client.ListContributorInsights(_request);
64+
nextToken = response.NextToken;
65+
yield return response;
66+
}
67+
while (!string.IsNullOrEmpty(nextToken));
68+
}
69+
#endif
70+
#if AWS_ASYNC_ENUMERABLES_API
71+
async IAsyncEnumerable<ListContributorInsightsResponse> IPaginator<ListContributorInsightsResponse>.PaginateAsync([System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
72+
{
73+
if (Interlocked.Exchange(ref _isPaginatorInUse, 1) != 0)
74+
{
75+
throw new System.InvalidOperationException("Paginator has already been consumed and cannot be reused. Please create a new instance.");
76+
}
77+
PaginatorUtils.SetUserAgentAdditionOnRequest(_request);
78+
var nextToken = _request.NextToken;
79+
ListContributorInsightsResponse response;
80+
do
81+
{
82+
_request.NextToken = nextToken;
83+
response = await _client.ListContributorInsightsAsync(_request, cancellationToken).ConfigureAwait(false);
84+
nextToken = response.NextToken;
85+
cancellationToken.ThrowIfCancellationRequested();
86+
yield return response;
87+
}
88+
while (!string.IsNullOrEmpty(nextToken));
89+
}
90+
#endif
91+
}
92+
}

0 commit comments

Comments
 (0)