Skip to content

Commit c55251b

Browse files
committed
updated YAML
1 parent c8d1858 commit c55251b

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

.doc_gen/metadata/inspector_metadata.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ inspector_Hello:
1616
- inspector.java2.hello.main
1717
services:
1818
inspector: {BatchGetAccountStatus, ListFindings, ListUsageTotals}
19+
inspector_DeleteFilter:
20+
languages:
21+
Java:
22+
versions:
23+
- sdk_version: 2
24+
github: javav2/example_code/inspector
25+
sdkguide:
26+
excerpts:
27+
- description:
28+
snippet_tags:
29+
- inspector.java2.delete.filter.main
30+
services:
31+
inspector: {DeleteFilter}
1932
inspector_EnableInspector:
2033
languages:
2134
Java:

javav2/example_code/inspector/src/main/java/com/java/inspector/InspectorActions.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ public CompletableFuture<String> listUsageTotalsAsync(
206206
int maxResults) {
207207

208208
logger.info("Starting usage totals paginator…");
209-
210-
// ----------------------------------------------------------
211-
// Build request
212-
// ----------------------------------------------------------
213209
ListUsageTotalsRequest.Builder builder =
214210
ListUsageTotalsRequest.builder()
215211
.maxResults(maxResults);
@@ -219,10 +215,6 @@ public CompletableFuture<String> listUsageTotalsAsync(
219215
}
220216

221217
ListUsageTotalsRequest request = builder.build();
222-
223-
// ----------------------------------------------------------
224-
// Get paginator
225-
// ----------------------------------------------------------
226218
ListUsageTotalsPublisher paginator =
227219
getAsyncClient().listUsageTotalsPaginator(request);
228220

@@ -231,9 +223,7 @@ public CompletableFuture<String> listUsageTotalsAsync(
231223

232224
CompletableFuture<String> future = new CompletableFuture<>();
233225

234-
// ----------------------------------------------------------
235226
// Subscribe with Reactive Streams Subscriber
236-
// ----------------------------------------------------------
237227
paginator.subscribe(new Subscriber<ListUsageTotalsResponse>() {
238228

239229
private Subscription subscription;
@@ -242,19 +232,17 @@ public CompletableFuture<String> listUsageTotalsAsync(
242232
@Override
243233
public void onSubscribe(Subscription s) {
244234
this.subscription = s;
245-
246235
logger.info("onSubscribe → requesting first page");
247236
s.request(1);
248237
}
249238

250239
@Override
251240
public void onNext(ListUsageTotalsResponse page) {
252241
pageCount++;
253-
254242
logger.info("onNext → received page {}", pageCount);
243+
255244
if (page.totals() != null) {
256245
logger.info("Page contains {} totals.", page.totals().size());
257-
258246
allTotals.addAll(page.totals());
259247
}
260248

@@ -264,13 +252,17 @@ public void onNext(ListUsageTotalsResponse page) {
264252

265253
@Override
266254
public void onError(Throwable t) {
267-
logger.info("paginator error: {} ", t);
255+
if (t instanceof ValidationException ve) {
256+
logger.info("Validation error: {}", ve.awsErrorDetails().errorMessage());
257+
} else {
258+
logger.info("Paginator error: {}", t);
259+
}
268260
future.completeExceptionally(t);
269261
}
270262

271263
@Override
272264
public void onComplete() {
273-
logger.info("paginator completed.");
265+
logger.info("Paginator completed.");
274266
future.complete(buildUsageSummary(allTotals));
275267
}
276268
});
@@ -628,13 +620,18 @@ public void onNext(ListFindingsResponse page) {
628620

629621
@Override
630622
public void onError(Throwable t) {
631-
logger.info("paginator error: {}", t);
623+
if (t instanceof ValidationException ve) {
624+
// Print detailed validation error.
625+
logger.info("Validation error: {}", ve.awsErrorDetails().errorMessage());
626+
} else {
627+
logger.info("Paginator error: {}", t);
628+
}
632629
future.completeExceptionally(t);
633630
}
634631

635632
@Override
636633
public void onComplete() {
637-
logger.info("paginator completed normally.");
634+
logger.info("Paginator completed normally.");
638635
future.complete(buildSummary(allFindings));
639636
}
640637
});
@@ -702,7 +699,7 @@ private String buildSummary(List<Finding> findings) {
702699
public CompletableFuture<String> listCoverageAsync(
703700
int maxResults) {
704701

705-
// Build the request
702+
// Build the request.
706703
ListCoverageRequest request = ListCoverageRequest.builder()
707704
.maxResults(maxResults)
708705
.build();

scenarios/basics/inspector/SPECIFICATION.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Uses a paginator to retrieve and show usage metrics and estimated monthly costs
4040

4141
## Scenario
4242

43-
This scenario demonstrates the basic usage of **Amazon Inspector** using a Java program. It focuses on checking account status, enabling Inspector, listing findings, reviewing coverage, and managing filters.
43+
This scenario demonstrates the basic usage of **Amazon Inspector** using an SDK. It focuses on checking account status, enabling Inspector, listing findings, reviewing coverage, and managing filters.
4444

4545
---
4646

@@ -95,16 +95,15 @@ The table below describes the exceptions handled in the program for each action.
9595
| Action | Exception | Handling |
9696
|-------------------------------|---------------------------|--------------------------------------------------------------------------|
9797
| `Enable` | `ValidationException` | Prints a message indicating Inspector may already be enabled. |
98-
| `BatchGetAccountStatus` | `Inspector2Exception` | Prints AWS service error details and rethrows the exception. |
98+
| `BatchGetAccountStatus` | `ValidationException` | Prints AWS service error details and rethrows the exception. |
9999
| `ListFindings` | `ValidationException` | Prints validation error details. |
100100
| `ListCoverage` | `ValidationException` | Prints validation error details. |
101101
| `ListCoverageStatistics` | `ValidationException` | Prints validation error details. |
102-
| `ListCoverageStatistics` | `Inspector2Exception` | Prints AWS service error details and rethrows the exception. |
103102
| `ListUsageTotals` | `ValidationException` | Prints validation error details. |
104-
| `CreateFilter` | `Inspector2Exception` | Prints AWS service error details and rethrows the exception. |
105-
| `ListFilters` | `Inspector2Exception` | Prints AWS service error details and rethrows the exception. |
106-
| `getAccountStatus` | `Inspector2Exception` | Prints AWS service error details and rethrows the exception.
107-
| `getAccountStatus` | `ResourceNotFoundException` | Prints AWS service error details and rethrows the exception. |
103+
| `ListFilters` | `ValidationException` | Prints AWS service error details and rethrows the exception. |
104+
| `getAccountStatus` | `ValidationException` | Prints AWS service error details and rethrows the exception.
105+
| `deleteFilter` | `ResourceNotFoundException` | Prints AWS service error details and rethrows the exception. |
106+
| `getAccountStatus` | `ValidationException` | Prints AWS service error details and rethrows the exception. |
108107

109108
## Metadata
110109

@@ -118,4 +117,5 @@ The table below describes the exceptions handled in the program for each action.
118117
| `ListUsageTotals` | inspector_metadata.yaml | inspector_ListUsageTotals |
119118
| `CreateFilter` | inspector_metadata.yaml | inspector_CreateFilter |
120119
| `ListFilters` | inspector_metadata.yaml | inspector_ListFilters |
120+
| `DeleteFilter` | inspector_metadata.yaml | inspector_Scenario |
121121
| `Amazon Inspector Basics Scenario` | inspector_metadata.yaml | inspector_Scenario |

0 commit comments

Comments
 (0)