Skip to content

Commit 67b8e9e

Browse files
committed
added Hello Neptune
1 parent cfffdd3 commit 67b8e9e

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# snippet-start:[neptune.python.hello.main]
5+
import boto3
6+
7+
def describe_db_clusters(neptune_client):
8+
"""
9+
Describes the Amazon Neptune DB clusters synchronously using a single call.
10+
11+
:param neptune_client: Boto3 Neptune client
12+
"""
13+
response = neptune_client.describe_db_clusters()
14+
for cluster in response.get("DBClusters", []):
15+
print(f"Cluster Identifier: {cluster['DBClusterIdentifier']}")
16+
print(f"Status: {cluster['Status']}")
17+
18+
19+
def main():
20+
"""
21+
Main entry point: creates the Neptune client and calls the describe operation.
22+
"""
23+
neptune_client = boto3.client("neptune")
24+
try:
25+
describe_db_clusters(neptune_client)
26+
except Exception as e:
27+
print(f"Error describing DB clusters: {str(e)}")
28+
29+
if __name__ == "__main__":
30+
main()
31+
# snippet-end:[neptune.python.hello.main]

python/example_code/ne[tune/NeptuneScenario.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44

5+
# snippet-start:[neptune.python.scenario.main]
56
import boto3
67
import time
7-
from datetime import timedelta
88
import botocore.exceptions
99

10-
# Constants
10+
# Constants used in this scenario
1111
POLL_INTERVAL_SECONDS = 10
1212
TIMEOUT_SECONDS = 1200 # 20 minutes
1313

@@ -301,7 +301,6 @@ def get_subnet_ids(vpc_id: str) -> list[str]:
301301
subnet_ids = [subnet['SubnetId'] for subnet in subnets if 'SubnetId' in subnet]
302302
return subnet_ids
303303

304-
305304
def get_default_vpc_id() -> str:
306305
ec2_client = boto3.client('ec2')
307306
describe_vpcs_request = {
@@ -419,6 +418,9 @@ def run_scenario(neptune_client, subnet_group_name: str, db_instance_id: str, cl
419418

420419
def main():
421420
neptune_client = boto3.client('neptune')
421+
422+
# Customize the following names to match your Neptune setup
423+
# (You must change these to unique values for your environment)
422424
subnet_group_name = "neptuneSubnetGroup75"
423425
cluster_name = "neptuneCluster75"
424426
db_instance_id = "neptuneDB75"
@@ -436,6 +438,6 @@ def main():
436438
https://docs.aws.amazon.com/code-library/latest/ug/what-is-code-library.html
437439
""")
438440

439-
440441
if __name__ == "__main__":
441442
main()
443+
# snippet-end:[neptune.python.scenario.main]

0 commit comments

Comments
 (0)