Skip to content

Commit 4af646c

Browse files
FEAT: Boto client custom app_id (#2)
### Summary 📝 To update the boto client configuration to make sure app_id being attached for resource monitor usage. ### Test plan: * Enable `botocore.endpoint` logger and run example script to make sure the newly added customer user_agent shows on the log. --------- Signed-off-by: Andy Kwok <andy.kwok@improving.com>
1 parent 8411bb0 commit 4af646c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

nx_neptune/clients/neptune_constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
SERVICE_IAM = "iam"
88
SERVICE_STS = "sts"
99

10+
# APP_ID
11+
APP_ID_NX = "nx-neptune"
12+
1013
# Internal constants for parameters
1114
PARAM_MAX_DEPTH = "maxDepth"
1215
PARAM_TRAVERSAL_DIRECTION = "traversalDirection"

nx_neptune/instance_management.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
import boto3
1010
import jmespath
11+
from botocore.config import Config
1112
from botocore.client import BaseClient
1213
from botocore.exceptions import ClientError
1314

1415
from .clients import SERVICE_IAM, SERVICE_NA, SERVICE_STS, IamClient
16+
from .clients.neptune_constants import APP_ID_NX
1517
from .na_graph import NeptuneGraph
1618

1719
__all__ = [
@@ -231,7 +233,8 @@ def create_na_instance(config: Optional[dict] = None):
231233
Raises:
232234
Exception: If the Neptune Analytics instance creation fails
233235
"""
234-
na_client = boto3.client(SERVICE_NA)
236+
na_client = boto3.client(service_name = SERVICE_NA,
237+
config = Config(user_agent_appid=APP_ID_NX))
235238

236239
# Permissions check
237240
user_arn = boto3.client(SERVICE_STS).get_caller_identity()["Arn"]

nx_neptune/na_graph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any, List, Optional
44

55
import boto3
6+
from botocore.config import Config
67
import networkx
78
from networkx import DiGraph, Graph
89

@@ -39,6 +40,8 @@
3940
"set_config_graph_id",
4041
]
4142

43+
from .clients.neptune_constants import APP_ID_NX
44+
4245
from .clients.opencypher_builder import insert_edges, insert_nodes
4346

4447

@@ -85,7 +88,8 @@ def from_config(cls, config: NeptuneConfig | None = None, graph=None, logger=Non
8588
s3_iam_role = boto3.client(SERVICE_STS).get_caller_identity()["Arn"]
8689

8790
na_client = NeptuneAnalyticsClient(
88-
config.graph_id, boto3.client(SERVICE_NA), logger
91+
config.graph_id, boto3.client(service_name = SERVICE_NA,
92+
config = Config(user_agent_appid=APP_ID_NX)), logger
8993
)
9094
iam_client = IamClient(s3_iam_role, boto3.client(SERVICE_IAM), logger)
9195
return cls(

0 commit comments

Comments
 (0)