|
| 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 | +namespace Amazon.DynamoDBv2.DataModel |
| 17 | +{ |
| 18 | + /// <summary> |
| 19 | + /// Base class for operation-specific configurations for DynamoDB object persistence operations. |
| 20 | + /// </summary> |
| 21 | + /// <remarks> |
| 22 | + /// This should only contain members that are relevant to all object persistence operations, |
| 23 | + /// anything operation-specific should be added to derived classes. |
| 24 | + /// </remarks> |
| 25 | +#if NET8_0_OR_GREATER |
| 26 | + // The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible |
| 27 | + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)] |
| 28 | +#endif |
| 29 | + public abstract class BaseOperationConfig |
| 30 | + { |
| 31 | + /// <summary> |
| 32 | + /// Indicates which DynamoDB table to use. This overrides the table specified |
| 33 | + /// by the <see cref="DynamoDBTableAttribute"/> on the .NET objects that you're saving or loading. |
| 34 | + /// </summary> |
| 35 | + public string OverrideTableName { get; set; } |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Directs <see cref="DynamoDBContext"/> to prefix all table names |
| 39 | + /// with a specific string. If this is null or empty, no prefix is used |
| 40 | + /// and default table names are used. |
| 41 | + /// </summary> |
| 42 | + public string TableNamePrefix { get; set; } |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// The object persistence model API relies on an internal cache of the DynamoDB table's metadata to |
| 46 | + /// construct and validate requests. This controls how the cache key is derived, which influences |
| 47 | + /// when the SDK will call DescribeTable internally to populate the cache. |
| 48 | + /// </summary> |
| 49 | + /// <remarks> |
| 50 | + /// For <see cref="MetadataCachingMode.Default"/> the cache key will be a combination of the table name, credentials, region and service URL. |
| 51 | + /// For <see cref="MetadataCachingMode.TableNameOnly"/> the cache key will only consist of the table name. This reduces cache misses in contexts |
| 52 | + /// where you are accessing tables with identical structure but using different credentials or endpoints (such as a multi-tenant application). |
| 53 | + /// </remarks> |
| 54 | + public MetadataCachingMode? MetadataCachingMode { get; set; } |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// If true disables fetching table metadata automatically from DynamoDB. Table metadata must be |
| 58 | + /// defined by <see cref="DynamoDBAttribute"/> attributes and/or in <see cref = "AWSConfigsDynamoDB"/>. |
| 59 | + /// </summary> |
| 60 | + /// <remarks> |
| 61 | + /// Setting this to true can avoid latency and thread starvation due to blocking asynchronous |
| 62 | + /// DescribeTable calls that are used to populate the SDK's cache of table metadata. |
| 63 | + /// It requires that the table's index schema be accurately described via the above methods, |
| 64 | + /// otherwise exceptions may be thrown and/or the results of certain DynamoDB operations may change. |
| 65 | + /// </remarks> |
| 66 | + public bool? DisableFetchingTableMetadata { get; set; } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Specification which controls the conversion between .NET and DynamoDB types. |
| 70 | + /// </summary> |
| 71 | + public DynamoDBEntryConversion Conversion { get; set; } |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Controls how <see cref="DynamoDBContext"/> interprets empty string values. |
| 75 | + /// If the property is false (or not set), empty string values will be |
| 76 | + /// interpreted as null values. |
| 77 | + /// </summary> |
| 78 | + public bool? IsEmptyStringValueEnabled { get; set; } |
| 79 | + |
| 80 | + /// <summary> |
| 81 | + /// Converts this to the shared <see cref="DynamoDBOperationConfig"/> |
| 82 | + /// </summary> |
| 83 | + /// <remarks> |
| 84 | + /// Users should interact with the new, operation-specific configs, but we |
| 85 | + /// convert to the internal shared config for the internal code paths. |
| 86 | + /// </remarks> |
| 87 | + /// <returns>A new <see cref="DynamoDBOperationConfig"/> with settings copied from the operation-specific config</returns> |
| 88 | + internal virtual DynamoDBOperationConfig ToDynamoDBOperationConfig() |
| 89 | + { |
| 90 | + return new DynamoDBOperationConfig() |
| 91 | + { |
| 92 | + OverrideTableName = OverrideTableName, |
| 93 | + TableNamePrefix = TableNamePrefix, |
| 94 | + MetadataCachingMode = MetadataCachingMode, |
| 95 | + DisableFetchingTableMetadata = DisableFetchingTableMetadata, |
| 96 | + Conversion = Conversion, |
| 97 | + IsEmptyStringValueEnabled = IsEmptyStringValueEnabled |
| 98 | + }; |
| 99 | + } |
| 100 | + } |
| 101 | +} |
0 commit comments