1717using Elastic . Documentation . Tooling . Diagnostics . Console ;
1818using Elastic . Documentation . Tooling . Filters ;
1919using Microsoft . Extensions . Logging ;
20- using DescribeKeyValueStoreRequest = Amazon . CloudFront . Model . DescribeKeyValueStoreRequest ;
2120
2221namespace Documentation . Assembler . Cli ;
2322
23+ internal enum KvsOperation
24+ {
25+ Puts ,
26+ Deletes
27+ }
28+
2429internal sealed class DeployCommands ( ILoggerFactory logger , ICoreService githubActionsService )
2530{
2631 [ SuppressMessage ( "Usage" , "CA2254:Template should be a static expression" ) ]
@@ -129,7 +134,7 @@ public async Task<int> UpdateRedirects(
129134
130135 ConsoleApp . Log ( "Parsing redirects mapping" ) ;
131136 var jsonContent = await File . ReadAllTextAsync ( redirectsFile , ctx ) ;
132- var sourcedRedirects = JsonSerializer . Deserialize ( jsonContent , SourceGenerationContext . Default . FrozenDictionaryStringString ) ;
137+ var sourcedRedirects = JsonSerializer . Deserialize ( jsonContent , SourceGenerationContext . Default . DictionaryStringString ) ;
133138
134139 if ( sourcedRedirects is null )
135140 {
@@ -144,7 +149,7 @@ public async Task<int> UpdateRedirects(
144149 var kvsClient = new AmazonCloudFrontKeyValueStoreClient ( ) ;
145150
146151 ConsoleApp . Log ( "Describing KVS" ) ;
147- var describeResponse = await cfClient . DescribeKeyValueStoreAsync ( new DescribeKeyValueStoreRequest { Name = kvsName } , ctx ) ;
152+ var describeResponse = await cfClient . DescribeKeyValueStoreAsync ( new Amazon . CloudFront . Model . DescribeKeyValueStoreRequest { Name = kvsName } , ctx ) ;
148153
149154 var kvsArn = describeResponse . KeyValueStore . ARN ;
150155 var eTag = describeResponse . ETag ;
@@ -171,8 +176,8 @@ public async Task<int> UpdateRedirects(
171176 ConsoleApp . Log ( "Updating redirects in KVS" ) ;
172177 const int batchSize = 500 ;
173178
174- eTag = await ProcessBatchUpdatesAsync ( kvsClient , kvsArn , eTag , toPut , batchSize , " Puts" , ctx ) ;
175- _ = await ProcessBatchUpdatesAsync ( kvsClient , kvsArn , eTag , toDelete , batchSize , " Deletes" , ctx ) ;
179+ eTag = await ProcessBatchUpdatesAsync ( kvsClient , kvsArn , eTag , toPut , batchSize , KvsOperation . Puts , ctx ) ;
180+ _ = await ProcessBatchUpdatesAsync ( kvsClient , kvsArn , eTag , toDelete , batchSize , KvsOperation . Deletes , ctx ) ;
176181
177182 await collector . StopAsync ( ctx ) ;
178183 return collector . Errors ;
@@ -184,7 +189,7 @@ private static async Task<string> ProcessBatchUpdatesAsync(
184189 string eTag ,
185190 IEnumerable < object > items ,
186191 int batchSize ,
187- string operation ,
192+ KvsOperation operation ,
188193 Cancel ctx )
189194 {
190195 var enumerable = items . ToList ( ) ;
@@ -197,9 +202,9 @@ private static async Task<string> ProcessBatchUpdatesAsync(
197202 IfMatch = eTag
198203 } ;
199204
200- if ( operation . Equals ( "Puts" , StringComparison . InvariantCulture ) )
205+ if ( operation is KvsOperation . Puts )
201206 updateRequest . Puts = batch . Cast < PutKeyRequestListItem > ( ) . ToList ( ) ;
202- else if ( operation . Equals ( "Deletes" , StringComparison . InvariantCulture ) )
207+ else if ( operation is KvsOperation . Deletes )
203208 updateRequest . Deletes = batch . Cast < DeleteKeyRequestListItem > ( ) . ToList ( ) ;
204209
205210 var update = await kvsClient . UpdateKeysAsync ( updateRequest , ctx ) ;
0 commit comments