Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions .doc_gen/metadata/iot_sitewise_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,6 @@ iotsitewise_CreateGateway:
- iotsitewise.JavaScript.Basics.createGateway
services:
iotsitewise: {CreateGateway}
iotsitewise_DescribePortal:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- sitewise.java2.describe.portal.main
Python:
versions:
- sdk_version: 3
github: python/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- python.example_code.iotsitewise.IoTSitewiseWrapper.decl
- python.example_code.iotsitewise.CreateGateway
JavaScript:
versions:
- sdk_version: 3
github: javascriptv3/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- iotsitewise.JavaScript.Basics.describePortal
services:
iotsitewise: {DescribePortal}
iotsitewise_ListAssetModels:
languages:
Java:
Expand Down Expand Up @@ -177,64 +148,6 @@ iotsitewise_ListAssetModels:
- iotsitewise.JavaScript.Basics.listAssetModels
services:
iotsitewise: {ListAssetModels}
iotsitewise_DeletePortal:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- sitewise.java2.delete.portal.main
Python:
versions:
- sdk_version: 3
github: python/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- python.example_code.iotsitewise.IoTSitewiseWrapper.decl
- python.example_code.iotsitewise.DeletePortal
JavaScript:
versions:
- sdk_version: 3
github: javascriptv3/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- iotsitewise.JavaScript.Basics.deletePortal
services:
iotsitewise: {DeletePortal}
iotsitewise_CreatePortal:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- sitewise.java2.create.portal.main
Python:
versions:
- sdk_version: 3
github: python/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- python.example_code.iotsitewise.IoTSitewiseWrapper.decl
- python.example_code.iotsitewise.CreatePortal
JavaScript:
versions:
- sdk_version: 3
github: javascriptv3/example_code/iotsitewise
excerpts:
- description:
snippet_tags:
- iotsitewise.JavaScript.Basics.createPortal
services:
iotsitewise: {CreatePortal}
iotsitewise_DeleteAssetModel:
languages:
Java:
Expand Down
3 changes: 0 additions & 3 deletions javascriptv3/example_code/iotsitewise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ Code excerpts that show you how to call individual service functions.
- [CreateAsset](actions/create-asset.js#L4)
- [CreateAssetModel](actions/create-asset-model.js#L4)
- [CreateGateway](actions/create-gateway.js#L4)
- [CreatePortal](actions/create-portal.js#L4)
- [DeleteAsset](actions/delete-asset.js#L4)
- [DeleteAssetModel](actions/delete-asset-model.js#L4)
- [DeleteGateway](actions/delete-gateway.js#L4)
- [DeletePortal](actions/delete-portal.js#L4)
- [DescribeAssetModel](actions/describe-asset-model.js#L4)
- [DescribeGateway](actions/describe-gateway.js#L4)
- [DescribePortal](actions/describe-portal.js#L4)
- [GetAssetPropertyValue](actions/get-asset-property-value.js#L4)
- [ListAssetModels](actions/list-asset-models.js#L4)

Expand Down
11 changes: 4 additions & 7 deletions javav2/example_code/iotsitewise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ Code excerpts that show you how to call individual service functions.
- [BatchPutAssetPropertyValue](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L169)
- [CreateAsset](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L138)
- [CreateAssetModel](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L88)
- [CreateGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L468)
- [CreatePortal](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L347)
- [CreateGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L378)
- [DeleteAsset](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L293)
- [DeleteAssetModel](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L320)
- [DeleteGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L513)
- [DeletePortal](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L381)
- [DeleteGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L423)
- [DescribeAssetModel](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L264)
- [DescribeGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L540)
- [DescribePortal](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L439)
- [DescribeGateway](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L450)
- [GetAssetPropertyValue](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L233)
- [ListAssetModels](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L408)
- [ListAssetModels](src/main/java/com/example/iotsitewise/scenario/SitewiseActions.java#L347)


<!--custom.examples.start-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,67 +344,6 @@ public CompletableFuture<DeleteAssetModelResponse> deleteAssetModelAsync(String
}
// snippet-end:[sitewise.java2.delete.asset.model.main]

// snippet-start:[sitewise.java2.create.portal.main]
/**
* Creates a new IoT SiteWise portal.
*
* @param portalName the name of the portal to create.
* @param iamRole the IAM role ARN to use for the portal.
* @param contactEmail the email address of the portal contact.
* @return a {@link CompletableFuture} that represents a {@link String} result of the portal ID. The calling code
* can attach callbacks, then handle the result or exception by calling {@link CompletableFuture#join()} or
* {@link CompletableFuture#get()}.
* <p>
* If any completion stage in this method throws an exception, the method logs the exception cause and keeps
* it available to the calling code as a {@link CompletionException}. By calling
* {@link CompletionException#getCause()}, the calling code can access the original exception.
*/
public CompletableFuture<String> createPortalAsync(String portalName, String iamRole, String contactEmail) {
CreatePortalRequest createPortalRequest = CreatePortalRequest.builder()
.portalName(portalName)
.portalDescription("This is my custom IoT SiteWise portal.")
.portalContactEmail(contactEmail)
.roleArn(iamRole)
.build();

return getAsyncClient().createPortal(createPortalRequest)
.handle((response, exception) -> {
if (exception != null) {
logger.error("Failed to create portal: {} ", exception.getCause().getMessage());
throw (CompletionException) exception;
}
return response.portalId();
});
}
// snippet-end:[sitewise.java2.create.portal.main]

// snippet-start:[sitewise.java2.delete.portal.main]
/**
* Deletes a portal.
*
* @param portalId the ID of the portal to be deleted.
* @return a {@link CompletableFuture} that represents a {@link DeletePortalResponse}. The calling code can attach
* callbacks, then handle the result or exception by calling {@link CompletableFuture#join()} or
* {@link CompletableFuture#get()}.
* <p>
* If any completion stage in this method throws an exception, the method logs the exception cause and keeps
* it available to the calling code as a {@link CompletionException}. By calling
* {@link CompletionException#getCause()}, the calling code can access the original exception.
*/
public CompletableFuture<DeletePortalResponse> deletePortalAsync(String portalId) {
DeletePortalRequest deletePortalRequest = DeletePortalRequest.builder()
.portalId(portalId)
.build();

return getAsyncClient().deletePortal(deletePortalRequest)
.whenComplete((response, exception) -> {
if (exception != null) {
logger.error("Failed to delete portal with ID: {}. Error: {}", portalId, exception.getCause().getMessage());
}
});
}
// snippet-end:[sitewise.java2.delete.portal.main]

// snippet-start:[sitewise.java2.list.asset.model.main]
/**
* Retrieves the asset model ID for the given asset model name.
Expand Down Expand Up @@ -436,35 +375,6 @@ public CompletableFuture<String> getAssetModelIdAsync(String assetModelName) {
}
// snippet-end:[sitewise.java2.list.asset.model.main]

// snippet-start:[sitewise.java2.describe.portal.main]
/**
* Retrieves a portal's description.
*
* @param portalId the ID of the portal to describe.
* @return a {@link CompletableFuture} that represents a {@link String} result of the portal's start URL
* (see: {@link DescribePortalResponse#portalStartUrl()}). The calling code can attach callbacks, then handle the
* result or exception by calling {@link CompletableFuture#join()} or {@link CompletableFuture#get()}.
* <p>
* If any completion stage in this method throws an exception, the method logs the exception cause and keeps
* it available to the calling code as a {@link CompletionException}. By calling
* {@link CompletionException#getCause()}, the calling code can access the original exception.
*/
public CompletableFuture<String> describePortalAsync(String portalId) {
DescribePortalRequest request = DescribePortalRequest.builder()
.portalId(portalId)
.build();

return getAsyncClient().describePortal(request)
.handle((response, exception) -> {
if (exception != null) {
logger.error("An exception occurred retrieving the portal description: {}", exception.getCause().getMessage());
throw (CompletionException) exception;
}
return response.portalStartUrl();
});
}
// snippet-end:[sitewise.java2.describe.portal.main]

// snippet-start:[sitewise.java2.create.gateway.main]

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,53 +219,7 @@ public static void runScenario(String assetModelName, String assetName, String
logger.info(DASHES);

logger.info(DASHES);
logger.info("6. Create an IoT SiteWise Portal");
logger.info("""
An IoT SiteWise Portal allows you to aggregate data from multiple industrial sources,
such as sensors, equipment, and control systems, into a centralized platform.
""");
waitForInputToContinue(scanner);
String portalId;
try {
portalId = sitewiseActions.createPortalAsync(portalName, iamRole, contactEmail).join();
logger.info("Portal created successfully. Portal ID {}", portalId);
} catch (CompletionException ce) {
Throwable cause = ce.getCause();
if (cause instanceof IoTSiteWiseException siteWiseEx) {
logger.error("IoT SiteWise error occurred: Error message: {}, Error code {}",
siteWiseEx.getMessage(), siteWiseEx.awsErrorDetails().errorCode(), siteWiseEx);
} else {
logger.error("An unexpected error occurred: {}", cause.getMessage());
}
return;
}
waitForInputToContinue(scanner);
logger.info(DASHES);

logger.info(DASHES);
logger.info("7. Describe the Portal");
logger.info("""
In this step, we get a description of the portal and display the portal URL.
""");
waitForInputToContinue(scanner);
try {
String portalUrl = sitewiseActions.describePortalAsync(portalId).join();
logger.info("Portal URL: {}", portalUrl);
} catch (CompletionException ce) {
Throwable cause = ce.getCause();
if (cause instanceof ResourceNotFoundException notFoundException) {
logger.error("A ResourceNotFoundException occurred: Error message: {}, Error code {}",
notFoundException.getMessage(), notFoundException.awsErrorDetails().errorCode(), notFoundException);
} else {
logger.error("An unexpected error occurred: {}", cause.getMessage());
}
return;
}
waitForInputToContinue(scanner);
logger.info(DASHES);

logger.info(DASHES);
logger.info("8. Create an IoT SiteWise Gateway");
logger.info("6. Create an IoT SiteWise Gateway");
logger.info(
"""
IoT SiteWise Gateway serves as the bridge between industrial equipment, sensors, and the
Expand All @@ -292,7 +246,7 @@ public static void runScenario(String assetModelName, String assetName, String
logger.info(DASHES);
logger.info(DASHES);

logger.info("9. Describe the IoT SiteWise Gateway");
logger.info("7. Describe the IoT SiteWise Gateway");
waitForInputToContinue(scanner);
try {
sitewiseActions.describeGatewayAsync(gatewayId)
Expand All @@ -315,7 +269,7 @@ public static void runScenario(String assetModelName, String assetName, String
logger.info(DASHES);

logger.info(DASHES);
logger.info("10. Delete the AWS IoT SiteWise Assets");
logger.info("8. Delete the AWS IoT SiteWise Assets");
logger.info(
"""
Before you can delete the Asset Model, you must delete the assets.
Expand All @@ -325,20 +279,6 @@ public static void runScenario(String assetModelName, String assetName, String
String delAns = scanner.nextLine().trim();
if (delAns.equalsIgnoreCase("y")) {
logger.info("You selected to delete the SiteWise assets.");
waitForInputToContinue(scanner);
try {
sitewiseActions.deletePortalAsync(portalId).join();
logger.info("Portal {} was deleted successfully.", portalId);

} catch (CompletionException ce) {
Throwable cause = ce.getCause();
if (cause instanceof ResourceNotFoundException notFoundException) {
logger.error("A ResourceNotFoundException occurred: Error message: {}, Error code {}",
notFoundException.getMessage(), notFoundException.awsErrorDetails().errorCode(), notFoundException);
} else {
logger.error("An unexpected error occurred: {}", cause.getMessage());
}
}

try {
sitewiseActions.deleteGatewayAsync(gatewayId).join();
Expand Down
Loading
Loading