1515import software .amazon .awssdk .services .iotsitewise .model .DescribeGatewayRequest ;
1616import software .amazon .awssdk .services .iotsitewise .model .DescribeGatewayResponse ;
1717import software .amazon .awssdk .core .client .config .ClientOverrideConfiguration ;
18- import software .amazon .awssdk .core .retry .RetryPolicy ;
1918import software .amazon .awssdk .http .async .SdkAsyncHttpClient ;
2019import software .amazon .awssdk .http .nio .netty .NettyNioAsyncHttpClient ;
2120import software .amazon .awssdk .services .iotsitewise .IoTSiteWiseAsyncClient ;
2827import software .amazon .awssdk .services .iotsitewise .model .CreateAssetRequest ;
2928import software .amazon .awssdk .services .iotsitewise .model .CreateAssetResponse ;
3029import software .amazon .awssdk .services .iotsitewise .model .CreatePortalRequest ;
31- import software .amazon .awssdk .services .iotsitewise .model .CreatePortalResponse ;
3230import software .amazon .awssdk .services .iotsitewise .model .DeleteAssetModelRequest ;
3331import software .amazon .awssdk .services .iotsitewise .model .DeleteAssetModelResponse ;
3432import software .amazon .awssdk .services .iotsitewise .model .DeleteAssetRequest ;
4846import software .amazon .awssdk .services .iotsitewise .model .PutAssetPropertyValueEntry ;
4947import software .amazon .awssdk .services .iotsitewise .model .TimeInNanos ;
5048import software .amazon .awssdk .services .iotsitewise .model .Variant ;
49+
5150import java .time .Duration ;
5251import java .time .Instant ;
5352import java .util .Arrays ;
@@ -88,8 +87,9 @@ private static IoTSiteWiseAsyncClient getAsyncClient() {
8887 }
8988
9089 // snippet-start:[sitewise.java2_create_asset_model.main]
90+
9191 /**
92- * Creates an asset model asynchronously .
92+ * Creates an asset model.
9393 *
9494 * @param name the name of the asset model to create
9595 * @return a {@link CompletableFuture} that completes with the created {@link CreateAssetModelResponse} when the operation is complete
@@ -115,7 +115,6 @@ public CompletableFuture<CreateAssetModelResponse> createAssetModelAsync(String
115115 .type (humidity )
116116 .build ();
117117
118-
119118 CreateAssetModelRequest createAssetModelRequest = CreateAssetModelRequest .builder ()
120119 .assetModelName (name )
121120 .assetModelDescription ("This is my asset model" )
@@ -133,10 +132,11 @@ public CompletableFuture<CreateAssetModelResponse> createAssetModelAsync(String
133132 // snippet-end:[sitewise.java2_create_asset_model.main]
134133
135134 // snippet-start:[sitewise.java2_create_asset.main]
135+
136136 /**
137- * Asynchronously creates an asset with the specified name and model ARN.
137+ * Creates an asset with the specified name and model ARN.
138138 *
139- * @param assetName the name of the asset to create
139+ * @param assetName the name of the asset to create
140140 * @param assetModelArn the ARN of the asset model to associate with the asset
141141 * @return a {@link CompletableFuture} that completes with the {@link CreateAssetResponse} when the asset creation is complete
142142 * @throws RuntimeException if the asset creation fails
@@ -153,12 +153,21 @@ public CompletableFuture<CreateAssetResponse> createAssetAsync(String assetName,
153153 if (exception != null ) {
154154 throw new RuntimeException ("Failed to create asset: " + exception .getMessage (), exception );
155155 }
156- return response ; // Return the response if successful
156+ return response ;
157157 });
158158 }
159159 // snippet-end:[sitewise.java2_create_asset.main]
160160
161161 // snippet-start:[sitewise.java2_put_batch_property.main]
162+
163+ /**
164+ * Sends data to the SiteWise service.
165+ *
166+ * @param assetId the ID of the asset to which the data will be sent
167+ * @param tempPropertyId the ID of the temperature property
168+ * @param humidityPropId the ID of the humidity property
169+ * @return a CompletableFuture representing the response from the SiteWise service
170+ */
162171 public CompletableFuture <BatchPutAssetPropertyValueResponse > sendDataToSiteWiseAsync (String assetId , String tempPropertyId , String humidityPropId ) {
163172 Map <String , Double > sampleData = generateSampleData ();
164173 long timestamp = Instant .now ().toEpochMilli ();
@@ -211,7 +220,15 @@ public CompletableFuture<BatchPutAssetPropertyValueResponse> sendDataToSiteWiseA
211220 // snippet-end:[sitewise.java2_put_batch_property.main]
212221
213222 // snippet-start:[sitewise.java2_get_property.main]
214- // TODO -- fix this including Javadoc
223+
224+ /**
225+ * Asynchronously fetches the value of an asset property.
226+ *
227+ * @param propName the name of the asset property to fetch
228+ * @param propId the ID of the asset property to fetch
229+ * @param assetId the ID of the asset to fetch the property value for
230+ * @throws RuntimeException if an error occurs while fetching the property value
231+ */
215232 public void getAssetPropValueAsync (String propName , String propId , String assetId ) {
216233 GetAssetPropertyValueRequest assetPropertyValueRequest = GetAssetPropertyValueRequest .builder ()
217234 .propertyId (propId )
@@ -232,26 +249,31 @@ public void getAssetPropValueAsync(String propName, String propId, String assetI
232249 // snippet-end:[sitewise.java2_get_property.main]
233250
234251 // snippet-start:[sitewise.java2.describe.asset.model.main]
252+
235253 /**
236- * @param assetModelId The Id of the asset model.
237- * @return A map of the asset model properties when the CompletableFuture completes.
254+ * Retrieves the property IDs associated with a specific asset model.
255+ *
256+ * @param assetModelId the ID of the asset model to retrieve the property IDs for
257+ * @return a {@link CompletableFuture} that, when completed, contains a {@link Map} mapping the property names to their corresponding IDs
258+ * @throws CompletionException if an error occurs while retrieving the asset model properties
238259 */
239- public CompletableFuture <Map <String , String >> getPropertyIds (String assetModelId ){
260+ public CompletableFuture <Map <String , String >> getPropertyIds (String assetModelId ) {
240261 ListAssetModelPropertiesRequest modelPropertiesRequest = ListAssetModelPropertiesRequest .builder ().assetModelId (assetModelId ).build ();
241262 return getAsyncClient ().listAssetModelProperties (modelPropertiesRequest )
242- .handle ( (response , throwable ) -> {
243- if (response != null ){
244- return response .assetModelPropertySummaries ().stream ()
245- .collect (Collectors
246- .toMap (AssetModelPropertySummary ::name , AssetModelPropertySummary ::id ));
247- } else {
248- throw (CompletionException ) throwable .getCause ();
249- }
250- });
263+ .handle ((response , throwable ) -> {
264+ if (response != null ) {
265+ return response .assetModelPropertySummaries ().stream ()
266+ .collect (Collectors
267+ .toMap (AssetModelPropertySummary ::name , AssetModelPropertySummary ::id ));
268+ } else {
269+ throw (CompletionException ) throwable .getCause ();
270+ }
271+ });
251272 }
252273 // snippet-end:[sitewise.java2.describe.asset.model.main]
253274
254275 // snippet-start:[sitewise.java2.delete.asset.main]
276+
255277 /**
256278 * Deletes an asset asynchronously.
257279 *
@@ -277,7 +299,7 @@ public CompletableFuture<DeleteAssetResponse> deleteAssetAsync(String assetId) {
277299
278300 // snippet-start:[sitewise.java2.delete.asset.model.main]
279301 /**
280- * Asynchronously deletes an Asset Model with the specified ID.
302+ * Deletes an Asset Model with the specified ID.
281303 *
282304 * @param assetModelId the ID of the Asset Model to delete
283305 * @return a {@link CompletableFuture} that completes with the {@link DeleteAssetModelResponse} when the operation is complete
@@ -298,11 +320,12 @@ public CompletableFuture<DeleteAssetModelResponse> deleteAssetModelAsync(String
298320 // snippet-end:[sitewise.java2.delete.asset.model.main]
299321
300322 // snippet-start:[sitewise.java2.create.portal.main]
323+
301324 /**
302- * Creates a new IoT SiteWise portal asynchronously .
325+ * Creates a new IoT SiteWise portal.
303326 *
304- * @param portalName the name of the portal to create
305- * @param iamRole the IAM role ARN to use for the portal
327+ * @param portalName the name of the portal to create
328+ * @param iamRole the IAM role ARN to use for the portal
306329 * @param contactEmail the email address of the portal contact
307330 * @return a {@link CompletableFuture} that completes with the portal ID when the portal is created successfully, or throws a {@link RuntimeException} if the creation fails
308331 */
@@ -315,7 +338,7 @@ public CompletableFuture<String> createPortalAsync(String portalName, String iam
315338 .build ();
316339
317340 return getAsyncClient ().createPortal (createPortalRequest )
318- .handle ((response , exception ) -> {
341+ .handle ((response , exception ) -> {
319342 if (exception != null ) {
320343 logger .error ("Failed to create portal: {} " , exception .getCause ().getMessage ());
321344 throw (CompletionException ) exception ;
@@ -327,7 +350,7 @@ public CompletableFuture<String> createPortalAsync(String portalName, String iam
327350
328351 // snippet-start:[sitewise.java2.delete.portal.main]
329352 /**
330- * Deletes a portal asynchronously .
353+ * Deletes a portal.
331354 *
332355 * @param portalId the ID of the portal to be deleted
333356 * @return a {@link CompletableFuture} containing the {@link DeletePortalResponse} when the operation is complete
@@ -349,7 +372,7 @@ public CompletableFuture<DeletePortalResponse> deletePortalAsync(String portalId
349372
350373 // snippet-start:[sitewise.java2.list.asset.model.main]
351374 /**
352- * Retrieves the asset model ID asynchronously for the given asset model name.
375+ * Retrieves the asset model ID for the given asset model name.
353376 *
354377 * @param assetModelName the name of the asset model to retrieve the ID for
355378 * @return a {@link CompletableFuture} that, when completed, contains the asset model ID, or {@code null} if the asset model is not found
@@ -363,7 +386,7 @@ public CompletableFuture<String> getAssetModelIdAsync(String assetModelName) {
363386 }
364387 for (AssetModelSummary assetModelSummary : listAssetModelsResponse .assetModelSummaries ()) {
365388 if (assetModelSummary .name ().equals (assetModelName )) {
366- return assetModelSummary .id (); // Return the ARN if found.
389+ return assetModelSummary .id ();
367390 }
368391 }
369392 return null ;
@@ -433,6 +456,13 @@ public CompletableFuture<String> createGatewayAsync(String gatewayName, String m
433456 // snippet-end:[sitewise.java2.create.gateway.main]
434457
435458 // snippet-start:[sitewise.java2.delete.gateway.main]
459+
460+ /**
461+ * Deletes the specified gateway asynchronously.
462+ *
463+ * @param gatewayARN the Amazon Resource Name (ARN) of the gateway to be deleted
464+ * @return a {@link CompletableFuture} representing the asynchronous operation of deleting the gateway
465+ */
436466 public CompletableFuture <DeleteGatewayResponse > deleteGatewayAsync (String gatewayARN ) {
437467 DeleteGatewayRequest deleteGatewayRequest = DeleteGatewayRequest .builder ()
438468 .gatewayId (gatewayARN )
@@ -450,6 +480,14 @@ public CompletableFuture<DeleteGatewayResponse> deleteGatewayAsync(String gatewa
450480 // snippet-end:[sitewise.java2.delete.gateway.main]
451481
452482 // snippet-start:[sitewise.java2.describe.gateway.main]
483+ /**
484+ * Asynchronously describes the specified gateway.
485+ *
486+ * @param gatewayId the ID of the gateway to describe
487+ * @return a {@link CompletableFuture} that represents the asynchronous operation,
488+ * which will complete with a {@link DescribeGatewayResponse} containing
489+ * information about the specified gateway
490+ */
453491 public CompletableFuture <DescribeGatewayResponse > describeGatewayAsync (String gatewayId ) {
454492 DescribeGatewayRequest request = DescribeGatewayRequest .builder ()
455493 .gatewayId (gatewayId )
0 commit comments