-
Notifications
You must be signed in to change notification settings - Fork 22
feature: folder api methods #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds folder management capabilities to the Python SDK by implementing three new API methods: create_folder, list_folders, and get_folder_by_id.
Key Changes:
- Added new
V2Foldersresource class following the existing SDK patterns (similar toV3RawSecretsandKMSresources) - Implemented proper UTC datetime handling for the
lastSecretModifiedfilter parameter - Created comprehensive response models (
CreateFolderResponse,ListFoldersResponse,SingleFolderResponse) with proper type definitions - Integrated the folders resource into the main SDK client
Implementation Quality:
- Code follows established patterns from other SDK resources
- Response models properly handle nested objects (e.g.,
EnvironmentwithinSingleFolderResponseItem) - UTC datetime conversion ensures correct timezone handling for API requests
- All methods properly use the request handler with appropriate models
Confidence Score: 4/5
- This PR is safe to merge with minor style improvements recommended
- The implementation follows existing SDK patterns consistently and adds well-structured folder management functionality. Two minor style improvements were suggested: removing redundant query parameters and following Python naming conventions. No logical errors or security issues were found.
- infisical_sdk/resources/folders.py has minor style suggestions but no critical issues
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| infisical_sdk/resources/folders.py | 4/5 | New folders resource with create, list, and get methods. Minor style improvements suggested for parameter handling. |
| infisical_sdk/api_types.py | 5/5 | Added folder response models with proper type definitions and nested object handling. |
Sequence Diagram
sequenceDiagram
participant Client as InfisicalSDKClient
participant Folders as V2Folders
participant Requests as InfisicalRequests
participant API as Infisical API
Note over Client,API: Create Folder Flow
Client->>Folders: create_folder(name, env_slug, project_id, path)
Folders->>Folders: Build request body with projectId, environment, name, path, description
Folders->>Requests: post("/api/v2/folders", request_body)
Requests->>API: POST /api/v2/folders
API-->>Requests: CreateFolderResponse
Requests-->>Folders: APIResponse[CreateFolderResponse]
Folders-->>Client: CreateFolderResponseItem
Note over Client,API: List Folders Flow
Client->>Folders: list_folders(project_id, env_slug, path, lastSecretModified, recursive)
Folders->>Folders: Build params with projectId, environment, path, recursive
Folders->>Folders: Convert lastSecretModified to UTC Z format if provided
Folders->>Requests: get("/api/v2/folders", params)
Requests->>API: GET /api/v2/folders?projectId=...&environment=...
API-->>Requests: ListFoldersResponse
Requests-->>Folders: APIResponse[ListFoldersResponse]
Folders-->>Client: ListFoldersResponse
Note over Client,API: Get Folder by ID Flow
Client->>Folders: get_folder_by_id(id)
Folders->>Requests: get("/api/v2/folders/{id}", params)
Requests->>API: GET /api/v2/folders/{id}
API-->>Requests: SingleFolderResponse
Requests-->>Folders: APIResponse[SingleFolderResponse]
Folders-->>Client: SingleFolderResponseItem
4 files reviewed, 2 comments
| # Convert to UTC and format as RFC 3339 with 'Z' suffix | ||
| # The API expects UTC times in 'Z' format (e.g., 2023-11-07T05:31:56Z) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 3 new methods to interact with the folders API:
create_folderlist_foldersget_folder_by_idhttps://infisical.com/docs/api-reference/endpoints/folders/list