Skip to content

Conversation

@victorvhs017
Copy link
Contributor

Added 3 new methods to interact with the folders API:

  • create_folder
  • list_folders
  • get_folder_by_id

https://infisical.com/docs/api-reference/endpoints/folders/list

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 V2Folders resource class following the existing SDK patterns (similar to V3RawSecrets and KMS resources)
  • Implemented proper UTC datetime handling for the lastSecretModified filter 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., Environment within SingleFolderResponseItem)
  • 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
Loading

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +52 to +53
# 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@victorvhs017 victorvhs017 requested review from carlosmonastyrski and varonix0 and removed request for varonix0 October 30, 2025 22:23
@victorvhs017 victorvhs017 merged commit d11257a into main Oct 31, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants