Skip to content

Commit 69632b4

Browse files
committed
added IoT Fleetwise snippet tags
1 parent 72c644f commit 69632b4

1 file changed

Lines changed: 43 additions & 6 deletions

File tree

javav2/example_code/iotfleetwise/src/main/java/com/example/fleetwise/scenario/FleetwiseActions.java

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.concurrent.atomic.AtomicInteger;
2626
import java.util.concurrent.atomic.AtomicReference;
2727

28+
// snippet-start:[iotfleetwise.java2.scenario.actions.main]
2829
public class FleetwiseActions {
2930
private static IoTFleetWiseAsyncClient ioTFleetWiseAsyncClient;
3031

@@ -51,6 +52,7 @@ private static IoTFleetWiseAsyncClient getAsyncClient() {
5152
return ioTFleetWiseAsyncClient;
5253
}
5354

55+
// snippet-start:[iotfleetwise.java2.create.catalog.main]
5456
/**
5557
* Creates a signal catalog asynchronously.
5658
*
@@ -106,6 +108,7 @@ public CompletableFuture<String> createSignalCatalogAsync(String signalCatalogNa
106108
.thenApply(CreateSignalCatalogResponse::arn);
107109
});
108110
}
111+
// snippet-end:[iotfleetwise.java2.create.catalog.main]
109112

110113
/**
111114
* Delays the execution of the current thread asynchronously for the specified duration.
@@ -124,7 +127,7 @@ private static CompletableFuture<Void> delayAsync(long millis) {
124127
});
125128
}
126129

127-
130+
// snippet-start:[iotfleetwise.java2.delete.catalog.main]
128131
/**
129132
* Deletes the specified signal catalog asynchronously, if it exists.
130133
*
@@ -151,7 +154,9 @@ public static CompletableFuture<Void> deleteSignalCatalogIfExistsAsync(String si
151154
return null;
152155
});
153156
}
157+
// snippet-end:[iotfleetwise.java2.delete.catalog.main]
154158

159+
// snippet-start:[iotfleetwise.java2.create.decoder.main]
155160
/**
156161
* Creates a new decoder manifest asynchronously.
157162
*
@@ -222,7 +227,16 @@ public CompletableFuture<String> createDecoderManifestAsync(String name, String
222227
})
223228
.thenApply(CreateDecoderManifestResponse::arn);
224229
}
230+
// snippet-end:[iotfleetwise.java2.create.decoder.main]
225231

232+
// snippet-start:[iotfleetwise.java2.delete.decoder.main]
233+
/**
234+
* Deletes a decoder manifest asynchronously.
235+
*
236+
* @param name the name of the decoder manifest to delete
237+
* @return a {@link CompletableFuture} that completes when the decoder manifest has been deleted
238+
* @throws RuntimeException if the deletion of the decoder manifest fails
239+
*/
226240
public CompletableFuture<Void> deleteDecoderManifestAsync(String name) {
227241
DeleteDecoderManifestRequest request = DeleteDecoderManifestRequest.builder()
228242
.name(name)
@@ -238,7 +252,9 @@ public CompletableFuture<Void> deleteDecoderManifestAsync(String name) {
238252
})
239253
.thenApply(response -> null); // Return CompletableFuture<Void>
240254
}
255+
// snippet-end:[iotfleetwise.java2.delete.decoder.main]
241256

257+
// snippet-start:[iotfleetwise.java2.delete.vehicle.main]
242258
/**
243259
* Asynchronously deletes a vehicle with the specified name.
244260
*
@@ -261,8 +277,9 @@ public CompletableFuture<Void> deleteVehicleAsync(String vecName) {
261277
})
262278
.thenApply(response -> null); // Return CompletableFuture<Void>
263279
}
280+
// snippet-end:[iotfleetwise.java2.delete.vehicle.main]
264281

265-
282+
// snippet-start:[iotfleetwise.java2.update.manifest.main]
266283
/**
267284
* Updates the model manifest asynchronously.
268285
*
@@ -282,7 +299,9 @@ public void updateModelManifestAsync(String name) {
282299
})
283300
.thenApply(response -> null);
284301
}
302+
// snippet-end:[iotfleetwise.java2.update.manifest.main]
285303

304+
// snippet-start:[iotfleetwise.java2.update.decoder.main]
286305
/**
287306
* Asynchronously updates the decoder manifest with the given name.
288307
*
@@ -304,7 +323,9 @@ public CompletableFuture<Void> updateDecoderManifestAsync(String name) {
304323
})
305324
.thenApply(response -> null); // Return void-equivalent
306325
}
326+
// snippet-end:[iotfleetwise.java2.update.decoder.main]
307327

328+
// snippet-start:[iotfleetwise.java2.create.vehicle.main]
308329
/**
309330
* Asynchronously creates a new vehicle in the system.
310331
*
@@ -331,7 +352,9 @@ public CompletableFuture<Void> createVehicleAsync(String vecName, String manifes
331352
})
332353
.thenApply(response -> null); // Void return type
333354
}
355+
// snippet-end:[iotfleetwise.java2.create.vehicle.main]
334356

357+
// snippet-start:[iotfleetwise.java2.decoder.active.main]
335358
/**
336359
* Waits for the decoder manifest to become active asynchronously.
337360
*
@@ -346,7 +369,6 @@ public CompletableFuture<Void> waitForDecoderManifestActiveAsync(String decoderN
346369
AtomicReference<ManifestStatus> lastStatus = new AtomicReference<>(ManifestStatus.DRAFT);
347370

348371
System.out.print("⏳ Elapsed: 0s | Decoder Status: DRAFT");
349-
350372
final Runnable pollTask = new Runnable() {
351373
@Override
352374
public void run() {
@@ -385,7 +407,6 @@ public void run() {
385407
}
386408
});
387409
} else {
388-
// Still print even if not polling yet
389410
System.out.print("\r⏱️ Elapsed: " + elapsed + "s | Decoder Status: " + lastStatus.get());
390411
}
391412
}
@@ -394,8 +415,9 @@ public void run() {
394415
scheduler.scheduleAtFixedRate(pollTask, 1, 1, TimeUnit.SECONDS);
395416
return result;
396417
}
418+
// snippet-end:[iotfleetwise.java2.decoder.active.main]
397419

398-
420+
// snippet-start:[iotfleetwise.java2.get.manifest.main]
399421
/**
400422
* Waits for the specified model manifest to become active.
401423
*
@@ -410,7 +432,6 @@ public CompletableFuture<Void> waitForModelManifestActiveAsync(String manifestNa
410432
AtomicReference<ManifestStatus> lastStatus = new AtomicReference<>(ManifestStatus.DRAFT);
411433

412434
System.out.print("⏳ Elapsed: 0s | Status: DRAFT");
413-
414435
final Runnable pollTask = new Runnable() {
415436
@Override
416437
public void run() {
@@ -458,7 +479,9 @@ public void run() {
458479
scheduler.scheduleAtFixedRate(pollTask, 1, 1, TimeUnit.SECONDS);
459480
return result;
460481
}
482+
// snippet-end:[iotfleetwise.java2.get.manifest.main]
461483

484+
// snippet-start:[iotfleetwise.java2.get.vehicle.main]
462485
/**
463486
* Asynchronously fetches the details of a vehicle.
464487
*
@@ -493,6 +516,7 @@ public CompletableFuture<Void> getVehicleDetailsAsync(String vehicleName) {
493516
})
494517
.thenApply(response -> null); // returning CompletableFuture<Void>
495518
}
519+
// snippet-end:[iotfleetwise.java2.get.vehicle.main]
496520

497521
/**
498522
* Asynchronously creates an IoT Thing if it does not already exist.
@@ -524,6 +548,7 @@ public CompletableFuture<Void> createThingIfNotExistsAsync(String thingName) {
524548
.thenApply(response -> null);
525549
}
526550

551+
// snippet-start:[iotfleetwise.java2.delete.model.main]
527552
/**
528553
* Deletes a model manifest asynchronously.
529554
*
@@ -546,7 +571,9 @@ public CompletableFuture<Void> deleteModelManifestAsync(String name) {
546571
})
547572
.thenApply(response -> null); // return type is CompletableFuture<Void>
548573
}
574+
// snippet-end:[iotfleetwise.java2.delete.model.main]
549575

576+
// snippet-start:[iotfleetwise.java2.delete.catalog.main]
550577
/**
551578
* Deletes a signal catalog asynchronously.
552579
*
@@ -569,7 +596,9 @@ public CompletableFuture<Void> deleteSignalCatalogAsync(String name) {
569596
})
570597
.thenApply(response -> null); // return type is CompletableFuture<Void>
571598
}
599+
// snippet-end:[iotfleetwise.java2.delete.catalog.main]
572600

601+
// snippet-start:[iotfleetwise.java2.list.catalogs.main]
573602
/**
574603
* Lists the signal catalog nodes asynchronously.
575604
*
@@ -590,7 +619,9 @@ public CompletableFuture<List<Node>> listSignalCatalogNodeAsync(String signalCat
590619
})
591620
.thenApply(ListSignalCatalogNodesResponse::nodes); // Return the nodes
592621
}
622+
// snippet-end:[iotfleetwise.java2.list.catalogs.main]
593623

624+
// snippet-start:[iotfleetwise.java2.create.model.main]
594625
/**
595626
* Creates a model manifest asynchronously.
596627
*
@@ -634,7 +665,9 @@ public CompletableFuture<String> createModelManifestAsync(String name,
634665
})
635666
.thenApply(CreateModelManifestResponse::arn); // Return the ARN
636667
}
668+
// snippet-end:[iotfleetwise.java2.create.model.main]
637669

670+
// snippet-start:[iotfleetwise.java2.delete.fleet.main]
638671
/**
639672
* Deletes a fleet based on the provided fleet ID.
640673
*
@@ -656,8 +689,10 @@ public CompletableFuture<Void> deleteFleetAsync(String fleetId) {
656689
})
657690
.thenApply(response -> null); // Returning Void
658691
}
692+
// snippet-end:[iotfleetwise.java2.delete.fleet.main]
659693

660694

695+
// snippet-start:[iotfleetwise.java2.create.fleet.main]
661696
/**
662697
* Creates a new fleet asynchronously using the AWS SDK for Java V2.
663698
*
@@ -681,4 +716,6 @@ public CompletableFuture<String> createFleetAsync(String catARN, String fleetId)
681716
})
682717
.thenApply(CreateFleetResponse::id); // Extract fleet ID on success
683718
}
719+
// snippet-end:[iotfleetwise.java2.create.fleet.main]
684720
}
721+
// snippet-end:[iotfleetwise.java2.scenario.actions.main]

0 commit comments

Comments
 (0)