letta-client 0.1.37__py3-none-any.whl → 0.1.39__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of letta-client might be problematic. Click here for more details.

Files changed (28) hide show
  1. letta_client/__init__.py +20 -0
  2. letta_client/agents/__init__.py +8 -0
  3. letta_client/agents/client.py +10 -0
  4. letta_client/agents/types/__init__.py +16 -0
  5. letta_client/agents/types/agents_search_response_agents_item_tool_rules_item_item.py +4 -0
  6. letta_client/agents/types/agents_search_response_agents_item_tool_rules_item_item_tool_name.py +23 -0
  7. letta_client/agents/types/agents_search_response_agents_item_tool_rules_item_item_tool_name_type.py +7 -0
  8. letta_client/agents/types/agents_search_response_agents_item_tool_rules_item_tool_name.py +23 -0
  9. letta_client/agents/types/agents_search_response_agents_item_tool_rules_item_tool_name_type.py +7 -0
  10. letta_client/agents/types/create_agent_request_tool_rules_item.py +4 -1
  11. letta_client/agents/types/update_agent_tool_rules_item.py +4 -1
  12. letta_client/core/client_wrapper.py +1 -1
  13. letta_client/identities/client.py +836 -36
  14. letta_client/templates/__init__.py +8 -0
  15. letta_client/templates/types/__init__.py +16 -0
  16. letta_client/templates/types/templates_create_agents_from_template_response_agents_item_tool_rules_item_item.py +4 -0
  17. letta_client/templates/types/templates_create_agents_from_template_response_agents_item_tool_rules_item_item_tool_name.py +23 -0
  18. letta_client/templates/types/templates_create_agents_from_template_response_agents_item_tool_rules_item_item_tool_name_type.py +7 -0
  19. letta_client/templates/types/templates_create_agents_from_template_response_agents_item_tool_rules_item_tool_name.py +23 -0
  20. letta_client/templates/types/templates_create_agents_from_template_response_agents_item_tool_rules_item_tool_name_type.py +7 -0
  21. letta_client/types/__init__.py +4 -0
  22. letta_client/types/agent_state_tool_rules_item.py +4 -1
  23. letta_client/types/continue_tool_rule.py +28 -0
  24. letta_client/types/identity.py +1 -1
  25. letta_client/types/identity_create.py +43 -0
  26. {letta_client-0.1.37.dist-info → letta_client-0.1.39.dist-info}/METADATA +1 -1
  27. {letta_client-0.1.37.dist-info → letta_client-0.1.39.dist-info}/RECORD +28 -18
  28. {letta_client-0.1.37.dist-info → letta_client-0.1.39.dist-info}/WHEEL +0 -0
@@ -1,7 +1,7 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from ..core.client_wrapper import SyncClientWrapper
4
3
  import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
5
  from ..types.identity_type import IdentityType
6
6
  from ..core.request_options import RequestOptions
7
7
  from ..types.identity import Identity
@@ -10,8 +10,12 @@ from ..errors.unprocessable_entity_error import UnprocessableEntityError
10
10
  from ..types.http_validation_error import HttpValidationError
11
11
  from json.decoder import JSONDecodeError
12
12
  from ..core.api_error import ApiError
13
+ from ..core.jsonable_encoder import jsonable_encoder
13
14
  from ..core.client_wrapper import AsyncClientWrapper
14
15
 
16
+ # this is used as the default value for optional parameters
17
+ OMIT = typing.cast(typing.Any, ...)
18
+
15
19
 
16
20
  class IdentitiesClient:
17
21
  def __init__(self, *, client_wrapper: SyncClientWrapper):
@@ -99,83 +103,879 @@ class IdentitiesClient:
99
103
  raise ApiError(status_code=_response.status_code, body=_response.text)
100
104
  raise ApiError(status_code=_response.status_code, body=_response_json)
101
105
 
106
+ def create_identity(
107
+ self,
108
+ *,
109
+ identifier_key: str,
110
+ name: str,
111
+ identity_type: IdentityType,
112
+ project_slug: typing.Optional[str] = None,
113
+ project_id: typing.Optional[str] = OMIT,
114
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
115
+ request_options: typing.Optional[RequestOptions] = None,
116
+ ) -> Identity:
117
+ """
118
+ Parameters
119
+ ----------
120
+ identifier_key : str
121
+ External, user-generated identifier key of the identity.
122
+
123
+ name : str
124
+ The name of the identity.
102
125
 
103
- class AsyncIdentitiesClient:
104
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
105
- self._client_wrapper = client_wrapper
126
+ identity_type : IdentityType
127
+ The type of the identity.
106
128
 
107
- async def list_identities(
129
+ project_slug : typing.Optional[str]
130
+
131
+ project_id : typing.Optional[str]
132
+ The project id of the identity, if applicable.
133
+
134
+ agent_ids : typing.Optional[typing.Sequence[str]]
135
+ The agent ids that are associated with the identity.
136
+
137
+ request_options : typing.Optional[RequestOptions]
138
+ Request-specific configuration.
139
+
140
+ Returns
141
+ -------
142
+ Identity
143
+ Successful Response
144
+
145
+ Examples
146
+ --------
147
+ from letta_client import Letta
148
+
149
+ client = Letta(
150
+ token="YOUR_TOKEN",
151
+ )
152
+ client.identities.create_identity(
153
+ identifier_key="identifier_key",
154
+ name="name",
155
+ identity_type="org",
156
+ )
157
+ """
158
+ _response = self._client_wrapper.httpx_client.request(
159
+ "v1/identities/",
160
+ method="POST",
161
+ json={
162
+ "identifier_key": identifier_key,
163
+ "name": name,
164
+ "identity_type": identity_type,
165
+ "project_id": project_id,
166
+ "agent_ids": agent_ids,
167
+ },
168
+ headers={
169
+ "project-slug": str(project_slug) if project_slug is not None else None,
170
+ },
171
+ request_options=request_options,
172
+ omit=OMIT,
173
+ )
174
+ try:
175
+ if 200 <= _response.status_code < 300:
176
+ return typing.cast(
177
+ Identity,
178
+ construct_type(
179
+ type_=Identity, # type: ignore
180
+ object_=_response.json(),
181
+ ),
182
+ )
183
+ if _response.status_code == 422:
184
+ raise UnprocessableEntityError(
185
+ typing.cast(
186
+ HttpValidationError,
187
+ construct_type(
188
+ type_=HttpValidationError, # type: ignore
189
+ object_=_response.json(),
190
+ ),
191
+ )
192
+ )
193
+ _response_json = _response.json()
194
+ except JSONDecodeError:
195
+ raise ApiError(status_code=_response.status_code, body=_response.text)
196
+ raise ApiError(status_code=_response.status_code, body=_response_json)
197
+
198
+ def upsert_identity(
108
199
  self,
109
200
  *,
110
- name: typing.Optional[str] = None,
111
- project_id: typing.Optional[str] = None,
112
- identity_type: typing.Optional[IdentityType] = None,
113
- before: typing.Optional[str] = None,
114
- after: typing.Optional[str] = None,
115
- limit: typing.Optional[int] = None,
201
+ identifier_key: str,
202
+ name: str,
203
+ identity_type: IdentityType,
204
+ project_slug: typing.Optional[str] = None,
205
+ project_id: typing.Optional[str] = OMIT,
206
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
116
207
  request_options: typing.Optional[RequestOptions] = None,
117
- ) -> typing.List[Identity]:
208
+ ) -> Identity:
118
209
  """
119
- Get a list of all identities in the database
120
-
121
210
  Parameters
122
211
  ----------
123
- name : typing.Optional[str]
212
+ identifier_key : str
213
+ External, user-generated identifier key of the identity.
214
+
215
+ name : str
216
+ The name of the identity.
217
+
218
+ identity_type : IdentityType
219
+ The type of the identity.
220
+
221
+ project_slug : typing.Optional[str]
124
222
 
125
223
  project_id : typing.Optional[str]
224
+ The project id of the identity, if applicable.
126
225
 
127
- identity_type : typing.Optional[IdentityType]
226
+ agent_ids : typing.Optional[typing.Sequence[str]]
227
+ The agent ids that are associated with the identity.
128
228
 
129
- before : typing.Optional[str]
229
+ request_options : typing.Optional[RequestOptions]
230
+ Request-specific configuration.
130
231
 
131
- after : typing.Optional[str]
232
+ Returns
233
+ -------
234
+ Identity
235
+ Successful Response
132
236
 
133
- limit : typing.Optional[int]
237
+ Examples
238
+ --------
239
+ from letta_client import Letta
240
+
241
+ client = Letta(
242
+ token="YOUR_TOKEN",
243
+ )
244
+ client.identities.upsert_identity(
245
+ identifier_key="identifier_key",
246
+ name="name",
247
+ identity_type="org",
248
+ )
249
+ """
250
+ _response = self._client_wrapper.httpx_client.request(
251
+ "v1/identities/",
252
+ method="PUT",
253
+ json={
254
+ "identifier_key": identifier_key,
255
+ "name": name,
256
+ "identity_type": identity_type,
257
+ "project_id": project_id,
258
+ "agent_ids": agent_ids,
259
+ },
260
+ headers={
261
+ "project-slug": str(project_slug) if project_slug is not None else None,
262
+ },
263
+ request_options=request_options,
264
+ omit=OMIT,
265
+ )
266
+ try:
267
+ if 200 <= _response.status_code < 300:
268
+ return typing.cast(
269
+ Identity,
270
+ construct_type(
271
+ type_=Identity, # type: ignore
272
+ object_=_response.json(),
273
+ ),
274
+ )
275
+ if _response.status_code == 422:
276
+ raise UnprocessableEntityError(
277
+ typing.cast(
278
+ HttpValidationError,
279
+ construct_type(
280
+ type_=HttpValidationError, # type: ignore
281
+ object_=_response.json(),
282
+ ),
283
+ )
284
+ )
285
+ _response_json = _response.json()
286
+ except JSONDecodeError:
287
+ raise ApiError(status_code=_response.status_code, body=_response.text)
288
+ raise ApiError(status_code=_response.status_code, body=_response_json)
289
+
290
+ def get_identity_from_identifier_key(
291
+ self, identifier_key: str, *, request_options: typing.Optional[RequestOptions] = None
292
+ ) -> Identity:
293
+ """
294
+ Parameters
295
+ ----------
296
+ identifier_key : str
134
297
 
135
298
  request_options : typing.Optional[RequestOptions]
136
299
  Request-specific configuration.
137
300
 
138
301
  Returns
139
302
  -------
140
- typing.List[Identity]
303
+ Identity
141
304
  Successful Response
142
305
 
143
306
  Examples
144
307
  --------
145
- import asyncio
308
+ from letta_client import Letta
146
309
 
147
- from letta_client import AsyncLetta
310
+ client = Letta(
311
+ token="YOUR_TOKEN",
312
+ )
313
+ client.identities.get_identity_from_identifier_key(
314
+ identifier_key="identifier_key",
315
+ )
316
+ """
317
+ _response = self._client_wrapper.httpx_client.request(
318
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
319
+ method="GET",
320
+ request_options=request_options,
321
+ )
322
+ try:
323
+ if 200 <= _response.status_code < 300:
324
+ return typing.cast(
325
+ Identity,
326
+ construct_type(
327
+ type_=Identity, # type: ignore
328
+ object_=_response.json(),
329
+ ),
330
+ )
331
+ if _response.status_code == 422:
332
+ raise UnprocessableEntityError(
333
+ typing.cast(
334
+ HttpValidationError,
335
+ construct_type(
336
+ type_=HttpValidationError, # type: ignore
337
+ object_=_response.json(),
338
+ ),
339
+ )
340
+ )
341
+ _response_json = _response.json()
342
+ except JSONDecodeError:
343
+ raise ApiError(status_code=_response.status_code, body=_response.text)
344
+ raise ApiError(status_code=_response.status_code, body=_response_json)
148
345
 
149
- client = AsyncLetta(
346
+ def delete_identity(
347
+ self, identifier_key: str, *, request_options: typing.Optional[RequestOptions] = None
348
+ ) -> typing.Optional[typing.Any]:
349
+ """
350
+ Delete an identity by its identifier key
351
+
352
+ Parameters
353
+ ----------
354
+ identifier_key : str
355
+
356
+ request_options : typing.Optional[RequestOptions]
357
+ Request-specific configuration.
358
+
359
+ Returns
360
+ -------
361
+ typing.Optional[typing.Any]
362
+ Successful Response
363
+
364
+ Examples
365
+ --------
366
+ from letta_client import Letta
367
+
368
+ client = Letta(
150
369
  token="YOUR_TOKEN",
151
370
  )
371
+ client.identities.delete_identity(
372
+ identifier_key="identifier_key",
373
+ )
374
+ """
375
+ _response = self._client_wrapper.httpx_client.request(
376
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
377
+ method="DELETE",
378
+ request_options=request_options,
379
+ )
380
+ try:
381
+ if 200 <= _response.status_code < 300:
382
+ return typing.cast(
383
+ typing.Optional[typing.Any],
384
+ construct_type(
385
+ type_=typing.Optional[typing.Any], # type: ignore
386
+ object_=_response.json(),
387
+ ),
388
+ )
389
+ if _response.status_code == 422:
390
+ raise UnprocessableEntityError(
391
+ typing.cast(
392
+ HttpValidationError,
393
+ construct_type(
394
+ type_=HttpValidationError, # type: ignore
395
+ object_=_response.json(),
396
+ ),
397
+ )
398
+ )
399
+ _response_json = _response.json()
400
+ except JSONDecodeError:
401
+ raise ApiError(status_code=_response.status_code, body=_response.text)
402
+ raise ApiError(status_code=_response.status_code, body=_response_json)
152
403
 
404
+ def update_identity(
405
+ self,
406
+ identifier_key: str,
407
+ *,
408
+ name: typing.Optional[str] = OMIT,
409
+ identity_type: typing.Optional[IdentityType] = OMIT,
410
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
411
+ request_options: typing.Optional[RequestOptions] = None,
412
+ ) -> Identity:
413
+ """
414
+ Parameters
415
+ ----------
416
+ identifier_key : str
153
417
 
154
- async def main() -> None:
155
- await client.identities.list_identities()
418
+ name : typing.Optional[str]
419
+ The name of the identity.
420
+
421
+ identity_type : typing.Optional[IdentityType]
422
+ The type of the identity.
156
423
 
424
+ agent_ids : typing.Optional[typing.Sequence[str]]
425
+ The agent ids that are associated with the identity.
157
426
 
158
- asyncio.run(main())
427
+ request_options : typing.Optional[RequestOptions]
428
+ Request-specific configuration.
429
+
430
+ Returns
431
+ -------
432
+ Identity
433
+ Successful Response
434
+
435
+ Examples
436
+ --------
437
+ from letta_client import Letta
438
+
439
+ client = Letta(
440
+ token="YOUR_TOKEN",
441
+ )
442
+ client.identities.update_identity(
443
+ identifier_key="identifier_key",
444
+ )
159
445
  """
160
- _response = await self._client_wrapper.httpx_client.request(
161
- "v1/identities/",
162
- method="GET",
163
- params={
446
+ _response = self._client_wrapper.httpx_client.request(
447
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
448
+ method="PATCH",
449
+ json={
164
450
  "name": name,
165
- "project_id": project_id,
166
451
  "identity_type": identity_type,
167
- "before": before,
168
- "after": after,
169
- "limit": limit,
452
+ "agent_ids": agent_ids,
453
+ },
454
+ headers={
455
+ "content-type": "application/json",
170
456
  },
171
457
  request_options=request_options,
458
+ omit=OMIT,
172
459
  )
173
460
  try:
174
461
  if 200 <= _response.status_code < 300:
175
462
  return typing.cast(
176
- typing.List[Identity],
463
+ Identity,
177
464
  construct_type(
178
- type_=typing.List[Identity], # type: ignore
465
+ type_=Identity, # type: ignore
466
+ object_=_response.json(),
467
+ ),
468
+ )
469
+ if _response.status_code == 422:
470
+ raise UnprocessableEntityError(
471
+ typing.cast(
472
+ HttpValidationError,
473
+ construct_type(
474
+ type_=HttpValidationError, # type: ignore
475
+ object_=_response.json(),
476
+ ),
477
+ )
478
+ )
479
+ _response_json = _response.json()
480
+ except JSONDecodeError:
481
+ raise ApiError(status_code=_response.status_code, body=_response.text)
482
+ raise ApiError(status_code=_response.status_code, body=_response_json)
483
+
484
+
485
+ class AsyncIdentitiesClient:
486
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
487
+ self._client_wrapper = client_wrapper
488
+
489
+ async def list_identities(
490
+ self,
491
+ *,
492
+ name: typing.Optional[str] = None,
493
+ project_id: typing.Optional[str] = None,
494
+ identity_type: typing.Optional[IdentityType] = None,
495
+ before: typing.Optional[str] = None,
496
+ after: typing.Optional[str] = None,
497
+ limit: typing.Optional[int] = None,
498
+ request_options: typing.Optional[RequestOptions] = None,
499
+ ) -> typing.List[Identity]:
500
+ """
501
+ Get a list of all identities in the database
502
+
503
+ Parameters
504
+ ----------
505
+ name : typing.Optional[str]
506
+
507
+ project_id : typing.Optional[str]
508
+
509
+ identity_type : typing.Optional[IdentityType]
510
+
511
+ before : typing.Optional[str]
512
+
513
+ after : typing.Optional[str]
514
+
515
+ limit : typing.Optional[int]
516
+
517
+ request_options : typing.Optional[RequestOptions]
518
+ Request-specific configuration.
519
+
520
+ Returns
521
+ -------
522
+ typing.List[Identity]
523
+ Successful Response
524
+
525
+ Examples
526
+ --------
527
+ import asyncio
528
+
529
+ from letta_client import AsyncLetta
530
+
531
+ client = AsyncLetta(
532
+ token="YOUR_TOKEN",
533
+ )
534
+
535
+
536
+ async def main() -> None:
537
+ await client.identities.list_identities()
538
+
539
+
540
+ asyncio.run(main())
541
+ """
542
+ _response = await self._client_wrapper.httpx_client.request(
543
+ "v1/identities/",
544
+ method="GET",
545
+ params={
546
+ "name": name,
547
+ "project_id": project_id,
548
+ "identity_type": identity_type,
549
+ "before": before,
550
+ "after": after,
551
+ "limit": limit,
552
+ },
553
+ request_options=request_options,
554
+ )
555
+ try:
556
+ if 200 <= _response.status_code < 300:
557
+ return typing.cast(
558
+ typing.List[Identity],
559
+ construct_type(
560
+ type_=typing.List[Identity], # type: ignore
561
+ object_=_response.json(),
562
+ ),
563
+ )
564
+ if _response.status_code == 422:
565
+ raise UnprocessableEntityError(
566
+ typing.cast(
567
+ HttpValidationError,
568
+ construct_type(
569
+ type_=HttpValidationError, # type: ignore
570
+ object_=_response.json(),
571
+ ),
572
+ )
573
+ )
574
+ _response_json = _response.json()
575
+ except JSONDecodeError:
576
+ raise ApiError(status_code=_response.status_code, body=_response.text)
577
+ raise ApiError(status_code=_response.status_code, body=_response_json)
578
+
579
+ async def create_identity(
580
+ self,
581
+ *,
582
+ identifier_key: str,
583
+ name: str,
584
+ identity_type: IdentityType,
585
+ project_slug: typing.Optional[str] = None,
586
+ project_id: typing.Optional[str] = OMIT,
587
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
588
+ request_options: typing.Optional[RequestOptions] = None,
589
+ ) -> Identity:
590
+ """
591
+ Parameters
592
+ ----------
593
+ identifier_key : str
594
+ External, user-generated identifier key of the identity.
595
+
596
+ name : str
597
+ The name of the identity.
598
+
599
+ identity_type : IdentityType
600
+ The type of the identity.
601
+
602
+ project_slug : typing.Optional[str]
603
+
604
+ project_id : typing.Optional[str]
605
+ The project id of the identity, if applicable.
606
+
607
+ agent_ids : typing.Optional[typing.Sequence[str]]
608
+ The agent ids that are associated with the identity.
609
+
610
+ request_options : typing.Optional[RequestOptions]
611
+ Request-specific configuration.
612
+
613
+ Returns
614
+ -------
615
+ Identity
616
+ Successful Response
617
+
618
+ Examples
619
+ --------
620
+ import asyncio
621
+
622
+ from letta_client import AsyncLetta
623
+
624
+ client = AsyncLetta(
625
+ token="YOUR_TOKEN",
626
+ )
627
+
628
+
629
+ async def main() -> None:
630
+ await client.identities.create_identity(
631
+ identifier_key="identifier_key",
632
+ name="name",
633
+ identity_type="org",
634
+ )
635
+
636
+
637
+ asyncio.run(main())
638
+ """
639
+ _response = await self._client_wrapper.httpx_client.request(
640
+ "v1/identities/",
641
+ method="POST",
642
+ json={
643
+ "identifier_key": identifier_key,
644
+ "name": name,
645
+ "identity_type": identity_type,
646
+ "project_id": project_id,
647
+ "agent_ids": agent_ids,
648
+ },
649
+ headers={
650
+ "project-slug": str(project_slug) if project_slug is not None else None,
651
+ },
652
+ request_options=request_options,
653
+ omit=OMIT,
654
+ )
655
+ try:
656
+ if 200 <= _response.status_code < 300:
657
+ return typing.cast(
658
+ Identity,
659
+ construct_type(
660
+ type_=Identity, # type: ignore
661
+ object_=_response.json(),
662
+ ),
663
+ )
664
+ if _response.status_code == 422:
665
+ raise UnprocessableEntityError(
666
+ typing.cast(
667
+ HttpValidationError,
668
+ construct_type(
669
+ type_=HttpValidationError, # type: ignore
670
+ object_=_response.json(),
671
+ ),
672
+ )
673
+ )
674
+ _response_json = _response.json()
675
+ except JSONDecodeError:
676
+ raise ApiError(status_code=_response.status_code, body=_response.text)
677
+ raise ApiError(status_code=_response.status_code, body=_response_json)
678
+
679
+ async def upsert_identity(
680
+ self,
681
+ *,
682
+ identifier_key: str,
683
+ name: str,
684
+ identity_type: IdentityType,
685
+ project_slug: typing.Optional[str] = None,
686
+ project_id: typing.Optional[str] = OMIT,
687
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
688
+ request_options: typing.Optional[RequestOptions] = None,
689
+ ) -> Identity:
690
+ """
691
+ Parameters
692
+ ----------
693
+ identifier_key : str
694
+ External, user-generated identifier key of the identity.
695
+
696
+ name : str
697
+ The name of the identity.
698
+
699
+ identity_type : IdentityType
700
+ The type of the identity.
701
+
702
+ project_slug : typing.Optional[str]
703
+
704
+ project_id : typing.Optional[str]
705
+ The project id of the identity, if applicable.
706
+
707
+ agent_ids : typing.Optional[typing.Sequence[str]]
708
+ The agent ids that are associated with the identity.
709
+
710
+ request_options : typing.Optional[RequestOptions]
711
+ Request-specific configuration.
712
+
713
+ Returns
714
+ -------
715
+ Identity
716
+ Successful Response
717
+
718
+ Examples
719
+ --------
720
+ import asyncio
721
+
722
+ from letta_client import AsyncLetta
723
+
724
+ client = AsyncLetta(
725
+ token="YOUR_TOKEN",
726
+ )
727
+
728
+
729
+ async def main() -> None:
730
+ await client.identities.upsert_identity(
731
+ identifier_key="identifier_key",
732
+ name="name",
733
+ identity_type="org",
734
+ )
735
+
736
+
737
+ asyncio.run(main())
738
+ """
739
+ _response = await self._client_wrapper.httpx_client.request(
740
+ "v1/identities/",
741
+ method="PUT",
742
+ json={
743
+ "identifier_key": identifier_key,
744
+ "name": name,
745
+ "identity_type": identity_type,
746
+ "project_id": project_id,
747
+ "agent_ids": agent_ids,
748
+ },
749
+ headers={
750
+ "project-slug": str(project_slug) if project_slug is not None else None,
751
+ },
752
+ request_options=request_options,
753
+ omit=OMIT,
754
+ )
755
+ try:
756
+ if 200 <= _response.status_code < 300:
757
+ return typing.cast(
758
+ Identity,
759
+ construct_type(
760
+ type_=Identity, # type: ignore
761
+ object_=_response.json(),
762
+ ),
763
+ )
764
+ if _response.status_code == 422:
765
+ raise UnprocessableEntityError(
766
+ typing.cast(
767
+ HttpValidationError,
768
+ construct_type(
769
+ type_=HttpValidationError, # type: ignore
770
+ object_=_response.json(),
771
+ ),
772
+ )
773
+ )
774
+ _response_json = _response.json()
775
+ except JSONDecodeError:
776
+ raise ApiError(status_code=_response.status_code, body=_response.text)
777
+ raise ApiError(status_code=_response.status_code, body=_response_json)
778
+
779
+ async def get_identity_from_identifier_key(
780
+ self, identifier_key: str, *, request_options: typing.Optional[RequestOptions] = None
781
+ ) -> Identity:
782
+ """
783
+ Parameters
784
+ ----------
785
+ identifier_key : str
786
+
787
+ request_options : typing.Optional[RequestOptions]
788
+ Request-specific configuration.
789
+
790
+ Returns
791
+ -------
792
+ Identity
793
+ Successful Response
794
+
795
+ Examples
796
+ --------
797
+ import asyncio
798
+
799
+ from letta_client import AsyncLetta
800
+
801
+ client = AsyncLetta(
802
+ token="YOUR_TOKEN",
803
+ )
804
+
805
+
806
+ async def main() -> None:
807
+ await client.identities.get_identity_from_identifier_key(
808
+ identifier_key="identifier_key",
809
+ )
810
+
811
+
812
+ asyncio.run(main())
813
+ """
814
+ _response = await self._client_wrapper.httpx_client.request(
815
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
816
+ method="GET",
817
+ request_options=request_options,
818
+ )
819
+ try:
820
+ if 200 <= _response.status_code < 300:
821
+ return typing.cast(
822
+ Identity,
823
+ construct_type(
824
+ type_=Identity, # type: ignore
825
+ object_=_response.json(),
826
+ ),
827
+ )
828
+ if _response.status_code == 422:
829
+ raise UnprocessableEntityError(
830
+ typing.cast(
831
+ HttpValidationError,
832
+ construct_type(
833
+ type_=HttpValidationError, # type: ignore
834
+ object_=_response.json(),
835
+ ),
836
+ )
837
+ )
838
+ _response_json = _response.json()
839
+ except JSONDecodeError:
840
+ raise ApiError(status_code=_response.status_code, body=_response.text)
841
+ raise ApiError(status_code=_response.status_code, body=_response_json)
842
+
843
+ async def delete_identity(
844
+ self, identifier_key: str, *, request_options: typing.Optional[RequestOptions] = None
845
+ ) -> typing.Optional[typing.Any]:
846
+ """
847
+ Delete an identity by its identifier key
848
+
849
+ Parameters
850
+ ----------
851
+ identifier_key : str
852
+
853
+ request_options : typing.Optional[RequestOptions]
854
+ Request-specific configuration.
855
+
856
+ Returns
857
+ -------
858
+ typing.Optional[typing.Any]
859
+ Successful Response
860
+
861
+ Examples
862
+ --------
863
+ import asyncio
864
+
865
+ from letta_client import AsyncLetta
866
+
867
+ client = AsyncLetta(
868
+ token="YOUR_TOKEN",
869
+ )
870
+
871
+
872
+ async def main() -> None:
873
+ await client.identities.delete_identity(
874
+ identifier_key="identifier_key",
875
+ )
876
+
877
+
878
+ asyncio.run(main())
879
+ """
880
+ _response = await self._client_wrapper.httpx_client.request(
881
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
882
+ method="DELETE",
883
+ request_options=request_options,
884
+ )
885
+ try:
886
+ if 200 <= _response.status_code < 300:
887
+ return typing.cast(
888
+ typing.Optional[typing.Any],
889
+ construct_type(
890
+ type_=typing.Optional[typing.Any], # type: ignore
891
+ object_=_response.json(),
892
+ ),
893
+ )
894
+ if _response.status_code == 422:
895
+ raise UnprocessableEntityError(
896
+ typing.cast(
897
+ HttpValidationError,
898
+ construct_type(
899
+ type_=HttpValidationError, # type: ignore
900
+ object_=_response.json(),
901
+ ),
902
+ )
903
+ )
904
+ _response_json = _response.json()
905
+ except JSONDecodeError:
906
+ raise ApiError(status_code=_response.status_code, body=_response.text)
907
+ raise ApiError(status_code=_response.status_code, body=_response_json)
908
+
909
+ async def update_identity(
910
+ self,
911
+ identifier_key: str,
912
+ *,
913
+ name: typing.Optional[str] = OMIT,
914
+ identity_type: typing.Optional[IdentityType] = OMIT,
915
+ agent_ids: typing.Optional[typing.Sequence[str]] = OMIT,
916
+ request_options: typing.Optional[RequestOptions] = None,
917
+ ) -> Identity:
918
+ """
919
+ Parameters
920
+ ----------
921
+ identifier_key : str
922
+
923
+ name : typing.Optional[str]
924
+ The name of the identity.
925
+
926
+ identity_type : typing.Optional[IdentityType]
927
+ The type of the identity.
928
+
929
+ agent_ids : typing.Optional[typing.Sequence[str]]
930
+ The agent ids that are associated with the identity.
931
+
932
+ request_options : typing.Optional[RequestOptions]
933
+ Request-specific configuration.
934
+
935
+ Returns
936
+ -------
937
+ Identity
938
+ Successful Response
939
+
940
+ Examples
941
+ --------
942
+ import asyncio
943
+
944
+ from letta_client import AsyncLetta
945
+
946
+ client = AsyncLetta(
947
+ token="YOUR_TOKEN",
948
+ )
949
+
950
+
951
+ async def main() -> None:
952
+ await client.identities.update_identity(
953
+ identifier_key="identifier_key",
954
+ )
955
+
956
+
957
+ asyncio.run(main())
958
+ """
959
+ _response = await self._client_wrapper.httpx_client.request(
960
+ f"v1/identities/{jsonable_encoder(identifier_key)}",
961
+ method="PATCH",
962
+ json={
963
+ "name": name,
964
+ "identity_type": identity_type,
965
+ "agent_ids": agent_ids,
966
+ },
967
+ headers={
968
+ "content-type": "application/json",
969
+ },
970
+ request_options=request_options,
971
+ omit=OMIT,
972
+ )
973
+ try:
974
+ if 200 <= _response.status_code < 300:
975
+ return typing.cast(
976
+ Identity,
977
+ construct_type(
978
+ type_=Identity, # type: ignore
179
979
  object_=_response.json(),
180
980
  ),
181
981
  )