Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Jul 29, 2025

Can be merged after opsmill/infrahub#6907

Summary by CodeRabbit

  • New Features

    • Added new resource types for weighted pools and internal IP ranges/prefixes.
    • Introduced new attributes such as allocation weight, shared key, pool type, and last address to various resources.
  • Improvements

    • Replaced several boolean options with dropdowns for more expressive configuration in group actions, trigger rules, and relationship matches.
    • Enhanced proposed change resources with draft status and rejection tracking.

@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

Walkthrough

This change expands and refines the protocol definitions in infrahub_sdk/protocols.py. It introduces new resource classes, adds and modifies attributes on existing classes (including replacing booleans with dropdowns and adding enums), and incorporates new relationship and state-tracking fields to enhance the data model's expressiveness and granularity.

Changes

Cohort / File(s) Change Summary
Weighted Pool Resource Classes
infrahub_sdk/protocols.py
Added CoreWeightedPoolResource and CoreWeightedPoolResourceSync classes with optional integer attribute allocation_weight.
Custom Webhook Enhancements
infrahub_sdk/protocols.py
Added optional string attribute shared_key to CoreCustomWebhook and CoreCustomWebhookSync.
Group Action & Trigger Rule Attribute Refinement
infrahub_sdk/protocols.py
Changed add_members (boolean) to member_action (dropdown) in CoreGroupAction and CoreGroupActionSync. Changed members_added (boolean) to member_update (dropdown) in CoreGroupTriggerRule and its sync version.
Node Trigger Relationship Match Update
infrahub_sdk/protocols.py
Changed added (boolean) to modification_type (dropdown) in CoreNodeTriggerRelationshipMatch and its sync version.
Number Pool Type Extension
infrahub_sdk/protocols.py
Added pool_type enum attribute to CoreNumberPool and CoreNumberPoolSync.
Proposed Change State and Relationship
infrahub_sdk/protocols.py
Added boolean is_draft and relationship manager rejected_by attributes to CoreProposedChange and its sync version.
Internal IP Prefix/Range Resources
infrahub_sdk/protocols.py
Added InternalIPPrefixAvailable (and sync version) extending BuiltinIPPrefix (no new attributes), and InternalIPRangeAvailable (and sync version) extending BuiltinIPAddress with last_address attribute.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ProtocolClass
    participant Resource

    Client->>ProtocolClass: Create/Modify Resource
    ProtocolClass->>Resource: Set attributes (including new/changed fields)
    Resource-->>ProtocolClass: Confirm attribute values
    ProtocolClass-->>Client: Return updated resource state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f82744b and 522a49a.

📒 Files selected for processing (1)
  • infrahub_sdk/protocols.py (14 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (13)
infrahub_sdk/protocols.py (13)

236-238: LGTM! New weighted pool resource class follows established patterns.

The new CoreWeightedPoolResource class with optional allocation weight is well-structured and follows the existing inheritance patterns.


328-328: LGTM! Shared key addition enhances webhook security.

Adding the optional shared_key attribute to CoreCustomWebhook is appropriate for webhook authentication and security.


413-413: LGTM! Dropdown provides better granularity than boolean.

Replacing the boolean add_members with member_action dropdown allows for more expressive member operations beyond just add/don't add.


418-418: LGTM! Consistent with improved member action expressiveness.

The member_update dropdown replacement follows the same improved pattern as other member action changes, providing better granularity.


450-450: LGTM! Modification type dropdown improves relationship change tracking.

Replacing the boolean added with modification_type dropdown allows tracking various relationship modifications beyond just additions.


465-465: LGTM! Pool type enum adds useful categorization.

The pool_type enum addition provides structured categorization for different number pool types.


490-490: LGTM! Enhanced change management workflow.

The is_draft boolean and rejected_by relationship manager additions improve proposed change state tracking and workflow management.

Also applies to: 492-492


566-568: LGTM! Marker class for IP prefix availability tracking.

The InternalIPPrefixAvailable class serves as a type-safe marker extending BuiltinIPPrefix for internal availability tracking.


570-572: LGTM! IP range class with proper address boundaries.

The InternalIPRangeAvailable class appropriately extends BuiltinIPAddress and adds last_address to define IP range boundaries.


785-787: LGTM! Sync version maintains consistency.

The CoreWeightedPoolResourceSync class correctly mirrors its async counterpart with identical structure.


877-877: LGTM! Sync version maintains attribute consistency.

The shared_key addition to CoreCustomWebhookSync maintains consistency with the async version.


962-962: LGTM! Sync versions maintain proper consistency.

All sync class modifications correctly mirror their async counterparts, maintaining the essential consistency between async and sync protocol definitions.

Also applies to: 967-967, 999-999, 1014-1014, 1039-1039, 1041-1041


1115-1117: LGTM! Internal sync classes maintain consistency.

The InternalIPPrefixAvailableSync and InternalIPRangeAvailableSync classes properly mirror their async counterparts with consistent structure.

Also applies to: 1119-1121

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pog-protocols

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 522a49a
Status: ✅  Deploy successful!
Preview URL: https://7a49946f.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-protocols.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #485      +/-   ##
===========================================
+ Coverage    75.65%   75.70%   +0.05%     
===========================================
  Files          100      100              
  Lines         8810     8830      +20     
  Branches      1725     1725              
===========================================
+ Hits          6665     6685      +20     
  Misses        1667     1667              
  Partials       478      478              
Flag Coverage Δ
integration-tests 34.94% <100.00%> (+0.14%) ⬆️
python-3.10 48.10% <100.00%> (+0.11%) ⬆️
python-3.11 48.13% <100.00%> (+0.11%) ⬆️
python-3.12 48.08% <100.00%> (+0.11%) ⬆️
python-3.13 48.10% <100.00%> (+0.11%) ⬆️
python-3.9 46.77% <100.00%> (+0.12%) ⬆️
python-filler-3.12 25.11% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/protocols.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad ogenstad requested a review from a team July 29, 2025 09:42
@ogenstad ogenstad closed this Aug 4, 2025
@ogenstad ogenstad deleted the pog-protocols branch August 4, 2025 07:47
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.

2 participants