benchling-sdk 1.17.0a0__py3-none-any.whl → 1.18.0__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.
Files changed (27) hide show
  1. benchling_sdk/benchling.py +50 -0
  2. benchling_sdk/errors.py +2 -1
  3. benchling_sdk/models/__init__.py +159 -3
  4. benchling_sdk/models/webhooks/v0/__init__.py +27 -37
  5. benchling_sdk/services/v2/alpha/v2_alpha_assembly_service.py +62 -0
  6. benchling_sdk/services/v2/beta/v2_beta_analysis_service.py +46 -0
  7. benchling_sdk/services/v2/beta/v2_beta_app_definition_service.py +45 -0
  8. benchling_sdk/services/v2/beta/v2_beta_app_service.py +1 -1
  9. benchling_sdk/services/v2/beta/v2_beta_audit_service.py +41 -0
  10. benchling_sdk/services/v2/beta/v2_beta_entry_service.py +13 -8
  11. benchling_sdk/services/v2/stable/aa_sequence_service.py +63 -6
  12. benchling_sdk/services/v2/stable/codon_usage_table_service.py +73 -0
  13. benchling_sdk/services/v2/stable/dna_sequence_service.py +12 -0
  14. benchling_sdk/services/v2/stable/enzyme_service.py +72 -0
  15. benchling_sdk/services/v2/stable/instrument_query_service.py +28 -0
  16. benchling_sdk/services/v2/stable/monomer_service.py +144 -0
  17. benchling_sdk/services/v2/stable/organization_service.py +104 -2
  18. benchling_sdk/services/v2/stable/team_service.py +120 -2
  19. benchling_sdk/services/v2/v2_alpha_service.py +15 -0
  20. benchling_sdk/services/v2/v2_beta_service.py +43 -1
  21. benchling_sdk/services/v2/v2_stable_service.py +58 -0
  22. {benchling_sdk-1.17.0a0.dist-info → benchling_sdk-1.18.0.dist-info}/METADATA +3 -3
  23. {benchling_sdk-1.17.0a0.dist-info → benchling_sdk-1.18.0.dist-info}/RECORD +25 -19
  24. benchling_sdk/apps/config/helpers.py +0 -157
  25. benchling_sdk/apps/config/mock_config.py +0 -635
  26. {benchling_sdk-1.17.0a0.dist-info → benchling_sdk-1.18.0.dist-info}/LICENSE +0 -0
  27. {benchling_sdk-1.17.0a0.dist-info → benchling_sdk-1.18.0.dist-info}/WHEEL +0 -0
@@ -19,12 +19,10 @@ __all__ = [
19
19
  "AssayRunCreatedWebhookV2Type",
20
20
  "AssayRunUpdatedFieldsWebhookV2",
21
21
  "AssayRunUpdatedFieldsWebhookV2Type",
22
- "CanvasInitializeWebhookV0",
23
- "CanvasInitializeWebhookV0Type",
22
+ "CanvasCreatedWebhookV2Beta",
23
+ "CanvasCreatedWebhookV2BetaType",
24
24
  "CanvasInitializeWebhookV2",
25
25
  "CanvasInitializeWebhookV2Type",
26
- "CanvasInteractionWebhookV0",
27
- "CanvasInteractionWebhookV0Type",
28
26
  "CanvasInteractionWebhookV2",
29
27
  "CanvasInteractionWebhookV2Type",
30
28
  "EntityRegisteredWebhookV2",
@@ -37,8 +35,6 @@ __all__ = [
37
35
  "EntryUpdatedReviewRecordWebhookV2Type",
38
36
  "EventBaseWebhookV2",
39
37
  "EventBaseWebhookV2Schematized",
40
- "EventCreatedWebhookV0Beta",
41
- "EventCreatedWebhookV0BetaType",
42
38
  "EventResourceSchema",
43
39
  "LifecycleActivateWebhookV0",
44
40
  "LifecycleActivateWebhookV0Beta",
@@ -111,6 +107,8 @@ __all__ = [
111
107
  "WorkflowTaskCreatedWebhookV2Type",
112
108
  "WorkflowTaskGroupCreatedWebhookV2",
113
109
  "WorkflowTaskGroupCreatedWebhookV2Type",
110
+ "WorkflowTaskGroupMappingCompletedWebhookV2",
111
+ "WorkflowTaskGroupMappingCompletedWebhookV2Type",
114
112
  "WorkflowTaskGroupUpdatedWatchersWebhookV2",
115
113
  "WorkflowTaskGroupUpdatedWatchersWebhookV2Type",
116
114
  "WorkflowTaskUpdatedAssigneeWebhookV2",
@@ -134,12 +132,10 @@ if TYPE_CHECKING:
134
132
  import benchling_api_client.webhooks.v0.stable.models.assay_run_created_webhook_v2_type
135
133
  import benchling_api_client.webhooks.v0.stable.models.assay_run_updated_fields_webhook_v2
136
134
  import benchling_api_client.webhooks.v0.stable.models.assay_run_updated_fields_webhook_v2_type
137
- import benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0
138
- import benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0_type
135
+ import benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta
136
+ import benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta_type
139
137
  import benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2
140
138
  import benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2_type
141
- import benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0
142
- import benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0_type
143
139
  import benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v2
144
140
  import benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v2_type
145
141
  import benchling_api_client.webhooks.v0.stable.models.entity_registered_webhook_v2
@@ -152,8 +148,6 @@ if TYPE_CHECKING:
152
148
  import benchling_api_client.webhooks.v0.stable.models.entry_updated_review_record_webhook_v2_type
153
149
  import benchling_api_client.webhooks.v0.stable.models.event_base_webhook_v2
154
150
  import benchling_api_client.webhooks.v0.stable.models.event_base_webhook_v2_schematized
155
- import benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta
156
- import benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta_type
157
151
  import benchling_api_client.webhooks.v0.stable.models.event_resource_schema
158
152
  import benchling_api_client.webhooks.v0.stable.models.lifecycle_activate_webhook_v0
159
153
  import benchling_api_client.webhooks.v0.stable.models.lifecycle_activate_webhook_v0_beta
@@ -226,6 +220,8 @@ if TYPE_CHECKING:
226
220
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_created_webhook_v2_type
227
221
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_created_webhook_v2
228
222
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_created_webhook_v2_type
223
+ import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2
224
+ import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2_type
229
225
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_updated_watchers_webhook_v2
230
226
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_group_updated_watchers_webhook_v2_type
231
227
  import benchling_api_client.webhooks.v0.stable.models.workflow_task_updated_assignee_webhook_v2
@@ -267,11 +263,11 @@ if TYPE_CHECKING:
267
263
  AssayRunUpdatedFieldsWebhookV2Type = (
268
264
  benchling_api_client.webhooks.v0.stable.models.assay_run_updated_fields_webhook_v2_type.AssayRunUpdatedFieldsWebhookV2Type
269
265
  )
270
- CanvasInitializeWebhookV0 = (
271
- benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0.CanvasInitializeWebhookV0
266
+ CanvasCreatedWebhookV2Beta = (
267
+ benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta.CanvasCreatedWebhookV2Beta
272
268
  )
273
- CanvasInitializeWebhookV0Type = (
274
- benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0_type.CanvasInitializeWebhookV0Type
269
+ CanvasCreatedWebhookV2BetaType = (
270
+ benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta_type.CanvasCreatedWebhookV2BetaType
275
271
  )
276
272
  CanvasInitializeWebhookV2 = (
277
273
  benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2.CanvasInitializeWebhookV2
@@ -279,12 +275,6 @@ if TYPE_CHECKING:
279
275
  CanvasInitializeWebhookV2Type = (
280
276
  benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2_type.CanvasInitializeWebhookV2Type
281
277
  )
282
- CanvasInteractionWebhookV0 = (
283
- benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0.CanvasInteractionWebhookV0
284
- )
285
- CanvasInteractionWebhookV0Type = (
286
- benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0_type.CanvasInteractionWebhookV0Type
287
- )
288
278
  CanvasInteractionWebhookV2 = (
289
279
  benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v2.CanvasInteractionWebhookV2
290
280
  )
@@ -321,12 +311,6 @@ if TYPE_CHECKING:
321
311
  EventBaseWebhookV2Schematized = (
322
312
  benchling_api_client.webhooks.v0.stable.models.event_base_webhook_v2_schematized.EventBaseWebhookV2Schematized
323
313
  )
324
- EventCreatedWebhookV0Beta = (
325
- benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta.EventCreatedWebhookV0Beta
326
- )
327
- EventCreatedWebhookV0BetaType = (
328
- benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta_type.EventCreatedWebhookV0BetaType
329
- )
330
314
  EventResourceSchema = (
331
315
  benchling_api_client.webhooks.v0.stable.models.event_resource_schema.EventResourceSchema
332
316
  )
@@ -535,6 +519,12 @@ if TYPE_CHECKING:
535
519
  WorkflowTaskGroupCreatedWebhookV2Type = (
536
520
  benchling_api_client.webhooks.v0.stable.models.workflow_task_group_created_webhook_v2_type.WorkflowTaskGroupCreatedWebhookV2Type
537
521
  )
522
+ WorkflowTaskGroupMappingCompletedWebhookV2 = (
523
+ benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2.WorkflowTaskGroupMappingCompletedWebhookV2
524
+ )
525
+ WorkflowTaskGroupMappingCompletedWebhookV2Type = (
526
+ benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2_type.WorkflowTaskGroupMappingCompletedWebhookV2Type
527
+ )
538
528
  WorkflowTaskGroupUpdatedWatchersWebhookV2 = (
539
529
  benchling_api_client.webhooks.v0.stable.models.workflow_task_group_updated_watchers_webhook_v2.WorkflowTaskGroupUpdatedWatchersWebhookV2
540
530
  )
@@ -578,12 +568,10 @@ else:
578
568
  "AssayRunCreatedWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.assay_run_created_webhook_v2_type",
579
569
  "AssayRunUpdatedFieldsWebhookV2": "benchling_api_client.webhooks.v0.stable.models.assay_run_updated_fields_webhook_v2",
580
570
  "AssayRunUpdatedFieldsWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.assay_run_updated_fields_webhook_v2_type",
581
- "CanvasInitializeWebhookV0": "benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0",
582
- "CanvasInitializeWebhookV0Type": "benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v0_type",
571
+ "CanvasCreatedWebhookV2Beta": "benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta",
572
+ "CanvasCreatedWebhookV2BetaType": "benchling_api_client.webhooks.v0.stable.models.canvas_created_webhook_v2_beta_type",
583
573
  "CanvasInitializeWebhookV2": "benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2",
584
574
  "CanvasInitializeWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.canvas_initialize_webhook_v2_type",
585
- "CanvasInteractionWebhookV0": "benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0",
586
- "CanvasInteractionWebhookV0Type": "benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v0_type",
587
575
  "CanvasInteractionWebhookV2": "benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v2",
588
576
  "CanvasInteractionWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.canvas_interaction_webhook_v2_type",
589
577
  "EntityRegisteredWebhookV2": "benchling_api_client.webhooks.v0.stable.models.entity_registered_webhook_v2",
@@ -596,8 +584,6 @@ else:
596
584
  "EntryUpdatedReviewRecordWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.entry_updated_review_record_webhook_v2_type",
597
585
  "EventBaseWebhookV2": "benchling_api_client.webhooks.v0.stable.models.event_base_webhook_v2",
598
586
  "EventBaseWebhookV2Schematized": "benchling_api_client.webhooks.v0.stable.models.event_base_webhook_v2_schematized",
599
- "EventCreatedWebhookV0Beta": "benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta",
600
- "EventCreatedWebhookV0BetaType": "benchling_api_client.webhooks.v0.stable.models.event_created_webhook_v0_beta_type",
601
587
  "EventResourceSchema": "benchling_api_client.webhooks.v0.stable.models.event_resource_schema",
602
588
  "LifecycleActivateWebhookV0": "benchling_api_client.webhooks.v0.stable.models.lifecycle_activate_webhook_v0",
603
589
  "LifecycleActivateWebhookV0Beta": "benchling_api_client.webhooks.v0.stable.models.lifecycle_activate_webhook_v0_beta",
@@ -670,6 +656,8 @@ else:
670
656
  "WorkflowTaskCreatedWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.workflow_task_created_webhook_v2_type",
671
657
  "WorkflowTaskGroupCreatedWebhookV2": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_created_webhook_v2",
672
658
  "WorkflowTaskGroupCreatedWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_created_webhook_v2_type",
659
+ "WorkflowTaskGroupMappingCompletedWebhookV2": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2",
660
+ "WorkflowTaskGroupMappingCompletedWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_mapping_completed_webhook_v2_type",
673
661
  "WorkflowTaskGroupUpdatedWatchersWebhookV2": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_updated_watchers_webhook_v2",
674
662
  "WorkflowTaskGroupUpdatedWatchersWebhookV2Type": "benchling_api_client.webhooks.v0.stable.models.workflow_task_group_updated_watchers_webhook_v2_type",
675
663
  "WorkflowTaskUpdatedAssigneeWebhookV2": "benchling_api_client.webhooks.v0.stable.models.workflow_task_updated_assignee_webhook_v2",
@@ -687,9 +675,11 @@ else:
687
675
  # Custom module to allow for lazy loading of models
688
676
  class _Models(ModuleType):
689
677
  def __getattr__(self, name):
690
- module = __import__(model_to_module_mapping[name], None, None, [name])
691
- setattr(self, name, getattr(module, name))
692
- return ModuleType.__getattribute__(self, name)
678
+ if module_name := model_to_module_mapping.get(name):
679
+ module = __import__(module_name, None, None, [name])
680
+ setattr(self, name, getattr(module, name))
681
+ return ModuleType.__getattribute__(self, name)
682
+ return ModuleType.__getattr__(self, name)
693
683
 
694
684
  # keep a reference to this module so that it's not garbage collected
695
685
  old_module = sys.modules[__name__]
@@ -0,0 +1,62 @@
1
+ from benchling_api_client.v2.alpha.api.assemblies import (
2
+ create_and_finalize_assembly,
3
+ get_assembly,
4
+ validate_assembly,
5
+ )
6
+ from benchling_api_client.v2.alpha.models.assembly import Assembly
7
+ from benchling_api_client.v2.alpha.models.assembly_spec_shared import AssemblySpecShared
8
+ from benchling_api_client.v2.alpha.models.create_and_finalize_assembly_json_body import (
9
+ CreateAndFinalizeAssemblyJsonBody,
10
+ )
11
+
12
+ from benchling_sdk.helpers.decorators import api_method
13
+ from benchling_sdk.helpers.response_helpers import model_from_detailed
14
+ from benchling_sdk.models import AsyncTaskLink
15
+ from benchling_sdk.services.v2.base_service import BaseService
16
+
17
+
18
+ class V2AlphaAssemblyService(BaseService):
19
+ """
20
+ V2-Alpha Assemblies.
21
+
22
+ In Benchling, Assemblies are records of a process in which many fragment sequences are
23
+ assembled in silico to create new construct sequences.
24
+
25
+ https://benchling.com/api/v2-alpha/reference#/Assemblies
26
+ """
27
+
28
+ @api_method
29
+ def get_by_id(self, bulk_assembly_id: str) -> Assembly:
30
+ """
31
+ Get a bulk assembly by its API identifier.
32
+
33
+ See https://benchling.com/api/v2-alpha/reference#/Assemblies/GetAssembly
34
+ """
35
+ response = get_assembly.sync_detailed(client=self.client, bulk_assembly_id=bulk_assembly_id)
36
+ return model_from_detailed(response)
37
+
38
+ @api_method
39
+ def create_and_finalize(self, create: CreateAndFinalizeAssemblyJsonBody) -> AsyncTaskLink:
40
+ """
41
+ Create and finalize a new bulk assembly in a single step.
42
+
43
+ This endpoint launches a long-running task and returns the Task ID of the launched task.
44
+ The task response contains a finalized bulk assembly.
45
+
46
+ See https://benchling.com/api/v2-alpha/reference#/Assemblies/CreateAndFinalizeAssembly
47
+ """
48
+ response = create_and_finalize_assembly.sync_detailed(client=self.client, json_body=create)
49
+ return model_from_detailed(response)
50
+
51
+ @api_method
52
+ def validate(self, assembly: AssemblySpecShared) -> AsyncTaskLink:
53
+ """
54
+ Validate an assembly prior to finalization to see if it will succeed.
55
+
56
+ This endpoint launches a long-running task and returns the Task ID of the launched task.
57
+ The task response contains a set of validation results.
58
+
59
+ See https://benchling.com/api/v2-alpha/reference#/Assemblies/ValidateAssembly
60
+ """
61
+ response = validate_assembly.sync_detailed(client=self.client, json_body=assembly)
62
+ return model_from_detailed(response)
@@ -0,0 +1,46 @@
1
+ from typing import List, Optional
2
+
3
+ from benchling_api_client.v2.beta.api.analyses import get_analysis, update_analysis
4
+ from benchling_api_client.v2.beta.models.analysis import Analysis
5
+ from benchling_api_client.v2.beta.models.analysis_update import AnalysisUpdate
6
+
7
+ from benchling_sdk.helpers.decorators import api_method
8
+ from benchling_sdk.helpers.response_helpers import model_from_detailed
9
+ from benchling_sdk.helpers.serialization_helpers import none_as_unset, optional_array_query_param
10
+ from benchling_sdk.services.v2.base_service import BaseService
11
+
12
+
13
+ class V2BetaAnalysisService(BaseService):
14
+ """
15
+ V2-Beta Analyses.
16
+
17
+ Analyses allow experimental data to be viewed, analyzed, and visualized.
18
+
19
+ https://benchling.com/api/v2-beta/reference#/Analyses
20
+ """
21
+
22
+ @api_method
23
+ def get_by_id(self, analysis_id: str, returning: Optional[List[str]] = None) -> Analysis:
24
+ """
25
+ Get an analysis.
26
+
27
+ See https://benchling.com/api/v2-beta/reference#/Analyses/getAnalysis
28
+ """
29
+ response = get_analysis.sync_detailed(
30
+ client=self.client,
31
+ analysis_id=analysis_id,
32
+ returning=none_as_unset(optional_array_query_param(returning)),
33
+ )
34
+ return model_from_detailed(response)
35
+
36
+ @api_method
37
+ def update(self, analysis_id: str, update: AnalysisUpdate) -> Analysis:
38
+ """
39
+ Update an analysis.
40
+
41
+ See https://benchling.com/api/v2-beta/reference#/Analyses/updateAnalysis
42
+ """
43
+ response = update_analysis.sync_detailed(
44
+ client=self.client, analysis_id=analysis_id, json_body=update
45
+ )
46
+ return model_from_detailed(response)
@@ -0,0 +1,45 @@
1
+ from benchling_api_client.v2.beta.api.app_definitions import (
2
+ get_benchling_app_definition_version_manifest,
3
+ put_benchling_app_definition_version_manifest,
4
+ )
5
+ from benchling_api_client.v2.beta.models.benchling_app_manifest import BenchlingAppManifest
6
+
7
+ from benchling_sdk.helpers.decorators import api_method
8
+ from benchling_sdk.helpers.response_helpers import model_from_detailed
9
+ from benchling_sdk.services.v2.base_service import BaseService
10
+
11
+
12
+ class V2BetaAppDefinitionService(BaseService):
13
+ """
14
+ V2-Beta App Definitions.
15
+
16
+ Create and manage Benchling app definitions on your tenant.
17
+
18
+ https://benchling.com/api/v2-beta/reference#/App%20Definitions
19
+ """
20
+
21
+ @api_method
22
+ def get_version_manifest(self, app_def_id: str, version_id: str) -> BenchlingAppManifest:
23
+ """
24
+ Get manifest for an app definition version.
25
+
26
+ See https://benchling.com/api/v2-beta/reference#/App%20Definitions/getBenchlingAppDefinitionVersionManifest
27
+ """
28
+ response = get_benchling_app_definition_version_manifest.sync_detailed(
29
+ client=self.client, app_def_id=app_def_id, version_id=version_id
30
+ )
31
+ return model_from_detailed(response)
32
+
33
+ @api_method
34
+ def put_version_manifest(
35
+ self, app_def_id: str, version_id: str, manifest: BenchlingAppManifest
36
+ ) -> BenchlingAppManifest:
37
+ """
38
+ Create or update app definition version from a manifest.
39
+
40
+ See https://benchling.com/api/v2-beta/reference#/App%20Definitions/putBenchlingAppDefinitionVersionManifest
41
+ """
42
+ response = put_benchling_app_definition_version_manifest.sync_detailed(
43
+ client=self.client, app_def_id=app_def_id, version_id=version_id, yaml_body=manifest
44
+ )
45
+ return model_from_detailed(response)
@@ -12,7 +12,7 @@ class V2BetaAppService(BaseService):
12
12
 
13
13
  Create and manage Apps on your tenant.
14
14
 
15
- https://benchling.com/api/v2-beta/reference?stability=not-available#/Apps
15
+ https://benchling.com/api/v2-beta/reference#/Apps
16
16
  """
17
17
 
18
18
  @api_method
@@ -0,0 +1,41 @@
1
+ from benchling_api_client.v2.beta.api.audit import audit_log
2
+ from benchling_api_client.v2.beta.models.audit_log_export import AuditLogExport
3
+
4
+ from benchling_sdk.helpers.decorators import api_method
5
+ from benchling_sdk.helpers.response_helpers import model_from_detailed
6
+ from benchling_sdk.models import AsyncTaskLink
7
+ from benchling_sdk.services.v2.base_service import BaseService
8
+
9
+
10
+ class V2BetaAuditService(BaseService):
11
+ """
12
+ V2-Beta Audit Service.
13
+
14
+ Export audit log data for Benchling objects.
15
+
16
+ https://benchling.com/api/v2-beta/reference#/Audit
17
+ """
18
+
19
+ @api_method
20
+ def get_audit_log(self, object_id: str, export: AuditLogExport) -> AsyncTaskLink:
21
+ """
22
+ Export an audit log file for a Benchling object.
23
+
24
+ This endpoint launches a long-running task and returns the Task ID of the
25
+ launched task. The task response contains a link to download the exported audit
26
+ log file from Amazon S3. This endpoint is subject to a rate limit of 500 requests
27
+ per hour, in conjunction with the global request rate limit. Export throughput
28
+ will additionally be rate limited around the scale of 70,000 total audit events
29
+ exported in csv format or 30,000 total audit events exported in pdf format per hour.
30
+
31
+ Example of submitting an export request and then getting the download URL from
32
+ the completed task:
33
+
34
+ task_link = benchling.v2.beta.audit.get_audit_log(object_id, export)
35
+ task = benchling.tasks.wait_for_task(task_link.task_id)
36
+ url = task.response["downloadURL"]
37
+
38
+ See https://benchling.com/api/v2-beta/reference#/Audit/auditLog
39
+ """
40
+ response = audit_log.sync_detailed(client=self.client, object_id=object_id, json_body=export)
41
+ return model_from_detailed(response)
@@ -1,9 +1,12 @@
1
- from benchling_api_client.v2.beta.api.entries import create_entry
1
+ from typing import Iterable, Optional
2
+
3
+ from benchling_api_client.v2.beta.api.entries import update_entry
2
4
  from benchling_api_client.v2.beta.models.entry import Entry
3
- from benchling_api_client.v2.beta.models.entry_create import EntryCreate
5
+ from benchling_api_client.v2.beta.models.entry_update import EntryUpdate
4
6
 
5
7
  from benchling_sdk.helpers.decorators import api_method
6
8
  from benchling_sdk.helpers.response_helpers import model_from_detailed
9
+ from benchling_sdk.helpers.serialization_helpers import none_as_unset, optional_array_query_param
7
10
  from benchling_sdk.services.v2.base_service import BaseService
8
11
 
9
12
 
@@ -17,14 +20,16 @@ class V2BetaEntryService(BaseService):
17
20
  """
18
21
 
19
22
  @api_method
20
- def create_entry(self, entry: EntryCreate) -> Entry:
23
+ def update_entry(
24
+ self, entry_id: str, entry: EntryUpdate, returning: Optional[Iterable[str]] = None
25
+ ) -> Entry:
21
26
  """
22
- Create a notebook entry against beta endpoint, supporting initialTables.
27
+ Update a notebook entry's metadata.
23
28
 
24
- See https://benchling.com/api/v2-beta/reference#/Entries/createEntry
29
+ See https://benchling.com/api/v2-beta/reference#/Entries/updateEntry
25
30
  """
26
- response = create_entry.sync_detailed(
27
- client=self.client,
28
- json_body=entry,
31
+ returning_string = optional_array_query_param(returning)
32
+ response = update_entry.sync_detailed(
33
+ client=self.client, entry_id=entry_id, json_body=entry, returning=none_as_unset(returning_string)
29
34
  )
30
35
  return model_from_detailed(response)
@@ -1,8 +1,10 @@
1
1
  from typing import Any, Dict, Iterable, List, Optional, Union
2
2
 
3
+ from attr import evolve
3
4
  from benchling_api_client.v2.stable.api.aa_sequences import (
4
5
  archive_aa_sequences,
5
6
  auto_annotate_aa_sequences,
7
+ back_translate,
6
8
  bulk_create_aa_sequences,
7
9
  bulk_get_aa_sequences,
8
10
  bulk_update_aa_sequences,
@@ -11,6 +13,8 @@ from benchling_api_client.v2.stable.api.aa_sequences import (
11
13
  find_matching_regions_aa_sequences,
12
14
  get_aa_sequence,
13
15
  list_aa_sequences,
16
+ match_amino_acids_aa_sequences,
17
+ search_aa_sequences,
14
18
  unarchive_aa_sequences,
15
19
  update_aa_sequence,
16
20
  upsert_aa_sequence,
@@ -39,18 +43,25 @@ from benchling_sdk.models import (
39
43
  AaSequencesBulkUpdateRequest,
40
44
  AaSequencesBulkUpsertRequest,
41
45
  AaSequencesFindMatchingRegion,
46
+ AaSequencesMatchBases,
42
47
  AaSequencesPaginatedList,
48
+ AaSequencesSearchBases,
43
49
  AaSequencesUnarchive,
44
50
  AaSequenceUpdate,
45
51
  AaSequenceUpsert,
46
52
  AsyncTaskLink,
47
53
  AutoAnnotateAaSequences,
54
+ BackTranslate,
48
55
  EntityArchiveReason,
49
56
  ListAASequencesSort,
50
57
  )
51
58
  from benchling_sdk.services.v2.base_service import BaseService
52
59
 
53
60
 
61
+ def _list_results_extractor(body: AaSequencesPaginatedList) -> Optional[List[AaSequence]]:
62
+ return body.aa_sequences
63
+
64
+
54
65
  class AaSequenceService(BaseService):
55
66
  """
56
67
  AA Sequences.
@@ -125,8 +136,7 @@ class AaSequenceService(BaseService):
125
136
  author_idsany_of=none_as_unset(optional_array_query_param(author_idsany_of)),
126
137
  returning=none_as_unset(optional_array_query_param(returning)),
127
138
  )
128
- raise_for_status(response)
129
- return response # type: ignore
139
+ return raise_for_status(response)
130
140
 
131
141
  def list(
132
142
  self,
@@ -186,10 +196,7 @@ class AaSequenceService(BaseService):
186
196
  returning=returning,
187
197
  )
188
198
 
189
- def results_extractor(body: AaSequencesPaginatedList) -> Optional[List[AaSequence]]:
190
- return body.aa_sequences
191
-
192
- return PageIterator(api_call, results_extractor)
199
+ return PageIterator(api_call, _list_results_extractor)
193
200
 
194
201
  @api_method
195
202
  def create(self, aa_sequence: AaSequenceCreate) -> AaSequence:
@@ -326,3 +333,53 @@ class AaSequenceService(BaseService):
326
333
  client=self.client, json_body=find_matching_region
327
334
  )
328
335
  return model_from_detailed(response)
336
+
337
+ @api_method
338
+ def back_translate(self, translate: BackTranslate) -> AsyncTaskLink:
339
+ """
340
+ Create back-translated DNA sequences from AA sequences.
341
+
342
+ See https://benchling.com/api/v2/reference#/AA%20Sequences/backTranslate
343
+ """
344
+ response = back_translate.sync_detailed(client=self.client, json_body=translate)
345
+ return model_from_detailed(response)
346
+
347
+ @api_method
348
+ def _match_bases_page(self, match_bases: AaSequencesMatchBases) -> Response[AaSequencesPaginatedList]:
349
+ return raise_for_status(
350
+ match_amino_acids_aa_sequences.sync_detailed(client=self.client, json_body=match_bases)
351
+ )
352
+
353
+ def match_amino_acids(self, match_bases: AaSequencesMatchBases) -> PageIterator[AaSequence]:
354
+ """
355
+ Return AA Sequences that exactly match the provided amino acids.
356
+
357
+ See https://benchling.com/api/reference#/AA%20Sequences/matchAminoAcidsAaSequences
358
+ """
359
+
360
+ def api_call(next_token: NextToken) -> Response[AaSequencesPaginatedList]:
361
+ return self._match_bases_page(evolve(match_bases, next_token=next_token))
362
+
363
+ return PageIterator(api_call, _list_results_extractor)
364
+
365
+ @api_method
366
+ def _search_bases_page(
367
+ self, search_request: AaSequencesSearchBases
368
+ ) -> Response[AaSequencesPaginatedList]:
369
+ return raise_for_status(
370
+ search_aa_sequences.sync_detailed(client=self.client, json_body=search_request)
371
+ )
372
+
373
+ def search(self, search_request: AaSequencesSearchBases) -> PageIterator[AaSequence]:
374
+ """
375
+ Return AA Sequences that contain the provided amino acids.
376
+
377
+ Search indexing is asynchronous, so results my be not be available immediately after creation.
378
+
379
+ See https://benchling.com/api/reference#/AA%20Sequences/searchAaSequences
380
+ """
381
+
382
+ def api_call(next_token: NextToken) -> Response[AaSequencesPaginatedList]:
383
+ return self._search_bases_page(evolve(search_request, next_token=next_token))
384
+
385
+ return PageIterator(api_call, _list_results_extractor)
@@ -0,0 +1,73 @@
1
+ from typing import Iterable, Optional
2
+
3
+ from benchling_api_client.v2.stable.api.codon_usage_tables import list_codon_usage_tables
4
+ from benchling_api_client.v2.types import Response
5
+
6
+ from benchling_sdk.errors import raise_for_status
7
+ from benchling_sdk.helpers.decorators import api_method
8
+ from benchling_sdk.helpers.pagination_helpers import NextToken, PageIterator
9
+ from benchling_sdk.helpers.serialization_helpers import none_as_unset, optional_array_query_param
10
+ from benchling_sdk.models import CodonUsageTable, CodonUsageTablesPaginatedList, ListCodonUsageTablesSort
11
+ from benchling_sdk.services.v2.base_service import BaseService
12
+
13
+
14
+ class CodonUsageTableService(BaseService):
15
+ """
16
+ Codon Usage Tables.
17
+
18
+ Benchling curates codon usage data for a variety of organisms to support operations such as Codon
19
+ Optimization and Back Translation.
20
+
21
+ See https://benchling.com/api/reference#/Codon%20Usage%20Tables
22
+ """
23
+
24
+ @api_method
25
+ def _list_page(
26
+ self,
27
+ sort: Optional[ListCodonUsageTablesSort] = None,
28
+ ids: Optional[Iterable[str]] = None,
29
+ name: Optional[str] = None,
30
+ name_includes: Optional[str] = None,
31
+ names_any_of: Optional[Iterable[str]] = [],
32
+ page_size: Optional[int] = None,
33
+ next_token: NextToken = None,
34
+ ) -> Response[CodonUsageTablesPaginatedList]:
35
+ response = list_codon_usage_tables.sync_detailed(
36
+ client=self.client,
37
+ ids=none_as_unset(optional_array_query_param(ids)),
38
+ name=none_as_unset(name),
39
+ name_includes=none_as_unset(name_includes),
40
+ namesany_of=none_as_unset(optional_array_query_param(names_any_of)),
41
+ next_token=none_as_unset(next_token),
42
+ page_size=none_as_unset(page_size),
43
+ sort=none_as_unset(sort),
44
+ )
45
+ return raise_for_status(response)
46
+
47
+ def list(
48
+ self,
49
+ sort: Optional[ListCodonUsageTablesSort] = None,
50
+ ids: Optional[Iterable[str]] = None,
51
+ name: Optional[str] = None,
52
+ name_includes: Optional[str] = None,
53
+ names_any_of: Optional[Iterable[str]] = None,
54
+ page_size: Optional[int] = None,
55
+ ) -> PageIterator[CodonUsageTable]:
56
+ """
57
+ List codon usage tables.
58
+
59
+ See https://benchling.com/api/reference#/Codon%20Usage%20Tables/listCodonUsageTables
60
+ """
61
+
62
+ def api_call(next_token: NextToken) -> Response[CodonUsageTablesPaginatedList]:
63
+ return self._list_page(
64
+ sort=sort,
65
+ ids=ids,
66
+ name=name,
67
+ name_includes=name_includes,
68
+ names_any_of=names_any_of,
69
+ page_size=page_size,
70
+ next_token=next_token,
71
+ )
72
+
73
+ return PageIterator(api_call, lambda result: result.codon_usage_tables)
@@ -15,6 +15,7 @@ from benchling_api_client.v2.stable.api.dna_sequences import (
15
15
  get_dna_sequence,
16
16
  list_dna_sequences,
17
17
  match_bases_dna_sequences,
18
+ optimize_codons,
18
19
  search_dna_sequences,
19
20
  unarchive_dna_sequences,
20
21
  update_dna_sequence,
@@ -54,6 +55,7 @@ from benchling_sdk.models import (
54
55
  EntityArchiveReason,
55
56
  ListDNASequencesSort,
56
57
  MatchBasesRequest,
58
+ OptimizeCodons,
57
59
  SearchBasesRequest,
58
60
  )
59
61
  from benchling_sdk.services.v2.base_service import BaseService
@@ -398,3 +400,13 @@ class DnaSequenceService(BaseService):
398
400
  client=self.client, json_body=find_matching_region
399
401
  )
400
402
  return model_from_detailed(response)
403
+
404
+ @api_method
405
+ def optimize_codons(self, optimize_request: OptimizeCodons) -> AsyncTaskLink:
406
+ """
407
+ Create codon-optimized DNA sequences.
408
+
409
+ See https://benchling.com/api/reference#/DNA%20Sequences/optimizeCodons
410
+ """
411
+ response = optimize_codons.sync_detailed(client=self.client, json_body=optimize_request)
412
+ return model_from_detailed(response)