-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathasync_network_policy.py
More file actions
80 lines (64 loc) · 2.38 KB
/
Copy pathasync_network_policy.py
File metadata and controls
80 lines (64 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""NetworkPolicy resource class for asynchronous operations."""
from __future__ import annotations
from typing_extensions import Unpack, override
from ._types import BaseRequestOptions, LongRequestOptions, SDKNetworkPolicyUpdateParams
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, **params: Unpack[SDKNetworkPolicyUpdateParams]) -> NetworkPolicyView:
"""Update the network policy.
:param params: See :typeddict:`~runloop_api_client.sdk._types.SDKNetworkPolicyUpdateParams` for available parameters
:return: Updated network policy view
:rtype: NetworkPolicyView
"""
return await self._client.network_policies.update(self._id, **params)
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,
)