-
Notifications
You must be signed in to change notification settings - Fork 2
feat(network-policy): add network policies #720
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a74dcd4
cp dines
dines-rl 284aa48
cp dines
dines-rl dc3a244
cp dines
dines-rl 46d7c50
fix: address PR review feedback (conventions, KISS, duplication)
claude 90e389d
fix: format async_benchmark.py to pass ruff checks
claude e618e48
fix: address PR review feedback - use SDKNetworkPolicyUpdateParams an…
claude c5ca54a
cp dines
dines-rl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| """NetworkPolicy resource class for asynchronous operations.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Optional | ||
| from typing_extensions import Unpack, override | ||
|
|
||
| from ._types import BaseRequestOptions, LongRequestOptions | ||
| from .._types import SequenceNotStr | ||
| from .._client import AsyncRunloop | ||
| from ..types.network_policy_view import NetworkPolicyView | ||
|
|
||
|
|
||
| class AsyncNetworkPolicy: | ||
| """Asynchronous wrapper around a network policy resource.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| client: AsyncRunloop, | ||
| network_policy_id: str, | ||
| ) -> None: | ||
| """Initialize the wrapper. | ||
|
|
||
| :param client: Generated AsyncRunloop client | ||
| :type client: AsyncRunloop | ||
| :param network_policy_id: NetworkPolicy ID returned by the API | ||
| :type network_policy_id: str | ||
| """ | ||
| self._client = client | ||
| self._id = network_policy_id | ||
|
|
||
| @override | ||
| def __repr__(self) -> str: | ||
| return f"<AsyncNetworkPolicy id={self._id!r}>" | ||
|
|
||
| @property | ||
| def id(self) -> str: | ||
| """Return the network policy ID. | ||
|
|
||
| :return: Unique network policy ID | ||
| :rtype: str | ||
| """ | ||
| return self._id | ||
|
|
||
| async def get_info( | ||
| self, | ||
| **options: Unpack[BaseRequestOptions], | ||
| ) -> NetworkPolicyView: | ||
| """Retrieve the latest network policy details. | ||
|
|
||
| :param options: Optional request configuration | ||
| :return: API response describing the network policy | ||
| :rtype: NetworkPolicyView | ||
| """ | ||
| return await self._client.network_policies.retrieve( | ||
| self._id, | ||
| **options, | ||
| ) | ||
|
|
||
| async def update( | ||
| self, | ||
| *, | ||
| allow_all: Optional[bool] = None, | ||
| allow_devbox_to_devbox: Optional[bool] = None, | ||
| allowed_hostnames: Optional[SequenceNotStr[str]] = None, | ||
| description: Optional[str] = None, | ||
| name: Optional[str] = None, | ||
| **options: Unpack[LongRequestOptions], | ||
| ) -> NetworkPolicyView: | ||
| """Update the network policy. | ||
|
|
||
| :param allow_all: If true, all egress traffic is allowed (ALLOW_ALL policy) | ||
| :type allow_all: Optional[bool] | ||
| :param allow_devbox_to_devbox: If true, allows traffic between devboxes via tunnels | ||
| :type allow_devbox_to_devbox: Optional[bool] | ||
| :param allowed_hostnames: DNS-based allow list with wildcard support | ||
| :type allowed_hostnames: Optional[SequenceNotStr[str]] | ||
| :param description: Updated description for the NetworkPolicy | ||
| :type description: Optional[str] | ||
| :param name: Updated human-readable name for the NetworkPolicy | ||
| :type name: Optional[str] | ||
| :param options: Optional long-running request configuration | ||
| :return: Updated network policy view | ||
| :rtype: NetworkPolicyView | ||
| """ | ||
| return await self._client.network_policies.update( | ||
| self._id, | ||
| allow_all=allow_all, | ||
| allow_devbox_to_devbox=allow_devbox_to_devbox, | ||
| allowed_hostnames=allowed_hostnames, | ||
| description=description, | ||
| name=name, | ||
| **options, | ||
| ) | ||
|
|
||
| async def delete( | ||
| self, | ||
| **options: Unpack[LongRequestOptions], | ||
| ) -> NetworkPolicyView: | ||
| """Delete the network policy. | ||
|
|
||
| :param options: Optional long-running request configuration | ||
| :return: API response acknowledging deletion | ||
| :rtype: NetworkPolicyView | ||
| """ | ||
| return await self._client.network_policies.delete( | ||
| self._id, | ||
| **options, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.