Skip to content

Commit cf72e6f

Browse files
committed
feat: remove security scheme from ACP spec and move to ACP SDK objects to support workflow server API key.
1 parent 90bb51d commit cf72e6f

22 files changed

+35
-173
lines changed

acp-spec

agntcy_acp/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,30 @@ class ACPClient(AgentsApi, StatelessRunsApi, ThreadsApi, ThreadRunsApi):
3535
"""
3636
def __init__(self, api_client: Optional[ApiClient] = None):
3737
super().__init__(api_client)
38+
self.__workflow_server_update_api_client()
39+
40+
def __workflow_server_update_api_client(self):
41+
if self.api_client.configuration.api_key is not None:
42+
# Check for 'x-api-key' config and move to header.
43+
try:
44+
self.api_client.default_headers['x-api-key'] = self.api_client.configuration.api_key['x-api-key']
45+
except KeyError:
46+
pass # ignore
3847

3948
class AsyncACPClient(AsyncAgentsApi, AsyncStatelessRunsApi, AsyncThreadsApi, AsyncThreadRunsApi):
4049
"""Async client for ACP API.
4150
"""
4251
def __init__(self, api_client: Optional[AsyncApiClient] = None):
4352
super().__init__(api_client)
53+
self.__workflow_server_update_api_client()
54+
55+
def __workflow_server_update_api_client(self):
56+
if self.api_client.configuration.api_key is not None:
57+
# Check for 'x-api-key' config and move to header.
58+
try:
59+
self.api_client.default_headers['x-api-key'] = self.api_client.configuration.api_key['x-api-key']
60+
except KeyError:
61+
pass # ignore
4462

4563
__ENV_VAR_SPECIAL_CHAR_TABLE = str.maketrans("-.", "__")
4664

agntcy_acp/acp_v0/async_client/api/agents_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ def _get_acp_descriptor_by_id_serialize(
289289

290290
# authentication setting
291291
_auth_settings: List[str] = [
292-
'x-api-key'
293292
]
294293

295294
return self.api_client.param_serialize(
@@ -553,7 +552,6 @@ def _get_agent_by_id_serialize(
553552

554553
# authentication setting
555554
_auth_settings: List[str] = [
556-
'x-api-key'
557555
]
558556

559557
return self.api_client.param_serialize(
@@ -830,7 +828,6 @@ def _search_agents_serialize(
830828

831829
# authentication setting
832830
_auth_settings: List[str] = [
833-
'x-api-key'
834831
]
835832

836833
return self.api_client.param_serialize(

agntcy_acp/acp_v0/async_client/api/stateless_runs_api.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ def _cancel_stateless_run_serialize(
322322

323323
# authentication setting
324324
_auth_settings: List[str] = [
325-
'x-api-key'
326325
]
327326

328327
return self.api_client.param_serialize(
@@ -606,7 +605,6 @@ def _create_and_stream_stateless_run_output_serialize(
606605

607606
# authentication setting
608607
_auth_settings: List[str] = [
609-
'x-api-key'
610608
]
611609

612610
return self.api_client.param_serialize(
@@ -889,7 +887,6 @@ def _create_and_wait_for_stateless_run_output_serialize(
889887

890888
# authentication setting
891889
_auth_settings: List[str] = [
892-
'x-api-key'
893890
]
894891

895892
return self.api_client.param_serialize(
@@ -1172,7 +1169,6 @@ def _create_stateless_run_serialize(
11721169

11731170
# authentication setting
11741171
_auth_settings: List[str] = [
1175-
'x-api-key'
11761172
]
11771173

11781174
return self.api_client.param_serialize(
@@ -1439,7 +1435,6 @@ def _delete_stateless_run_serialize(
14391435

14401436
# authentication setting
14411437
_auth_settings: List[str] = [
1442-
'x-api-key'
14431438
]
14441439

14451440
return self.api_client.param_serialize(
@@ -1706,7 +1701,6 @@ def _get_stateless_run_serialize(
17061701

17071702
# authentication setting
17081703
_auth_settings: List[str] = [
1709-
'x-api-key'
17101704
]
17111705

17121706
return self.api_client.param_serialize(
@@ -2004,7 +1998,6 @@ def _resume_stateless_run_serialize(
20041998

20051999
# authentication setting
20062000
_auth_settings: List[str] = [
2007-
'x-api-key'
20082001
]
20092002

20102003
return self.api_client.param_serialize(
@@ -2281,7 +2274,6 @@ def _search_stateless_runs_serialize(
22812274

22822275
# authentication setting
22832276
_auth_settings: List[str] = [
2284-
'x-api-key'
22852277
]
22862278

22872279
return self.api_client.param_serialize(
@@ -2549,7 +2541,6 @@ def _stream_stateless_run_output_serialize(
25492541

25502542
# authentication setting
25512543
_auth_settings: List[str] = [
2552-
'x-api-key'
25532544
]
25542545

25552546
return self.api_client.param_serialize(
@@ -2816,7 +2807,6 @@ def _wait_for_stateless_run_output_serialize(
28162807

28172808
# authentication setting
28182809
_auth_settings: List[str] = [
2819-
'x-api-key'
28202810
]
28212811

28222812
return self.api_client.param_serialize(

agntcy_acp/acp_v0/async_client/api/thread_runs_api.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ def _cancel_thread_run_serialize(
336336

337337
# authentication setting
338338
_auth_settings: List[str] = [
339-
'x-api-key'
340339
]
341340

342341
return self.api_client.param_serialize(
@@ -635,7 +634,6 @@ def _create_and_stream_thread_run_output_serialize(
635634

636635
# authentication setting
637636
_auth_settings: List[str] = [
638-
'x-api-key'
639637
]
640638

641639
return self.api_client.param_serialize(
@@ -933,7 +931,6 @@ def _create_and_wait_for_thread_run_output_serialize(
933931

934932
# authentication setting
935933
_auth_settings: List[str] = [
936-
'x-api-key'
937934
]
938935

939936
return self.api_client.param_serialize(
@@ -1231,7 +1228,6 @@ def _create_thread_run_serialize(
12311228

12321229
# authentication setting
12331230
_auth_settings: List[str] = [
1234-
'x-api-key'
12351231
]
12361232

12371233
return self.api_client.param_serialize(
@@ -1513,7 +1509,6 @@ def _delete_thread_run_serialize(
15131509

15141510
# authentication setting
15151511
_auth_settings: List[str] = [
1516-
'x-api-key'
15171512
]
15181513

15191514
return self.api_client.param_serialize(
@@ -1795,7 +1790,6 @@ def _get_thread_run_serialize(
17951790

17961791
# authentication setting
17971792
_auth_settings: List[str] = [
1798-
'x-api-key'
17991793
]
18001794

18011795
return self.api_client.param_serialize(
@@ -2096,7 +2090,6 @@ def _list_thread_runs_serialize(
20962090

20972091
# authentication setting
20982092
_auth_settings: List[str] = [
2099-
'x-api-key'
21002093
]
21012094

21022095
return self.api_client.param_serialize(
@@ -2409,7 +2402,6 @@ def _resume_thread_run_serialize(
24092402

24102403
# authentication setting
24112404
_auth_settings: List[str] = [
2412-
'x-api-key'
24132405
]
24142406

24152407
return self.api_client.param_serialize(
@@ -2692,7 +2684,6 @@ def _stream_thread_run_output_serialize(
26922684

26932685
# authentication setting
26942686
_auth_settings: List[str] = [
2695-
'x-api-key'
26962687
]
26972688

26982689
return self.api_client.param_serialize(
@@ -2974,7 +2965,6 @@ def _wait_for_thread_run_output_serialize(
29742965

29752966
# authentication setting
29762967
_auth_settings: List[str] = [
2977-
'x-api-key'
29782968
]
29792969

29802970
return self.api_client.param_serialize(

agntcy_acp/acp_v0/async_client/api/threads_api.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ def _copy_thread_serialize(
291291

292292
# authentication setting
293293
_auth_settings: List[str] = [
294-
'x-api-key'
295294
]
296295

297296
return self.api_client.param_serialize(
@@ -571,7 +570,6 @@ def _create_thread_serialize(
571570

572571
# authentication setting
573572
_auth_settings: List[str] = [
574-
'x-api-key'
575573
]
576574

577575
return self.api_client.param_serialize(
@@ -838,7 +836,6 @@ def _delete_thread_serialize(
838836

839837
# authentication setting
840838
_auth_settings: List[str] = [
841-
'x-api-key'
842839
]
843840

844841
return self.api_client.param_serialize(
@@ -1105,7 +1102,6 @@ def _get_thread_serialize(
11051102

11061103
# authentication setting
11071104
_auth_settings: List[str] = [
1108-
'x-api-key'
11091105
]
11101106

11111107
return self.api_client.param_serialize(
@@ -1406,7 +1402,6 @@ def _get_thread_history_serialize(
14061402

14071403
# authentication setting
14081404
_auth_settings: List[str] = [
1409-
'x-api-key'
14101405
]
14111406

14121407
return self.api_client.param_serialize(
@@ -1701,7 +1696,6 @@ def _patch_thread_serialize(
17011696

17021697
# authentication setting
17031698
_auth_settings: List[str] = [
1704-
'x-api-key'
17051699
]
17061700

17071701
return self.api_client.param_serialize(
@@ -1978,7 +1972,6 @@ def _search_threads_serialize(
19781972

19791973
# authentication setting
19801974
_auth_settings: List[str] = [
1981-
'x-api-key'
19821975
]
19831976

19841977
return self.api_client.param_serialize(

agntcy_acp/acp_v0/configuration.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
AuthSettings = TypedDict(
116116
"AuthSettings",
117117
{
118-
"x-api-key": APIKeyAuthSetting,
119118
},
120119
total=False,
121120
)
@@ -166,26 +165,6 @@ class Configuration:
166165
:param ca_cert_data: verify the peer using concatenated CA certificate data
167166
in PEM (str) or DER (bytes) format.
168167
169-
:Example:
170-
171-
API Key Authentication Example.
172-
Given the following security scheme in the OpenAPI specification:
173-
components:
174-
securitySchemes:
175-
cookieAuth: # name for the security scheme
176-
type: apiKey
177-
in: cookie
178-
name: JSESSIONID # cookie name
179-
180-
You can programmatically set the cookie:
181-
182-
conf = agntcy_acp.acp_v0.Configuration(
183-
api_key={'cookieAuth': 'abc123'}
184-
api_key_prefix={'cookieAuth': 'JSESSIONID'}
185-
)
186-
187-
The following cookie will be added to the HTTP request:
188-
Cookie: JSESSIONID abc123
189168
"""
190169

191170
_default: ClassVar[Optional[Self]] = None
@@ -513,15 +492,6 @@ def auth_settings(self)-> AuthSettings:
513492
:return: The Auth Settings information dict.
514493
"""
515494
auth: AuthSettings = {}
516-
if 'x-api-key' in self.api_key:
517-
auth['x-api-key'] = {
518-
'type': 'api_key',
519-
'in': 'header',
520-
'key': 'x-api-key',
521-
'value': self.get_api_key_with_prefix(
522-
'x-api-key',
523-
),
524-
}
525495
return auth
526496

527497
def to_debug_report(self) -> str:

agntcy_acp/acp_v0/sync_client/api/agents_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ def _get_acp_descriptor_by_id_serialize(
289289

290290
# authentication setting
291291
_auth_settings: List[str] = [
292-
'x-api-key'
293292
]
294293

295294
return self.api_client.param_serialize(
@@ -553,7 +552,6 @@ def _get_agent_by_id_serialize(
553552

554553
# authentication setting
555554
_auth_settings: List[str] = [
556-
'x-api-key'
557555
]
558556

559557
return self.api_client.param_serialize(
@@ -830,7 +828,6 @@ def _search_agents_serialize(
830828

831829
# authentication setting
832830
_auth_settings: List[str] = [
833-
'x-api-key'
834831
]
835832

836833
return self.api_client.param_serialize(

0 commit comments

Comments
 (0)