Skip to content

Python Add the Amazon Neptune Python follow #7473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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
136 changes: 136 additions & 0 deletions .doc_gen/metadata/neptune_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ neptune_Hello:
synopsis: get started using &neptune;.
category: Hello
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.hello.main
Java:
versions:
- sdk_version: 2
Expand All @@ -18,6 +26,14 @@ neptune_Hello:
neptune: {DescribeDBClustersPaginator}
neptune_ExecuteQuery:
languages:
Python:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This metadata tag is not listed in the specification.

versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.graph.execute.main
Java:
versions:
- sdk_version: 2
Expand All @@ -31,6 +47,14 @@ neptune_ExecuteQuery:
neptune: {ExecuteQuery}
neptune_CreateGraph:
languages:
Python:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata key not listed in specification.

versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.graph.create.main
Java:
versions:
- sdk_version: 2
Expand All @@ -44,6 +68,14 @@ neptune_CreateGraph:
neptune: {CreateGraph}
neptune_ExecuteOpenCypherExplainQuery:
languages:
Python:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key not listed in specification. Same for many of these in this file.

versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.data.query.opencypher.main
Java:
versions:
- sdk_version: 2
Expand All @@ -57,6 +89,14 @@ neptune_ExecuteOpenCypherExplainQuery:
neptune: {ExecuteOpenCypherExplainQuery}
neptune_ExecuteGremlinProfileQuery:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.data.query.gremlin.main
Java:
versions:
- sdk_version: 2
Expand All @@ -70,6 +110,14 @@ neptune_ExecuteGremlinProfileQuery:
neptune: {ExecuteGremlinProfileQuery}
neptune_ExecuteGremlinQuery:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.data.query.gremlin.profile.main
Java:
versions:
- sdk_version: 2
Expand All @@ -83,6 +131,14 @@ neptune_ExecuteGremlinQuery:
neptune: {ExecuteGremlinQuery}
neptune_DeleteDBSubnetGroup:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.delete.subnet.group.main
Java:
versions:
- sdk_version: 2
Expand All @@ -96,6 +152,14 @@ neptune_DeleteDBSubnetGroup:
neptune: {DeleteDBSubnetGroup}
neptune_DeleteDBCluster:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.delete.cluster.main
Java:
versions:
- sdk_version: 2
Expand All @@ -109,6 +173,14 @@ neptune_DeleteDBCluster:
neptune: {DeleteDBCluster}
neptune_DeleteDBInstance:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.delete.instance.main
Java:
versions:
- sdk_version: 2
Expand All @@ -122,6 +194,14 @@ neptune_DeleteDBInstance:
neptune: {DeleteDBInstance}
neptune_StartDBCluster:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.start.cluster.main
Java:
versions:
- sdk_version: 2
Expand All @@ -135,6 +215,14 @@ neptune_StartDBCluster:
neptune: {StartDBCluster}
neptune_StopDBCluster:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.stop.cluster.main
Java:
versions:
- sdk_version: 2
Expand All @@ -148,6 +236,14 @@ neptune_StopDBCluster:
neptune: {StopDBCluster}
neptune_DescribeDBClusters:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.describe.cluster.main
Java:
versions:
- sdk_version: 2
Expand All @@ -161,6 +257,14 @@ neptune_DescribeDBClusters:
neptune: {DescribeDBClusters}
neptune_DescribeDBInstances:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.describe.dbinstance.main
Java:
versions:
- sdk_version: 2
Expand All @@ -174,6 +278,14 @@ neptune_DescribeDBInstances:
neptune: {DescribeDBInstances}
neptune_CreateDBInstance:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.create.dbinstance.main
Java:
versions:
- sdk_version: 2
Expand All @@ -187,6 +299,14 @@ neptune_CreateDBInstance:
neptune: {CreateDBInstance}
neptune_CreateDBCluster:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.create.cluster.main
Java:
versions:
- sdk_version: 2
Expand All @@ -200,6 +320,14 @@ neptune_CreateDBCluster:
neptune: {CreateDBCluster}
neptune_CreateDBSubnetGroup:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.create.subnet.main
Java:
versions:
- sdk_version: 2
Expand All @@ -223,6 +351,14 @@ neptune_Scenario:
- Delete the &neptune; Assets.
category: Basics
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/neptune
excerpts:
- description:
snippet_tags:
- neptune.python.scenario.main
Java:
versions:
- sdk_version: 2
Expand Down
31 changes: 31 additions & 0 deletions python/example_code/neptune/HelloNeptune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python files should not be named with uppercase names. They should match the patterns in the rest of the library. Same for all files in this PR.

# SPDX-License-Identifier: Apache-2.0

# snippet-start:[neptune.python.hello.main]
import boto3

def describe_db_clusters(neptune_client):
"""
Describes the Amazon Neptune DB clusters synchronously using a single call.

:param neptune_client: Boto3 Neptune client
"""
response = neptune_client.describe_db_clusters()
for cluster in response.get("DBClusters", []):
print(f"Cluster Identifier: {cluster['DBClusterIdentifier']}")
print(f"Status: {cluster['Status']}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specification requires handling a ResourceNotFoundException.



def main():
"""
Main entry point: creates the Neptune client and calls the describe operation.
"""
neptune_client = boto3.client("neptune", region_name="us-east-1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hard-code regions.

try:
describe_db_clusters(neptune_client)
except Exception as e:
print(f"Error describing DB clusters: {str(e)}")

if __name__ == "__main__":
main()
# snippet-end:[neptune.python.hello.main]
Loading
Loading