codemie-sdk-python 0.1.92__py3-none-any.whl → 0.1.258__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 codemie-sdk-python might be problematic. Click here for more details.

Files changed (33) hide show
  1. codemie_sdk/__init__.py +114 -2
  2. codemie_sdk/auth/credentials.py +5 -4
  3. codemie_sdk/client/client.py +66 -5
  4. codemie_sdk/models/assistant.py +111 -8
  5. codemie_sdk/models/conversation.py +169 -0
  6. codemie_sdk/models/datasource.py +80 -1
  7. codemie_sdk/models/file_operation.py +25 -0
  8. codemie_sdk/models/integration.py +3 -1
  9. codemie_sdk/models/vendor_assistant.py +187 -0
  10. codemie_sdk/models/vendor_guardrail.py +152 -0
  11. codemie_sdk/models/vendor_knowledgebase.py +151 -0
  12. codemie_sdk/models/vendor_workflow.py +145 -0
  13. codemie_sdk/models/workflow.py +1 -1
  14. codemie_sdk/models/workflow_execution_payload.py +21 -0
  15. codemie_sdk/models/workflow_state.py +6 -3
  16. codemie_sdk/models/workflow_thoughts.py +26 -0
  17. codemie_sdk/services/assistant.py +220 -1
  18. codemie_sdk/services/conversation.py +90 -0
  19. codemie_sdk/services/datasource.py +67 -0
  20. codemie_sdk/services/files.py +82 -0
  21. codemie_sdk/services/vendor_assistant.py +364 -0
  22. codemie_sdk/services/vendor_guardrail.py +375 -0
  23. codemie_sdk/services/vendor_knowledgebase.py +270 -0
  24. codemie_sdk/services/vendor_workflow.py +330 -0
  25. codemie_sdk/services/webhook.py +41 -0
  26. codemie_sdk/services/workflow.py +26 -2
  27. codemie_sdk/services/workflow_execution.py +54 -6
  28. codemie_sdk/utils/http.py +43 -16
  29. codemie_sdk_python-0.1.258.dist-info/METADATA +1404 -0
  30. codemie_sdk_python-0.1.258.dist-info/RECORD +45 -0
  31. codemie_sdk_python-0.1.92.dist-info/METADATA +0 -892
  32. codemie_sdk_python-0.1.92.dist-info/RECORD +0 -30
  33. {codemie_sdk_python-0.1.92.dist-info → codemie_sdk_python-0.1.258.dist-info}/WHEEL +0 -0
@@ -1,892 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: codemie-sdk-python
3
- Version: 0.1.92
4
- Summary: CodeMie SDK for Python
5
- Author: Vadym Vlasenko
6
- Author-email: vadym_vlasenko@epam.com
7
- Requires-Python: >=3.12,<4.0
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.12
10
- Requires-Dist: pydantic (>=2.11.1,<3.0.0)
11
- Requires-Dist: requests (>=2.31.0,<3.0.0)
12
- Description-Content-Type: text/markdown
13
-
14
- # CodeMie Python SDK
15
-
16
- Python SDK for CodeMie services. This SDK provides a comprehensive interface to interact with CodeMie services, including LLM (Large Language Models), assistants, workflows, and tools.
17
-
18
- ## Table of Contents
19
-
20
- - [Installation](#installation)
21
- - [Usage](#usage)
22
- - [Basic Usage](#basic-usage)
23
- - [Service Details](#service-details)
24
- - [LLM Service](#llm-service)
25
- - [Assistant Service](#assistant-service)
26
- - [Core Methods](#core-methods)
27
- - [Advanced Features](#advanced-features)
28
- - [Datasource Service](#datasource-service)
29
- - [Supported Datasource Types](#supported-datasource-types)
30
- - [Core Methods](#core-methods-1)
31
- - [Datasource Status](#datasource-status)
32
- - [Best Practices for Datasources](#best-practices-for-datasources)
33
- - [Integration Service](#integration-service)
34
- - [Integration Types](#integration-types)
35
- - [Core Methods](#core-methods-2)
36
- - [Best Practices for Integrations](#best-practices-for-integrations)
37
- - [Workflow Service](#workflow-service)
38
- - [Core Methods](#core-methods-3)
39
- - [Workflow Execution](#workflow-execution)
40
- - [Workflow Configuration](#workflow-configuration)
41
- - [Best Practices](#best-practices)
42
- - [Error Handling](#error-handling)
43
- - [Workflow Status Monitoring](#workflow-status-monitoring)
44
- - [Development](#development)
45
- - [Setup](#setup)
46
- - [Running Tests](#running-tests)
47
- - [Building Package](#building-package)
48
- - [Error Handling](#error-handling-1)
49
- - [Authentication](#authentication)
50
- - [Required Parameters](#required-parameters)
51
- - [Usage Examples](#usage-examples)
52
- - [Best Practices](#best-practices-1)
53
- - [Support](#support)
54
-
55
- ## Installation
56
-
57
- ```sh
58
- pip install codemie-sdk
59
- ```
60
- OR
61
- ```sh
62
- poetry install
63
- ```
64
-
65
- ### If you want to run only tests, go to ## Running tests section
66
-
67
- ## Usage
68
-
69
- ### Basic usage
70
-
71
- ```python
72
- from codemie_sdk import CodeMieClient
73
-
74
- # Initialize client with authentication parameters
75
- client = CodeMieClient(
76
- auth_server_url="https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth",
77
- auth_client_id="your-client-id",
78
- auth_client_secret="your-client-secret",
79
- auth_realm_name="your-realm",
80
- codemie_api_domain="https://codemie.lab.epam.com/code-assistant-api"
81
- )
82
- ```
83
-
84
- ## Service Details
85
-
86
- ### LLM Service
87
-
88
- The LLM service provides access to language models and embedding models:
89
-
90
- - **list()**: Retrieves a list of available LLM models
91
- ```python
92
- llm_models = client.llm.list(token=client.token)
93
- ```
94
-
95
- - **list_embeddings()**: Retrieves a list of available embedding models
96
- ```python
97
- embedding_models = client.llm.list_embeddings(token=client.token)
98
- ```
99
-
100
- Each LLM model contains the following information:
101
- - Model identifier
102
- - Model capabilities
103
- - Configuration parameters
104
-
105
- Example usage:
106
- ```python
107
- # List available LLM models
108
- llm_models = client.llm.list(token=client.token)
109
-
110
- # List available embedding models
111
- embedding_models = client.llm.list_embeddings(token=client.token)
112
- ```
113
-
114
- ### Assistant Service
115
-
116
- The Assistant service allows you to manage and interact with CodeMie assistants:
117
-
118
- #### Core Methods
119
-
120
- 1. **List Assistants**
121
- ```python
122
- assistants = client.assistant.list(
123
- minimal_response=True, # Return minimal assistant info
124
- scope="visible_to_user", # or "created_by_user"
125
- page=0,
126
- per_page=12,
127
- filters={"key": "value"} # Optional filters
128
- )
129
- ```
130
-
131
- 2. **Get Assistant Details**
132
- ```python
133
- # By ID
134
- assistant = client.assistant.get("assistant-id")
135
-
136
- # By Slug
137
- assistant = client.assistant.get_by_slug("assistant-slug")
138
- ```
139
-
140
- 3. **Create Assistant**
141
- ```python
142
- from codemie_sdk.models.assistant import AssistantCreateRequest
143
-
144
- request = AssistantCreateRequest(
145
- name="My Assistant",
146
- description="Assistant description",
147
- instructions="Assistant instructions",
148
- tools=["tool1", "tool2"],
149
- # Additional parameters as needed
150
- )
151
- new_assistant = client.assistant.create(request)
152
- ```
153
-
154
- 4. **Update Assistant**
155
- ```python
156
- from codemie_sdk.models.assistant import AssistantUpdateRequest
157
-
158
- request = AssistantUpdateRequest(
159
- name="Updated Name",
160
- description="Updated description",
161
- # Other fields to update
162
- )
163
- updated_assistant = client.assistant.update("assistant-id", request)
164
- ```
165
-
166
- 5. **Delete Assistant**
167
- ```python
168
- result = client.assistant.delete("assistant-id")
169
- ```
170
-
171
- #### Advanced Features
172
-
173
- 6. **Chat with Assistant**
174
- ```python
175
- from codemie_sdk.models.assistant import AssistantChatRequest
176
-
177
- chat_request = AssistantChatRequest(
178
- text="Your message here",
179
- stream=False, # Set to True for streaming response
180
- # Additional parameters
181
- )
182
- response = client.assistant.chat("assistant-id", chat_request)
183
- ```
184
-
185
- 7. **Utilize structured outputs with Assistant**
186
- ```python
187
- from pydantic import BaseModel
188
-
189
- class OutputSchema(BaseModel):
190
- requirements: list[str]
191
-
192
- chat_request = AssistantChatRequest(
193
- text="Your message here",
194
- stream=False,
195
- output_schema=OutputSchema
196
- # Additional parameters
197
- )
198
-
199
- response = client.assistants.chat("id", chat_request)
200
- # response.generated is a Pydantic object
201
- ```
202
- Or using JSON schema in dict format
203
- ```python
204
- output_schema = {
205
- "properties": {
206
- "requirements": {
207
- "items": {"type": "string"},
208
- "title": "Requirements",
209
- "type": "array",
210
- }
211
- },
212
- "required": ["requirements"],
213
- "title": "OutputSchema",
214
- "type": "object",
215
- }
216
-
217
- chat_request = AssistantChatRequest(
218
- text="Your message here",
219
- stream=False,
220
- output_schema=output_schema
221
- # Additional parameters
222
- )
223
-
224
- response = client.assistants.chat("id", chat_request)
225
- # response.generated is a dict corresponded with JSON schema
226
- ```
227
-
228
- 8. **Work with Prebuilt Assistants**
229
- ```python
230
- # List prebuilt assistants
231
- prebuilt = client.assistant.get_prebuilt()
232
-
233
- # Get specific prebuilt assistant
234
- prebuilt_assistant = client.assistant.get_prebuilt_by_slug("assistant-slug")
235
- ```
236
-
237
- 9. **Get Available Tools**
238
- ```python
239
- tools = client.assistant.get_tools()
240
- ```
241
-
242
- ### Datasource Service
243
-
244
- The Datasource service enables managing various types of data sources in CodeMie, including code repositories, Confluence spaces, Jira projects, files, and Google documents.
245
-
246
- #### Supported Datasource Types
247
-
248
- - `CODE`: Code repository datasources
249
- - `CONFLUENCE`: Confluence knowledge base
250
- - `JIRA`: Jira knowledge base
251
- - `FILE`: File-based knowledge base
252
- - `GOOGLE`: Google documents
253
-
254
- #### Core Methods
255
-
256
- 1. **Create Datasource**
257
- ```python
258
- from codemie_sdk.models.datasource import (
259
- CodeDataSourceRequest,
260
- ConfluenceDataSourceRequest,
261
- JiraDataSourceRequest,
262
- GoogleDataSourceRequest
263
- )
264
-
265
- # Create Code Datasource
266
- code_request = CodeDataSourceRequest(
267
- name="my_repo", # lowercase letters and underscores only
268
- project_name="my_project",
269
- description="My code repository",
270
- link="https://github.com/user/repo",
271
- branch="main",
272
- index_type="code", # or "summary" or "chunk-summary"
273
- files_filter="*.py", # optional
274
- embeddings_model="model_name",
275
- summarization_model="gpt-4", # optional
276
- docs_generation=False # optional
277
- )
278
- result = client.datasource.create(code_request)
279
-
280
- # Create Confluence Datasource
281
- confluence_request = ConfluenceDataSourceRequest(
282
- name="confluence_kb",
283
- project_name="my_project",
284
- description="Confluence space",
285
- cql="space = 'MYSPACE'",
286
- include_restricted_content=False,
287
- include_archived_content=False,
288
- include_attachments=True,
289
- include_comments=True
290
- )
291
- result = client.datasource.create(confluence_request)
292
-
293
- # Create Jira Datasource
294
- jira_request = JiraDataSourceRequest(
295
- name="jira_kb",
296
- project_name="my_project",
297
- description="Jira project",
298
- jql="project = 'MYPROJECT'"
299
- )
300
- result = client.datasource.create(jira_request)
301
-
302
- # Create Google Doc Datasource
303
- google_request = GoogleDataSourceRequest(
304
- name="google_doc",
305
- project_name="my_project",
306
- description="Google document",
307
- google_doc="document_url"
308
- )
309
- result = client.datasource.create(google_request)
310
- ```
311
-
312
- 2. **Update Datasource**
313
- ```python
314
- from codemie_sdk.models.datasource import UpdateCodeDataSourceRequest
315
-
316
- # Update Code Datasource
317
- update_request = UpdateCodeDataSourceRequest(
318
- name="my_repo",
319
- project_name="my_project",
320
- description="Updated description",
321
- branch="develop",
322
- full_reindex=True, # optional reindex parameters
323
- skip_reindex=False,
324
- resume_indexing=False
325
- )
326
- result = client.datasource.update("datasource_id", update_request)
327
- ```
328
-
329
- 3. **List Datasources**
330
- ```python
331
- # List all datasources with filtering and pagination
332
- datasources = client.datasource.list(
333
- page=0,
334
- per_page=10,
335
- sort_key="update_date", # or "date"
336
- sort_order="desc", # or "asc"
337
- datasource_types=["CODE", "CONFLUENCE"], # optional filter by type
338
- projects=["project1", "project2"], # optional filter by projects
339
- owner="John Doe", # optional filter by owner
340
- status="COMPLETED" # optional filter by status
341
- )
342
- ```
343
-
344
- 4. **Get Datasource Details**
345
- ```python
346
- # Get single datasource by ID
347
- datasource = client.datasource.get("datasource_id")
348
- ```
349
-
350
- 5. **Delete Datasource**
351
- ```python
352
- # Delete datasource by ID
353
- result = client.datasource.delete("datasource_id")
354
- ```
355
-
356
- #### Datasource Status
357
-
358
- Datasources can have the following statuses:
359
- - `COMPLETED`: Indexing completed successfully
360
- - `FAILED`: Indexing failed
361
- - `FETCHING`: Fetching data from source
362
- - `IN_PROGRESS`: Processing/indexing in progress
363
-
364
- #### Best Practices for Datasources
365
-
366
- 1. **Naming Convention**:
367
- - Use lowercase letters and underscores for datasource names
368
- - Keep names descriptive but concise
369
-
370
- 2. **Performance Optimization**:
371
- - Use appropriate filters when listing datasources
372
- - Consider pagination for large result sets
373
- - Choose appropriate reindex options based on your needs
374
-
375
- 3. **Error Handling**:
376
- - Always check datasource status after creation/update
377
- - Handle potential failures gracefully
378
- - Monitor processing information for issues
379
-
380
- 4. **Security**:
381
- - Be careful with sensitive data in filters and queries
382
- - Use proper access controls when sharing datasources
383
- - Regularly review and clean up unused datasources
384
-
385
- ### Integration Service
386
-
387
- The Integration service manages both user and project-level integrations in CodeMie, allowing you to configure and manage various integration settings.
388
-
389
- #### Integration Types
390
-
391
- - `USER`: User-level integrations
392
- - `PROJECT`: Project-level integrations
393
-
394
- #### Core Methods
395
-
396
- 1. **List Integrations**
397
- ```python
398
- from codemie_sdk.models.integration import IntegrationType
399
-
400
- # List user integrations with pagination
401
- user_integrations = client.integration.list(
402
- setting_type=IntegrationType.USER,
403
- page=0,
404
- per_page=10,
405
- filters={"some_filter": "value"} # optional
406
- )
407
-
408
- # List project integrations
409
- project_integrations = client.integration.list(
410
- setting_type=IntegrationType.PROJECT,
411
- per_page=100
412
- )
413
- ```
414
-
415
- 2. **Get Integration**
416
- ```python
417
- # Get integration by ID
418
- integration = client.integration.get(
419
- integration_id="integration_id",
420
- setting_type=IntegrationType.USER
421
- )
422
-
423
- # Get integration by alias
424
- integration = client.integration.get_by_alias(
425
- alias="integration_alias",
426
- setting_type=IntegrationType.PROJECT
427
- )
428
- ```
429
-
430
- 3. **Create Integration**
431
- ```python
432
- from codemie_sdk.models.integration import Integration
433
-
434
- # Create new integration
435
- new_integration = Integration(
436
- setting_type=IntegrationType.USER,
437
- alias="my_integration",
438
- # Add other required fields based on integration type
439
- )
440
- result = client.integration.create(new_integration)
441
- ```
442
-
443
- 4. **Update Integration**
444
- ```python
445
- # Update existing integration
446
- updated_integration = Integration(
447
- setting_type=IntegrationType.USER,
448
- alias="updated_alias",
449
- # Add other fields to update
450
- )
451
- result = client.integration.update("integration_id", updated_integration)
452
- ```
453
-
454
- 5. **Delete Integration**
455
- ```python
456
- # Delete integration
457
- result = client.integration.delete(
458
- setting_id="integration_id",
459
- setting_type=IntegrationType.USER
460
- )
461
- ```
462
-
463
- #### Best Practices for Integrations
464
-
465
- 1. **Error Handling**:
466
- - Handle `NotFoundError` when getting integrations by ID or alias
467
- - Validate integration settings before creation/update
468
- - Use appropriate setting type (USER/PROJECT) based on context
469
-
470
- 2. **Performance**:
471
- - Use pagination for listing integrations
472
- - Cache frequently accessed integrations when appropriate
473
- - Use filters to reduce result set size
474
-
475
- 3. **Security**:
476
- - Keep integration credentials secure
477
- - Regularly review and update integration settings
478
- - Use project-level integrations for team-wide settings
479
- - Use user-level integrations for personal settings
480
-
481
- ### Workflow Service
482
-
483
- The Workflow service enables you to create, manage, and execute workflows in CodeMie. Workflows allow you to automate complex processes and integrate various CodeMie services.
484
-
485
- #### Core Methods
486
-
487
- 1. **Create Workflow**
488
- ```python
489
- from codemie_sdk.models.workflow import WorkflowCreateRequest
490
-
491
- # Create new workflow
492
- workflow_request = WorkflowCreateRequest(
493
- name="My Workflow",
494
- description="Workflow description",
495
- project="project-id",
496
- yaml_config="your-yaml-configuration",
497
- mode="SEQUENTIAL", # Optional, defaults to SEQUENTIAL
498
- shared=False, # Optional, defaults to False
499
- icon_url="https://example.com/icon.png" # Optional
500
- )
501
- result = client.workflow.create_workflow(workflow_request)
502
- ```
503
-
504
- 2. **Update Workflow**
505
- ```python
506
- from codemie_sdk.models.workflow import WorkflowUpdateRequest
507
-
508
- # Update existing workflow
509
- update_request = WorkflowUpdateRequest(
510
- name="Updated Workflow",
511
- description="Updated description",
512
- yaml_config="updated-yaml-config",
513
- mode="PARALLEL",
514
- shared=True
515
- )
516
- result = client.workflow.update("workflow-id", update_request)
517
- ```
518
-
519
- 3. **List Workflows**
520
- ```python
521
- # List workflows with pagination and filtering
522
- workflows = client.workflow.list(
523
- page=0,
524
- per_page=10,
525
- projects=["project1", "project2"] # Optional project filter
526
- )
527
- ```
528
-
529
- 4. **Get Workflow Details**
530
- ```python
531
- # Get workflow by ID
532
- workflow = client.workflow.get("workflow-id")
533
-
534
- # Get prebuilt workflows
535
- prebuilt_workflows = client.workflow.get_prebuilt()
536
- ```
537
-
538
- 5. **Delete Workflow**
539
- ```python
540
- result = client.workflow.delete("workflow-id")
541
- ```
542
-
543
- #### Workflow Execution
544
-
545
- The SDK provides comprehensive workflow execution management through the WorkflowExecutionService:
546
-
547
- 1. **Run Workflow**
548
- ```python
549
- # Simple workflow execution
550
- execution = client.workflow.run("workflow-id", user_input="optional input")
551
-
552
- # Get execution service for advanced operations
553
- execution_service = client.workflow.executions("workflow-id")
554
- ```
555
-
556
- 2. **Manage Executions**
557
- ```python
558
- # List workflow executions
559
- executions = execution_service.list(
560
- page=0,
561
- per_page=10
562
- )
563
-
564
- # Get execution details
565
- execution = execution_service.get("execution-id")
566
-
567
- # Abort running execution
568
- result = execution_service.abort("execution-id")
569
-
570
- # Resume interrupted execution
571
- result = execution_service.resume("execution-id")
572
-
573
- # Delete all executions
574
- result = execution_service.delete_all()
575
- ```
576
-
577
- 3. **Work with Execution States**
578
- ```python
579
- # Get execution states
580
- states = execution_service.states(execution_id).list()
581
-
582
- # Get state output
583
- state_output = execution_service.states(execution_id).get_output(state_id)
584
-
585
- # Example of monitoring workflow with state verification
586
- def verify_workflow_execution(execution_service, execution_id):
587
- execution = execution_service.get(execution_id)
588
-
589
- if execution.status == ExecutionStatus.SUCCEEDED:
590
- # Get and verify states
591
- states = execution_service.states(execution_id).list()
592
-
593
- # States are ordered by completion date
594
- if len(states) >= 2:
595
- first_state = states[0]
596
- second_state = states[1]
597
- assert first_state.completed_at < second_state.completed_at
598
-
599
- # Get state outputs
600
- for state in states:
601
- output = execution_service.states(execution_id).get_output(state.id)
602
- print(f"State {state.id} output: {output.output}")
603
-
604
- elif execution.status == ExecutionStatus.FAILED:
605
- print(f"Workflow failed: {execution.error_message}")
606
- ```
607
-
608
- #### Workflow Configuration
609
-
610
- Workflows support various configuration options:
611
-
612
- 1. **Modes**:
613
- - `SEQUENTIAL`: Tasks execute in sequence
614
- - `PARALLEL`: Tasks can execute simultaneously
615
-
616
- 2. **YAML Configuration**:
617
- ```yaml
618
- name: Example Workflow
619
- description: Workflow description
620
- tasks:
621
- - name: task1
622
- type: llm
623
- config:
624
- prompt: "Your prompt here"
625
- model: "gpt-4"
626
-
627
- - name: task2
628
- type: tool
629
- config:
630
- tool_name: "your-tool"
631
- parameters:
632
- param1: "value1"
633
- ```
634
-
635
- #### Best Practices
636
-
637
- 1. **Workflow Design**:
638
- - Keep workflows modular and focused
639
- - Use clear, descriptive names for workflows and tasks
640
- - Document workflow purpose and requirements
641
- - Test workflows thoroughly before deployment
642
-
643
- 2. **Execution Management**:
644
- - Monitor long-running workflows
645
- - Implement proper error handling
646
- - Use pagination for listing executions
647
- - Clean up completed executions regularly
648
-
649
- 3. **Performance Optimization**:
650
- - Choose appropriate workflow mode (SEQUENTIAL/PARALLEL)
651
- - Manage resource usage in parallel workflows
652
- - Consider task dependencies and ordering
653
- - Use efficient task configurations
654
-
655
- 4. **Security**:
656
- - Control workflow sharing carefully
657
- - Validate user inputs
658
- - Manage sensitive data appropriately
659
- - Regular audit of workflow access
660
-
661
- 5. **Maintenance**:
662
- - Regular review of workflow configurations
663
- - Update workflows when dependencies change
664
- - Monitor workflow performance
665
- - Archive or remove unused workflows
666
-
667
- #### Error Handling
668
-
669
- Implement proper error handling for workflow operations:
670
-
671
- ```python
672
- try:
673
- workflow = client.workflow.get("workflow-id")
674
- except ApiError as e:
675
- if e.status_code == 404:
676
- print("Workflow not found")
677
- else:
678
- print(f"API error: {e}")
679
- except Exception as e:
680
- print(f"Unexpected error: {e}")
681
- ```
682
-
683
- #### Workflow Status Monitoring
684
-
685
- Monitor workflow execution status:
686
-
687
- ```python
688
- def monitor_execution(execution_service, execution_id):
689
- while True:
690
- execution = execution_service.get(execution_id)
691
- status = execution.status
692
-
693
- if status == "COMPLETED":
694
- print("Workflow completed successfully")
695
- break
696
- elif status == "FAILED":
697
- print(f"Workflow failed: {execution.error}")
698
- break
699
- elif status == "ABORTED":
700
- print("Workflow was aborted")
701
- break
702
-
703
- time.sleep(5) # Poll every 5 seconds
704
- ```
705
-
706
- ## Error Handling
707
-
708
- The SDK implements comprehensive error handling. All API calls may raise exceptions for:
709
- - Authentication failures
710
- - Network errors
711
- - Invalid parameters
712
- - Server-side errors
713
-
714
- It's recommended to implement try-catch blocks around SDK operations to handle potential exceptions gracefully.
715
-
716
- ## Authentication
717
-
718
- The SDK supports two authentication methods through Keycloak:
719
-
720
- 1. Username/Password Authentication
721
- 2. Client Credentials Authentication
722
-
723
- ### Required Parameters
724
-
725
- You must provide either:
726
-
727
- - Username/Password credentials:
728
- ```python
729
- {
730
- "username": "your-username",
731
- "password": "your-password",
732
- "auth_client_id": "client-id", # Optional, defaults to "codemie-sdk"
733
- "auth_realm_name": "realm-name",
734
- "auth_server_url": "keycloak-url",
735
- "verify_ssl": True # Optional, defaults to True
736
- }
737
- ```
738
-
739
- OR
740
-
741
- - Client Credentials:
742
- ```python
743
- {
744
- "auth_client_id": "your-client-id",
745
- "auth_client_secret": "your-client-secret",
746
- "auth_realm_name": "realm-name",
747
- "auth_server_url": "keycloak-url",
748
- "verify_ssl": True # Optional, defaults to True
749
- }
750
- ```
751
-
752
- ### Usage Examples
753
-
754
- 1. Username/Password Authentication:
755
- ```python
756
- from codemie_sdk import CodeMieClient
757
-
758
- client = CodeMieClient(
759
- codemie_api_domain="https://api.domain.com",
760
- username="your-username",
761
- password="your-password",
762
- auth_client_id="your-client-id", # Optional
763
- auth_realm_name="your-realm",
764
- auth_server_url="https://keycloak.domain.com/auth",
765
- verify_ssl=True # Optional
766
- )
767
- ```
768
-
769
- 2. Client Credentials Authentication:
770
- ```python
771
- from codemie_sdk.auth import KeycloakCredentials
772
-
773
- credentials = KeycloakCredentials(
774
- server_url="https://keycloak.domain.com/auth",
775
- realm_name="your-realm",
776
- client_id="your-client-id",
777
- client_secret="your-client-secret",
778
- verify_ssl=True # Optional
779
- )
780
-
781
- client = CodeMieClient(
782
- codemie_api_domain="https://api.domain.com",
783
- credentials=credentials
784
- )
785
- ```
786
-
787
- ## Support
788
- For providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com
789
-
790
- ## Running tests
791
-
792
- For running tests on custom environment you should create .env file in the ./tests directory,
793
- ask QA team: anton_yeromin@epam.com to provide all needed testing credentials. Under this directory there are stubs
794
- for .env files for running tests on local and preview environments.
795
-
796
- Configuration example:
797
-
798
- ``` properties
799
-
800
- AUTH_SERVER_URL=https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth
801
- AUTH_CLIENT_ID=codemie-preview
802
- AUTH_CLIENT_SECRET=<auth_clienbt_secret>
803
- AUTH_REALM_NAME=codemie-prod
804
- CODEMIE_API_DOMAIN=http://localhost:8080
805
- VERIFY_SSL=False
806
-
807
- NATS_URL=nats://localhost:4222
808
-
809
- ENV=local
810
- CLEANUP_DATA=True
811
-
812
- AUTH_USERNAME=<username>
813
- AUTH_PASSWORD=<password>
814
- TEST_USER_FULL_NAME=<user_full_name>
815
-
816
- PROJECT_NAME=codemie
817
- GIT_ENV=gitlab
818
-
819
- DEFAULT_TIMEOUT=60
820
-
821
- GITLAB_URL=https://gitbud.epam.com
822
- GITLAB_TOKEN=<gitlab_token>
823
- GITLAB_PROJECT=https://gitbud.epam.com/epm-cdme/autotests/codemie-test-project
824
- GITLAB_PROJECT_ID=17889
825
-
826
- GITHUB_URL=https://github.com
827
- GITHUB_TOKEN=<github_token>
828
- GITHUB_PROJECT=https://github.com/wild47/final_task
829
-
830
- JIRA_URL=https://jiraeu.epam.com
831
- JIRA_TOKEN=<jira_token>
832
- JQL="project = 'EPMCDME' and issuetype = 'Epic' and status = 'Closed'"
833
-
834
- CONFLUENCE_URL=https://kb.epam.com
835
- CONFLUENCE_TOKEN=<confluence_token>
836
- CQL="space = EPMCDME and type = page and title = 'AQA Backlog Estimation'"
837
-
838
- AWS_ACCESS_KEY=<aws_access_token>
839
- AWS_SECRET_KEY=<aws_secret_key>
840
-
841
- RP_API_KEY=<report_portal_key_optional>
842
- ```
843
-
844
- Run all tests
845
-
846
- ```shell
847
- pytest -n auto --reruns 1
848
- ```
849
-
850
- Run e2e/regression tests
851
-
852
- ```shell
853
- pytest -n auto -m "e2e or regression" --reruns 1
854
- ```
855
-
856
- Run UI tests
857
-
858
- First you have to install playwright browsers:
859
-
860
- ```shell
861
- playwright install
862
- ```
863
- and then
864
-
865
- ```shell
866
- pytest -n 4 -m ui --reruns 1
867
- ```
868
-
869
- All Playwright documentation can be found by the following link: https://playwright.dev/python/docs/intro
870
-
871
- Run tests for e2e tests for specific integration/tool.
872
- Available marks:
873
- - jira_kb
874
- - confluence_kb
875
- - code_kb
876
- - gitlab
877
- - github
878
- - git
879
-
880
- ```shell
881
- pytest -n auto -m "jira_kb or github" --reruns 1
882
- ```
883
-
884
- In case you want to send test results in **ReportPortal** you should specify RP_API_KEY in .env and run tests like this:
885
-
886
- ```shell
887
- pytest -n auto -m "e2e or regression" --reruns 1 --reportportal
888
- ```
889
-
890
- ReportPortal link is available by the following URL: https://report-portal.core.kuberocketci.io/ui/#epm-cdme/launches/all
891
-
892
- If you do not have access to the project ask Anton Yeromin (anton_yeromin@epam.com) to add you.