/
CustomizationConfig.java
565 lines (443 loc) · 18.8 KB
/
CustomizationConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.config.customization;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.core.traits.PayloadTrait;
import software.amazon.awssdk.utils.AttributeMap;
/**
* {@code service-2.json} models can be manually modified via defining properties in an associated {@code customization.config}
* file. This class defines the Java bean representation that will be used to parse the JSON customization file. The bean can
* then be later queried in the misc. codegen steps.
*/
public class CustomizationConfig {
/**
* List of 'convenience' overloads to generate for model classes. Convenience overloads expose a
* different type that is adapted to the real type
*/
private final List<ConvenienceTypeOverload> convenienceTypeOverloads = new ArrayList<>();
/**
* Configuration object for service-specific configuration options.
*/
private ServiceConfig serviceConfig = new ServiceConfig();
/**
* Specify shapes to be renamed.
*/
private Map<String, String> renameShapes;
/**
* Custom service and intermediate model metadata properties.
*/
private MetadataConfig customServiceMetadata;
/**
* Codegen customization mechanism shared by the .NET SDK
*/
private Map<String, OperationModifier> operationModifiers;
private Map<String, ShapeSubstitution> shapeSubstitutions;
private Map<String, ShapeModifier> shapeModifiers;
/**
* Sets the custom field name that identifies the type of modeled exception for JSON protocols.
* Normally this is '__type' but Glacier has a custom error code field named simply 'code'.
*/
private String customErrorCodeFieldName;
/**
* Service specific base class for all modeled exceptions. By default this is syncInterface +
* Exception (i.e. AmazonSQSException). Currently only DynamoDB Streams utilizes this
* customization since it shares exception types with the DynamoDB client.
*
* <p>This customization should only provide the simple class name. The typical model package
* will be used when fully qualifying references to this exception</p>
*
* <p><b>Note:</b> that if a custom base class is provided the generator will not generate one.
* We assume it already exists.</p>
*/
private String sdkModeledExceptionBaseClassName;
/**
* Service calculates CRC32 checksum from compressed file when Accept-Encoding: gzip header is provided.
*/
private boolean calculateCrc32FromCompressedData;
/**
* Exclude the create() method on a client. This is useful for global services that will need a global region configured to
* work.
*/
private boolean excludeClientCreateMethod = false;
/**
* Configurations for the service that share model with other services. The models and non-request marshallers will be
* generated into the same directory as the provided service's models.
*/
private ShareModelConfig shareModelConfig;
/**
* Fully qualified name of the class that contains the custom http config. The class should expose a public static method
* with name "defaultHttpConfig" that returns an {@link AttributeMap} containing the desired http config defaults.
*
* See SWF customization.config for an example.
*/
private String serviceSpecificHttpConfig;
/**
* APIs that have no required arguments in their model but can't be called via a simple method
*/
private List<String> blacklistedSimpleMethods = new ArrayList<>();
/**
* APIs that are not Get/List/Describe APIs that have been verified that they are able
* to be used through simple methods
*/
private List<String> verifiedSimpleMethods = new ArrayList<>();
/**
* If a service isn't in the endpoints.json, the region that should be used for simple method integration tests.
*/
private String defaultSimpleMethodTestRegion;
private List<String> deprecatedOperations = new ArrayList<>();
private List<String> deprecatedShapes = new ArrayList<>();
private String sdkRequestBaseClassName;
private String sdkResponseBaseClassName;
private Map<String, String> modelMarshallerDefaultValueSupplier = new HashMap<>();
/**
* Custom Retry Policy
*/
private String customRetryPolicy;
private boolean skipSyncClientGeneration;
/**
* Customization to attach the {@link PayloadTrait} to a member. Currently this is only used for
* S3 which doesn't model a member as a payload trait even though it is.
*/
private Map<String, String> attachPayloadTraitToMember = new HashMap<>();
/**
* Custom Response metadata
*/
private Map<String, String> customResponseMetadata;
/**
* Custom protocol factory implementation. Currently this is only respected by the REST-XML protocol as only S3
* needs a custom factory.
*/
private String customProtocolFactoryFqcn;
/**
* Map of paginated operations that use custom class generation.
* Key - c2j operation name
* Value - indicates the type of pagination strategy to use
*/
private Map<String, String> paginationCustomization;
/**
* Config to generate a utilities() in the low-level client
*/
private UtilitiesMethod utilitiesMethod;
/**
* Force generation of deprecated client builder method 'enableEndpointDiscovery'. Only services that already had
* this method when it was deprecated require this flag to be set.
*/
private boolean enableEndpointDiscoveryMethodRequired = false;
/**
* Arnable fields used in s3 control
*/
private Map<String, S3ArnableFieldConfig> s3ArnableFields;
/**
* Allow a customer to set an endpoint override AND bypass endpoint discovery on their client even when endpoint discovery
* enabled is true and endpoint discovery is required for an operation. This customization should almost never be "true"
* because it creates a confusing customer experience.
*/
private boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations = false;
/**
* Customization to instruct the code generator to use the legacy model generation scheme for the given events.
* <p>
* <b>NOTE</b>This customization is primarily here to preserve backwards compatibility with existing code before the
* generation scheme for the visitor methods was changed. There should be no good reason to use this customization
* for any other purpose.
*/
private Map<String, List<String>> useLegacyEventGenerationScheme = new HashMap<>();
/**
* How the code generator should behave when it encounters shapes with underscores in the name.
*/
private UnderscoresInNameBehavior underscoresInNameBehavior;
private String userAgent;
private RetryMode defaultRetryMode;
/**
* Whether to generate an abstract decorator class that delegates to the async service client
*/
private boolean delegateAsyncClientClass;
/**
* Whether to skip generating endpoint tests from endpoint-tests.json
*/
private boolean skipEndpointTestGeneration;
/**
* A mapping from the skipped test's description to the reason why it's being skipped.
*/
private Map<String, String> skipEndpointTests;
private boolean useGlobalEndpoint;
/**
* Whether Endpoints 2.0/rule based endpoints should be used for endpoint resolution.
*/
private boolean useRuleBasedEndpoints = false;
private CustomizationConfig() {
}
public static CustomizationConfig create() {
return new CustomizationConfig();
}
public Map<String, OperationModifier> getOperationModifiers() {
return operationModifiers;
}
public void setOperationModifiers(Map<String, OperationModifier> operationModifiers) {
this.operationModifiers = operationModifiers;
}
public Map<String, String> getRenameShapes() {
return renameShapes;
}
public void setRenameShapes(Map<String, String> renameShapes) {
this.renameShapes = renameShapes;
}
public Map<String, ShapeSubstitution> getShapeSubstitutions() {
return shapeSubstitutions;
}
public void setShapeSubstitutions(Map<String, ShapeSubstitution> shapeSubstitutions) {
this.shapeSubstitutions = shapeSubstitutions;
}
public Map<String, ShapeModifier> getShapeModifiers() {
return shapeModifiers;
}
public void setShapeModifiers(Map<String, ShapeModifier> shapeModifiers) {
this.shapeModifiers = shapeModifiers;
}
public List<ConvenienceTypeOverload> getConvenienceTypeOverloads() {
return this.convenienceTypeOverloads;
}
public void setConvenienceTypeOverloads(List<ConvenienceTypeOverload> convenienceTypeOverloads) {
this.convenienceTypeOverloads.addAll(convenienceTypeOverloads);
}
public MetadataConfig getCustomServiceMetadata() {
return customServiceMetadata;
}
public void setCustomServiceMetadata(MetadataConfig metadataConfig) {
this.customServiceMetadata = metadataConfig;
}
public String getCustomErrorCodeFieldName() {
return customErrorCodeFieldName;
}
public void setCustomErrorCodeFieldName(String customErrorCodeFieldName) {
this.customErrorCodeFieldName = customErrorCodeFieldName;
}
public String getSdkModeledExceptionBaseClassName() {
return sdkModeledExceptionBaseClassName;
}
public void setSdkModeledExceptionBaseClassName(String sdkModeledExceptionBaseClassName) {
this.sdkModeledExceptionBaseClassName = sdkModeledExceptionBaseClassName;
}
public boolean isCalculateCrc32FromCompressedData() {
return calculateCrc32FromCompressedData;
}
public void setCalculateCrc32FromCompressedData(
boolean calculateCrc32FromCompressedData) {
this.calculateCrc32FromCompressedData = calculateCrc32FromCompressedData;
}
public boolean isExcludeClientCreateMethod() {
return excludeClientCreateMethod;
}
public void setExcludeClientCreateMethod(boolean excludeClientCreateMethod) {
this.excludeClientCreateMethod = excludeClientCreateMethod;
}
public ShareModelConfig getShareModelConfig() {
return shareModelConfig;
}
public void setShareModelConfig(ShareModelConfig shareModelConfig) {
this.shareModelConfig = shareModelConfig;
}
public String getServiceSpecificHttpConfig() {
return serviceSpecificHttpConfig;
}
public void setServiceSpecificHttpConfig(String serviceSpecificHttpConfig) {
this.serviceSpecificHttpConfig = serviceSpecificHttpConfig;
}
public List<String> getBlacklistedSimpleMethods() {
return blacklistedSimpleMethods;
}
public void setBlacklistedSimpleMethods(List<String> blackListedSimpleMethods) {
this.blacklistedSimpleMethods = blackListedSimpleMethods;
}
public List<String> getVerifiedSimpleMethods() {
return verifiedSimpleMethods;
}
public void setVerifiedSimpleMethods(List<String> verifiedSimpleMethods) {
this.verifiedSimpleMethods = verifiedSimpleMethods;
}
public String getDefaultSimpleMethodTestRegion() {
return defaultSimpleMethodTestRegion;
}
public void setDefaultSimpleMethodTestRegion(String defaultSimpleMethodTestRegion) {
this.defaultSimpleMethodTestRegion = defaultSimpleMethodTestRegion;
}
public List<String> getDeprecatedOperations() {
return deprecatedOperations;
}
public void setDeprecatedOperations(List<String> deprecatedOperations) {
this.deprecatedOperations = deprecatedOperations;
}
public List<String> getDeprecatedShapes() {
return deprecatedShapes;
}
public void setDeprecatedShapes(List<String> deprecatedShapes) {
this.deprecatedShapes = deprecatedShapes;
}
public String getSdkRequestBaseClassName() {
return sdkRequestBaseClassName;
}
public void setSdkRequestBaseClassName(String sdkRequestBaseClassName) {
this.sdkRequestBaseClassName = sdkRequestBaseClassName;
}
public String getSdkResponseBaseClassName() {
return sdkResponseBaseClassName;
}
public void setSdkResponseBaseClassName(String sdkResponseBaseClassName) {
this.sdkResponseBaseClassName = sdkResponseBaseClassName;
}
public Map<String, String> getModelMarshallerDefaultValueSupplier() {
return modelMarshallerDefaultValueSupplier;
}
public void setModelMarshallerDefaultValueSupplier(Map<String, String> modelMarshallerDefaultValueSupplier) {
this.modelMarshallerDefaultValueSupplier = modelMarshallerDefaultValueSupplier;
}
public String getCustomRetryPolicy() {
return customRetryPolicy;
}
public void setCustomRetryPolicy(String customRetryPolicy) {
this.customRetryPolicy = customRetryPolicy;
}
public boolean isSkipSyncClientGeneration() {
return skipSyncClientGeneration;
}
public void setSkipSyncClientGeneration(boolean skipSyncClientGeneration) {
this.skipSyncClientGeneration = skipSyncClientGeneration;
}
public Map<String, String> getAttachPayloadTraitToMember() {
return attachPayloadTraitToMember;
}
public void setAttachPayloadTraitToMember(Map<String, String> attachPayloadTraitToMember) {
this.attachPayloadTraitToMember = attachPayloadTraitToMember;
}
public Map<String, String> getCustomResponseMetadata() {
return customResponseMetadata;
}
public void setCustomResponseMetadata(Map<String, String> customResponseMetadata) {
this.customResponseMetadata = customResponseMetadata;
}
public String getCustomProtocolFactoryFqcn() {
return customProtocolFactoryFqcn;
}
public void setCustomProtocolFactoryFqcn(String customProtocolFactoryFqcn) {
this.customProtocolFactoryFqcn = customProtocolFactoryFqcn;
}
public Map<String, String> getPaginationCustomization() {
return paginationCustomization;
}
public void setPaginationCustomization(Map<String, String> paginationCustomization) {
this.paginationCustomization = paginationCustomization;
}
public UtilitiesMethod getUtilitiesMethod() {
return utilitiesMethod;
}
public void setUtilitiesMethod(UtilitiesMethod utilitiesMethod) {
this.utilitiesMethod = utilitiesMethod;
}
public boolean isEnableEndpointDiscoveryMethodRequired() {
return enableEndpointDiscoveryMethodRequired;
}
public void setEnableEndpointDiscoveryMethodRequired(boolean enableEndpointDiscoveryMethodRequired) {
this.enableEndpointDiscoveryMethodRequired = enableEndpointDiscoveryMethodRequired;
}
public Map<String, S3ArnableFieldConfig> getS3ArnableFields() {
return s3ArnableFields;
}
public CustomizationConfig withS3ArnableFields(Map<String, S3ArnableFieldConfig> s3ArnableFields) {
this.s3ArnableFields = s3ArnableFields;
return this;
}
public void setS3ArnableFields(Map<String, S3ArnableFieldConfig> s3ArnableFields) {
this.s3ArnableFields = s3ArnableFields;
}
public boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations() {
return allowEndpointOverrideForEndpointDiscoveryRequiredOperations;
}
public void setAllowEndpointOverrideForEndpointDiscoveryRequiredOperations(
boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations) {
this.allowEndpointOverrideForEndpointDiscoveryRequiredOperations =
allowEndpointOverrideForEndpointDiscoveryRequiredOperations;
}
public Map<String, List<String>> getUseLegacyEventGenerationScheme() {
return useLegacyEventGenerationScheme;
}
public void setUseLegacyEventGenerationScheme(Map<String, List<String>> useLegacyEventGenerationScheme) {
this.useLegacyEventGenerationScheme = useLegacyEventGenerationScheme;
}
public UnderscoresInNameBehavior getUnderscoresInNameBehavior() {
return underscoresInNameBehavior;
}
public void setUnderscoresInNameBehavior(UnderscoresInNameBehavior behavior) {
this.underscoresInNameBehavior = behavior;
}
public CustomizationConfig withUnderscoresInShapeNameBehavior(UnderscoresInNameBehavior behavior) {
this.underscoresInNameBehavior = behavior;
return this;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public CustomizationConfig withUserAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}
public RetryMode getDefaultRetryMode() {
return defaultRetryMode;
}
public void setDefaultRetryMode(RetryMode defaultRetryMode) {
this.defaultRetryMode = defaultRetryMode;
}
public ServiceConfig getServiceConfig() {
return serviceConfig;
}
public void setServiceConfig(ServiceConfig serviceConfig) {
this.serviceConfig = serviceConfig;
}
public boolean isDelegateAsyncClientClass() {
return delegateAsyncClientClass;
}
public void setDelegateAsyncClientClass(boolean delegateAsyncClientClass) {
this.delegateAsyncClientClass = delegateAsyncClientClass;
}
public boolean isSkipEndpointTestGeneration() {
return skipEndpointTestGeneration;
}
public void setSkipEndpointTestGeneration(boolean skipEndpointTestGeneration) {
this.skipEndpointTestGeneration = skipEndpointTestGeneration;
}
public boolean useGlobalEndpoint() {
return useGlobalEndpoint;
}
public void setUseGlobalEndpoint(boolean useGlobalEndpoint) {
this.useGlobalEndpoint = useGlobalEndpoint;
}
public Map<String, String> getSkipEndpointTests() {
return skipEndpointTests;
}
public void setSkipEndpointTests(Map<String, String> skipEndpointTests) {
this.skipEndpointTests = skipEndpointTests;
}
public boolean useRuleBasedEndpoints() {
return useRuleBasedEndpoints;
}
public void setUseRuleBasedEndpoints(boolean useRuleBasedEndpoints) {
this.useRuleBasedEndpoints = useRuleBasedEndpoints;
}
}