Skip to content

Commit 913a75f

Browse files
authored
Merge pull request #145 from GetStream/chore/agent-header
[AI-148] Expose the user agent
2 parents 27be15e + c8b2e38 commit 913a75f

21 files changed

+308
-26
lines changed

getstream/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ def __init__(
118118
base_url=None,
119119
token=None,
120120
timeout=None,
121+
user_agent=None,
121122
):
122123
super().__init__(
123124
api_key=api_key,
124125
base_url=base_url,
125126
token=token,
126127
timeout=timeout,
128+
user_agent=user_agent,
127129
)
128130
self.client = httpx.Client(
129131
base_url=self.base_url,
@@ -280,12 +282,14 @@ def __init__(
280282
base_url=None,
281283
token=None,
282284
timeout=None,
285+
user_agent=None,
283286
):
284287
super().__init__(
285288
api_key=api_key,
286289
base_url=base_url,
287290
token=token,
288291
timeout=timeout,
292+
user_agent=user_agent,
289293
)
290294
self.client = httpx.AsyncClient(
291295
base_url=self.base_url,

getstream/chat/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44

55
class ChatClient(ChatRestClient):
6-
def __init__(self, api_key: str, base_url, token, timeout, stream):
6+
def __init__(self, api_key: str, base_url, token, timeout, stream, user_agent=None):
77
super().__init__(
8-
api_key=api_key, base_url=base_url, token=token, timeout=timeout
8+
api_key=api_key,
9+
base_url=base_url,
10+
token=token,
11+
timeout=timeout,
12+
user_agent=user_agent,
913
)
1014
self.stream = stream
1115

getstream/chat/async_rest_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,28 @@
77

88

99
class ChatRestClient(AsyncBaseClient):
10-
def __init__(self, api_key: str, base_url: str, timeout: float, token: str):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
base_url: str,
14+
timeout: float,
15+
token: str,
16+
user_agent: str = None,
17+
):
1118
"""
1219
Initializes ChatClient with BaseClient instance
1320
:param api_key: A string representing the client's API key
1421
:param base_url: A string representing the base uniform resource locator
1522
:param timeout: A number representing the time limit for a request
1623
:param token: A string instance representing the client's token
24+
:param user_agent: Optional custom user agent string
1725
"""
1826
super().__init__(
1927
api_key=api_key,
2028
base_url=base_url,
2129
timeout=timeout,
2230
token=token,
31+
user_agent=user_agent,
2332
)
2433

2534
@telemetry.operation_name("getstream.api.chat.query_campaigns")

getstream/chat/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44

55
class ChatClient(ChatRestClient):
6-
def __init__(self, api_key: str, base_url, token, timeout, stream):
6+
def __init__(self, api_key: str, base_url, token, timeout, stream, user_agent=None):
77
super().__init__(
8-
api_key=api_key, base_url=base_url, token=token, timeout=timeout
8+
api_key=api_key,
9+
base_url=base_url,
10+
token=token,
11+
timeout=timeout,
12+
user_agent=user_agent,
913
)
1014
self.stream = stream
1115

getstream/chat/rest_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,28 @@
77

88

99
class ChatRestClient(BaseClient):
10-
def __init__(self, api_key: str, base_url: str, timeout: float, token: str):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
base_url: str,
14+
timeout: float,
15+
token: str,
16+
user_agent: str = None,
17+
):
1118
"""
1219
Initializes ChatClient with BaseClient instance
1320
:param api_key: A string representing the client's API key
1421
:param base_url: A string representing the base uniform resource locator
1522
:param timeout: A number representing the time limit for a request
1623
:param token: A string instance representing the client's token
24+
:param user_agent: Optional custom user agent string
1725
"""
1826
super().__init__(
1927
api_key=api_key,
2028
base_url=base_url,
2129
timeout=timeout,
2230
token=token,
31+
user_agent=user_agent,
2332
)
2433

2534
@telemetry.operation_name("getstream.api.chat.query_campaigns")

getstream/common/async_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33

44
class CommonClient(CommonRestClient):
5-
def __init__(self, api_key: str, base_url, token, timeout):
5+
def __init__(self, api_key: str, base_url, token, timeout, user_agent=None):
66
super().__init__(
7-
api_key=api_key, base_url=base_url, token=token, timeout=timeout
7+
api_key=api_key,
8+
base_url=base_url,
9+
token=token,
10+
timeout=timeout,
11+
user_agent=user_agent,
812
)

getstream/common/async_rest_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,28 @@
77

88

99
class CommonRestClient(AsyncBaseClient):
10-
def __init__(self, api_key: str, base_url: str, timeout: float, token: str):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
base_url: str,
14+
timeout: float,
15+
token: str,
16+
user_agent: str = None,
17+
):
1118
"""
1219
Initializes CommonClient with BaseClient instance
1320
:param api_key: A string representing the client's API key
1421
:param base_url: A string representing the base uniform resource locator
1522
:param timeout: A number representing the time limit for a request
1623
:param token: A string instance representing the client's token
24+
:param user_agent: Optional custom user agent string
1725
"""
1826
super().__init__(
1927
api_key=api_key,
2028
base_url=base_url,
2129
timeout=timeout,
2230
token=token,
31+
user_agent=user_agent,
2332
)
2433

2534
@telemetry.operation_name("getstream.api.common.get_app")

getstream/common/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33

44
class CommonClient(CommonRestClient):
5-
def __init__(self, api_key: str, base_url, token, timeout):
5+
def __init__(self, api_key: str, base_url, token, timeout, user_agent=None):
66
super().__init__(
7-
api_key=api_key, base_url=base_url, token=token, timeout=timeout
7+
api_key=api_key,
8+
base_url=base_url,
9+
token=token,
10+
timeout=timeout,
11+
user_agent=user_agent,
812
)

getstream/common/rest_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,28 @@
77

88

99
class CommonRestClient(BaseClient):
10-
def __init__(self, api_key: str, base_url: str, timeout: float, token: str):
10+
def __init__(
11+
self,
12+
api_key: str,
13+
base_url: str,
14+
timeout: float,
15+
token: str,
16+
user_agent: str = None,
17+
):
1118
"""
1219
Initializes CommonClient with BaseClient instance
1320
:param api_key: A string representing the client's API key
1421
:param base_url: A string representing the base uniform resource locator
1522
:param timeout: A number representing the time limit for a request
1623
:param token: A string instance representing the client's token
24+
:param user_agent: Optional custom user agent string
1725
"""
1826
super().__init__(
1927
api_key=api_key,
2028
base_url=base_url,
2129
timeout=timeout,
2230
token=token,
31+
user_agent=user_agent,
2332
)
2433

2534
@telemetry.operation_name("getstream.api.common.get_app")

getstream/feeds/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55

66
class FeedsClient(FeedsRestClient):
7-
def __init__(self, api_key: str, base_url, token, timeout, stream):
7+
def __init__(self, api_key: str, base_url, token, timeout, stream, user_agent=None):
88
super().__init__(
9-
api_key=api_key, base_url=base_url, token=token, timeout=timeout
9+
api_key=api_key,
10+
base_url=base_url,
11+
token=token,
12+
timeout=timeout,
13+
user_agent=user_agent,
1014
)
1115
self.stream = stream
1216

0 commit comments

Comments
 (0)