Skip to content

Commit acc29ee

Browse files
Wrap up for beta release (#109)
1 parent 67749fe commit acc29ee

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

  • src/elimity_insights_client/agent

src/elimity_insights_client/agent/api.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""API endpoints for agent interactions with an Elimity Insights server."""
22

33
from dataclasses import dataclass
4-
from typing import List, TypeVar, cast, Type
4+
from typing import List, TypeVar, cast, Type, Optional
55

66
from requests import request
77

@@ -33,9 +33,9 @@ class Config:
3333
def query(config: Config, queries: List[Query]) -> List[QueryResultsPage]:
3434
"""Perform the given queries and return the result pages."""
3535
query_iter = map(encode_query, queries)
36-
queries = encoder.encode(query_iter)
36+
data = encoder.encode(query_iter)
3737
page_dicts = _request(
38-
config, queries, "POST", "/api/agent/query", List[QueryResultsPageDict]
38+
config, data, "POST", "/api/agent/query", List[QueryResultsPageDict]
3939
)
4040
return map_list(decode_query_results_page, page_dicts)
4141

@@ -47,10 +47,18 @@ def sources(config: Config) -> List[Source]:
4747

4848

4949
def _request(
50-
config: Config, json: object, method: str, path: str, _type: Type[_T]
50+
config: Config, data: Optional[str], method: str, path: str, _type: Type[_T]
5151
) -> _T:
5252
auth = config.token_id, config.token_secret
53-
response = request(method, config.url + path, auth=auth, json=json)
53+
headers = {"Content-Type": "application/json"}
54+
response = request(
55+
method,
56+
config.url + path,
57+
auth=auth,
58+
data=data,
59+
headers=headers,
60+
verify=config.verify_ssl,
61+
)
5462
response.raise_for_status()
5563
json = response.json()
5664
return cast(_T, json)

0 commit comments

Comments
 (0)