Skip to content

Commit

Permalink
add integration_name kwarg to the API constructors.
Browse files Browse the repository at this point in the history
You can use the integration_name argument to track API usage for a specific script or integration in the server access.log. For example:

```
In [2]: c=CbEnterpriseResponseAPI(integration_name="Splunk-App")
```

Will generate the following in the Cb server's access log:

```
`::ffff:1.2.3.4 - - [17/Oct/2016:19:47:10 -0400(0.004)] "GET /api/info HTTP/1.1" 200 297 "-" "cbapi/0.9.8 Python/2.7.10 Splunk-App" "-"
```
  • Loading branch information
jgarman committed Oct 17, 2016
1 parent 9ec4bb7 commit c7c9ee8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class BaseAPI(object):
def __init__(self, *args, **kwargs):
product_name = kwargs.pop("product_name", None)
credential_file = kwargs.pop("credential_file", None)
integration_name = kwargs.pop("integration_name", None)

self.credential_store = CredentialStore(product_name, credential_file=credential_file)

Expand All @@ -182,7 +183,7 @@ def __init__(self, *args, **kwargs):
self.credential_profile_name = kwargs.pop("profile", None)
self.credentials = self.credential_store.get_credentials(self.credential_profile_name)

self.session = Connection(self.credentials)
self.session = Connection(self.credentials, integration_name=integration_name)

def raise_unless_json(self, ret, expected):
if ret.status_code == 200:
Expand Down

0 comments on commit c7c9ee8

Please sign in to comment.