Skip to content

Commit d77096c

Browse files
author
Tejas Ganesh Naik
committed
adding java and kotlin steering directories
1 parent a63ff3c commit d77096c

File tree

14 files changed

+4755
-0
lines changed

14 files changed

+4755
-0
lines changed

steering_docs/java-tech/actions.md

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

steering_docs/java-tech/basics.md

Lines changed: 429 additions & 0 deletions
Large diffs are not rendered by default.

steering_docs/java-tech/hello.md

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Java Hello Examples Generation
2+
3+
## MANDATORY: Knowledge Base Consultation (FIRST STEP)
4+
**🚨 CRITICAL - Must be completed BEFORE any code generation**
5+
6+
```bash
7+
# Step 1: List available knowledge bases
8+
ListKnowledgeBases()
9+
10+
# Step 2: Query coding standards (REQUIRED)
11+
QueryKnowledgeBases("coding-standards-KB", "Java-code-example-standards")
12+
13+
# Step 3: Query implementation patterns (REQUIRED)
14+
QueryKnowledgeBases("Java-premium-KB", "Java implementation patterns")
15+
16+
# Step 4: AWS service research (REQUIRED)
17+
search_documentation("What is [AWS Service] and what are its key API operations?")
18+
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
19+
```
20+
21+
**FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE**
22+
23+
## Purpose
24+
Generate simple "Hello" examples that demonstrate basic service connectivity and the most fundamental operation using direct AWS SDK for Java V2 client calls.
25+
26+
## Requirements
27+
- **MANDATORY**: Every AWS service MUST include a "Hello" scenario
28+
- **Simplicity**: Should be the most basic, minimal example possible
29+
- **Standalone**: Must work independently of other examples
30+
- **Direct Client**: Use AWS SDK client directly, no actions classes needed
31+
32+
## File Structure
33+
```
34+
javav2/example_code/{service}/
35+
├── src/main/java/com/example/{service}/
36+
│ └── Hello{Service}.java # Hello example file
37+
```
38+
39+
## Hello Example Pattern
40+
```java
41+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
42+
// SPDX-License-Identifier: Apache-2.0
43+
44+
package com.example.{service};
45+
46+
import software.amazon.awssdk.regions.Region;
47+
import software.amazon.awssdk.services.{service}.{Service}Client;
48+
import software.amazon.awssdk.services.{service}.model.*;
49+
import software.amazon.awssdk.core.exception.SdkException;
50+
51+
/**
52+
* Before running this Java V2 code example, set up your development
53+
* environment, including your credentials.
54+
*
55+
* For more information, see the following documentation topic:
56+
*
57+
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
58+
*
59+
* This example shows how to get started with {AWS Service} by {basic operation description}.
60+
*/
61+
62+
// snippet-start:[{service}.java2.hello.main]
63+
public class Hello{Service} {
64+
65+
public static void main(String[] args) {
66+
final String usage = """
67+
Usage:
68+
<region>
69+
70+
Where:
71+
region - The AWS region (for example, us-east-1).
72+
""";
73+
74+
if (args.length != 1) {
75+
System.out.println(usage);
76+
System.exit(1);
77+
}
78+
79+
String region = args[0];
80+
Region awsRegion = Region.of(region);
81+
{Service}Client {service}Client = {Service}Client.builder()
82+
.region(awsRegion)
83+
.build();
84+
85+
hello{Service}({service}Client);
86+
{service}Client.close();
87+
}
88+
89+
/**
90+
* Invokes a {AWS Service} operation to {basic operation description}.
91+
*
92+
* @param {service}Client the {AWS Service} client to use for the operation
93+
*/
94+
public static void hello{Service}({Service}Client {service}Client) {
95+
try {
96+
// Perform the most basic operation for this service
97+
{BasicOperation}Request request = {BasicOperation}Request.builder()
98+
.build();
99+
100+
{BasicOperation}Response response = {service}Client.{basicOperation}(request);
101+
102+
System.out.println("Hello, {AWS Service}!");
103+
104+
// Display appropriate result information
105+
if (response.has{ResultField}()) {
106+
System.out.println("Found " + response.{resultField}().size() + " {resources}.");
107+
response.{resultField}().forEach(resource ->
108+
System.out.println(" - " + resource.{resourceName}())
109+
);
110+
} else {
111+
System.out.println("{AWS Service} is available and ready to use.");
112+
}
113+
114+
} catch ({Service}Exception e) {
115+
System.err.println("{AWS Service} error occurred: " + e.awsErrorDetails().errorMessage());
116+
System.exit(1);
117+
} catch (SdkException e) {
118+
System.err.println("SDK error occurred: " + e.getMessage());
119+
System.exit(1);
120+
}
121+
}
122+
}
123+
// snippet-end:[{service}.java2.hello.main]
124+
```
125+
126+
## Hello Examples by Service Type
127+
128+
### List-Based Services (S3, DynamoDB, etc.)
129+
- **Operation**: List primary resources (buckets, tables, etc.)
130+
- **Message**: Show count and names of resources
131+
132+
### Status-Based Services (GuardDuty, Config, etc.)
133+
- **Operation**: Check service status or list detectors/configurations
134+
- **Message**: Show service availability and basic status
135+
136+
### Compute Services (EC2, Lambda, etc.)
137+
- **Operation**: List instances/functions or describe regions
138+
- **Message**: Show available resources or regions
139+
140+
## Service-Specific Hello Examples
141+
142+
### For Services with List Operations
143+
```java
144+
public static void hello{Service}({Service}Client {service}Client) {
145+
try {
146+
List{Resources}Request request = List{Resources}Request.builder().build();
147+
List{Resources}Response response = {service}Client.list{Resources}(request);
148+
149+
System.out.println("Hello, {AWS Service}!");
150+
System.out.println("Found " + response.{resources}().size() + " {resources}.");
151+
152+
response.{resources}().forEach(resource ->
153+
System.out.println(" - " + resource.{resourceName}())
154+
);
155+
156+
} catch ({Service}Exception e) {
157+
System.err.println("{AWS Service} error: " + e.awsErrorDetails().errorMessage());
158+
System.exit(1);
159+
}
160+
}
161+
```
162+
163+
### For Services with Status Operations
164+
```java
165+
public static void hello{Service}({Service}Client {service}Client) {
166+
try {
167+
Get{Service}StatusRequest request = Get{Service}StatusRequest.builder().build();
168+
Get{Service}StatusResponse response = {service}Client.get{Service}Status(request);
169+
170+
System.out.println("Hello, {AWS Service}!");
171+
System.out.println("Service status: " + response.status());
172+
System.out.println("{AWS Service} is ready to use.");
173+
174+
} catch ({Service}Exception e) {
175+
System.err.println("{AWS Service} error: " + e.awsErrorDetails().errorMessage());
176+
System.exit(1);
177+
}
178+
}
179+
```
180+
181+
### For Services with Describe Operations
182+
```java
183+
public static void hello{Service}({Service}Client {service}Client) {
184+
try {
185+
Describe{Resources}Request request = Describe{Resources}Request.builder()
186+
.maxResults(10)
187+
.build();
188+
Describe{Resources}Response response = {service}Client.describe{Resources}(request);
189+
190+
System.out.println("Hello, {AWS Service}!");
191+
System.out.println("Found " + response.{resources}().size() + " {resources}.");
192+
193+
response.{resources}().forEach(resource ->
194+
System.out.println(" - " + resource.{resourceId}() + " (" + resource.state() + ")")
195+
);
196+
197+
} catch ({Service}Exception e) {
198+
System.err.println("{AWS Service} error: " + e.awsErrorDetails().errorMessage());
199+
System.exit(1);
200+
}
201+
}
202+
```
203+
204+
## Error Handling Requirements
205+
206+
### Standard Error Handling Pattern
207+
```java
208+
try {
209+
// AWS operation
210+
response = {service}Client.operation(request);
211+
212+
} catch ({Service}Exception e) {
213+
// Service-specific errors
214+
String errorCode = e.awsErrorDetails().errorCode();
215+
switch (errorCode) {
216+
case "UnauthorizedOperation":
217+
System.err.println("You don't have permission to access {AWS Service}.");
218+
break;
219+
case "InvalidParameterValue":
220+
System.err.println("Invalid parameter provided to {AWS Service}.");
221+
break;
222+
default:
223+
System.err.println("{AWS Service} error: " + e.awsErrorDetails().errorMessage());
224+
}
225+
System.exit(1);
226+
227+
} catch (SdkException e) {
228+
// General SDK errors (network, credentials, etc.)
229+
System.err.println("SDK error: " + e.getMessage());
230+
System.exit(1);
231+
}
232+
```
233+
234+
## Validation Requirements
235+
-**Must run without errors** (with proper credentials)
236+
-**Must handle credential issues gracefully**
237+
-**Must display meaningful output**
238+
-**Must use direct AWS SDK client calls**
239+
-**Must include proper snippet tags**
240+
-**Must accept region as command line argument**
241+
-**Must close client resources properly**
242+
243+
## Common Patterns
244+
- Always use `{Service}Client.builder().region(awsRegion).build()` for client creation
245+
- Include comprehensive error handling for both service and SDK exceptions
246+
- Provide user-friendly output messages
247+
- Handle command line arguments properly
248+
- Close client resources in main method
249+
- Keep it as simple as possible - no additional classes or complexity
250+
- Use proper Java naming conventions (PascalCase for classes, camelCase for methods)
251+
252+
## Build Configuration
253+
Ensure the service dependency is included in `pom.xml`:
254+
255+
```xml
256+
<dependency>
257+
<groupId>software.amazon.awssdk</groupId>
258+
<artifactId>{service}</artifactId>
259+
<version>${aws.java.sdk.version}</version>
260+
</dependency>
261+
```
262+
263+
## Testing Requirements
264+
-**Must compile without errors**
265+
-**Must run with valid AWS credentials**
266+
-**Must handle invalid regions gracefully**
267+
-**Must display appropriate output for empty results**
268+
-**Must exit cleanly on errors**

0 commit comments

Comments
 (0)