ACL¶
Named ACLs. Accessed via client.acl.
Service¶
AclService ¶
Entry point for NIOS acl resources. Each resource is lazily constructed.
Initialise AclService with an authenticated HTTP client.
Source code in src/ibx_nios_sdk/acl/_service.py
Resources¶
NamedaclResource ¶
Bases: WapiResource[Namedacl]
Manage NIOS named ACL (Access Control List) objects.
Initialize the resource with an HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
HttpClient
|
The :class: |
required |
Source code in src/ibx_nios_sdk/_resource.py
list_page
async
¶
list_page(*, page_id: str | None = None, max_results: int = 1000, return_fields: list[str] | None = None, return_fields_plus: list[str] | None = None, **filters: Any) -> tuple[list[TModel], str | None]
Fetch a single page of WAPI results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str | None
|
Continuation token from a previous response. Pass |
None
|
max_results
|
int
|
Maximum number of records per page (WAPI
|
1000
|
return_fields
|
list[str] | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
list[str] | None
|
Extra fields to add on top of
|
None
|
**filters
|
Any
|
Field-level filters using kwarg conventions (e.g.
|
{}
|
Returns:
| Type | Description |
|---|---|
list[TModel]
|
A |
str | None
|
model instances; |
tuple[list[TModel], str | None]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
UnsupportedOperationError
|
If WAPI does not support reads of this object type. |
NiosError
|
Or a subclass for WAPI errors. |
Example
Fetch the first two pages manually::
rows, next_id = await resource.list_page(max_results=100)
if next_id:
more, _ = await resource.list_page(page_id=next_id)
Source code in src/ibx_nios_sdk/_resource.py
list ¶
list(*, max_results: int = 1000, return_fields: list[str] | None = None, return_fields_plus: list[str] | None = None, **filters: Any) -> AsyncPageIterator[TModel]
Return an auto-paginated async iterator over all matching objects.
Fetches pages on demand as the caller iterates. Use await .all()
on the returned iterator to collect every record into a list at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_results
|
int
|
Maximum records per page (WAPI |
1000
|
return_fields
|
list[str] | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
list[str] | None
|
Extra fields on top of |
None
|
**filters
|
Any
|
Field-level filters (see :func: |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
AsyncPageIterator[TModel]
|
class: |
AsyncPageIterator[TModel]
|
validated model instances across all pages. |
Raises:
| Type | Description |
|---|---|
UnsupportedOperationError
|
If WAPI does not support reads of this object type. Raised by this call, not by the first iteration. |
Example
Iterate lazily::
async for record in resource.list(name="example"):
print(record.ref)
Collect all at once::
records = await resource.list(comment__like="prod").all()
Source code in src/ibx_nios_sdk/_resource.py
find_one
async
¶
find_one(*, return_fields: _StrList | None = None, return_fields_plus: _StrList | None = None, **filters: Any) -> TModel | None
Return the first matching object, or None if no match is found.
Requests at most one result (max_results=1) to minimise data
transfer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_fields
|
_StrList | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
_StrList | None
|
Extra fields on top of |
None
|
**filters
|
Any
|
Field-level filters (see :func: |
{}
|
Returns:
| Type | Description |
|---|---|
TModel | None
|
The first matching validated model instance, or |
TModel | None
|
WAPI returns an empty result set. |
Raises:
| Type | Description |
|---|---|
NiosError
|
Or a subclass for WAPI errors. |
Example
Look up a record by name::
record = await resource.find_one(name="foo.example.com")
if record is None:
print("not found")
Source code in src/ibx_nios_sdk/_resource.py
get
async
¶
get(ref: str, *, return_fields: _StrList | None = None, return_fields_plus: _StrList | None = None) -> TModel
Fetch a single WAPI object by its _ref.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
The WAPI object reference string (e.g.
|
required |
return_fields
|
_StrList | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
_StrList | None
|
Extra fields on top of |
None
|
Returns:
| Type | Description |
|---|---|
TModel
|
A validated model instance for the requested object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NotFoundError
|
If the object no longer exists in NIOS. |
UnsupportedOperationError
|
If WAPI does not support reads of this object type. |
NiosError
|
Or a subclass for other WAPI errors. |
Example
Fetch a record by ref::
record = await resource.get("record:a/ZG5z...:1.2.3.4/default")
print(record.ipv4addr)
Source code in src/ibx_nios_sdk/_resource.py
create
async
¶
create(obj: BaseModel | dict[str, Any], *, return_fields: _StrList | None = None, return_fields_plus: _StrList | None = None) -> TModel
Create a new WAPI object and return the populated model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
BaseModel | dict[str, Any]
|
A Pydantic model instance or plain dict containing the fields
for the new object. |
required |
return_fields
|
_StrList | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
_StrList | None
|
Extra fields on top of |
None
|
Returns:
| Type | Description |
|---|---|
TModel
|
A validated model instance for the newly created object, populated |
TModel
|
with the fields requested via |
Raises:
| Type | Description |
|---|---|
UnsupportedOperationError
|
If WAPI does not support creating this object type. |
ConflictError
|
If the object already exists. |
BadRequestError
|
If the request body contains invalid fields. |
NiosError
|
Or a subclass for other WAPI errors. |
Example
Create an A record::
record = await resource.create(
{"name": "host.example.com", "ipv4addr": "1.2.3.4"}
)
print(record.ref)
Source code in src/ibx_nios_sdk/_resource.py
update
async
¶
update(ref: str, obj: BaseModel | dict[str, Any], *, return_fields: _StrList | None = None, return_fields_plus: _StrList | None = None) -> TModel
Update an existing WAPI object and return the refreshed model.
Sends a PUT request with _return_as_object=1. Read-only fields
listed in _readonly_fields are stripped from the payload
automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
WAPI object reference string identifying the object to update. |
required |
obj
|
BaseModel | dict[str, Any]
|
A Pydantic model instance or plain dict of fields to update.
|
required |
return_fields
|
_StrList | None
|
Exact list of fields to return; mutually exclusive
with |
None
|
return_fields_plus
|
_StrList | None
|
Extra fields on top of |
None
|
Returns:
| Type | Description |
|---|---|
TModel
|
A validated model instance reflecting the object's state after the |
TModel
|
update. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NotFoundError
|
If the object no longer exists in NIOS. |
UnsupportedOperationError
|
If WAPI does not support updating this object type. |
NiosError
|
Or a subclass for other WAPI errors. |
Example
Change the comment on a host record::
updated = await resource.update(
"record:host/ZG5z...",
{"comment": "updated by SDK"},
)
Source code in src/ibx_nios_sdk/_resource.py
delete
async
¶
Delete a WAPI object by its _ref.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
WAPI object reference string identifying the object to delete. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The |
str
|
differ from the input |
str
|
the input |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NotFoundError
|
If the object does not exist in NIOS. |
UnsupportedOperationError
|
If WAPI does not support deleting this object type. |
NiosError
|
Or a subclass for other WAPI errors. |
Example
Delete an A record::
deleted_ref = await resource.delete("record:a/ZG5z...:1.2.3.4/default")
Source code in src/ibx_nios_sdk/_resource.py
call_function
async
¶
Call a WAPI function on a specific object or on the object type.
Uses POST /<ref>?_function=<name> when ref is provided, or
POST /<wapi_type>?_function=<name> for type-level functions.
None kwarg values are excluded from the request body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str | None
|
WAPI object reference, or |
required |
function
|
str
|
WAPI function name (e.g. |
required |
**kwargs
|
Any
|
Function arguments passed as the POST body. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The parsed JSON response body from the function call as a dict |
dict[str, Any]
|
(empty dict if the WAPI returns no body). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NiosError
|
Or a subclass for WAPI errors. |
Example
Find the next available IP in a network::
result = await resource.call_function(
"network/ZG5z...",
"nextavailableip",
num=1,
)
print(result["ips"])
Source code in src/ibx_nios_sdk/_resource.py
set_extattrs
async
¶
Set extensible attributes on a WAPI object.
Wraps kwarg key/value pairs into the WAPI extattrs nested shape
({"<name>": {"value": <val>}}) and delegates to
:meth:update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
WAPI object reference string identifying the target object. |
required |
**kwargs
|
Any
|
Extensible-attribute name/value pairs to set (e.g.
|
{}
|
Returns:
| Type | Description |
|---|---|
TModel
|
A validated model instance reflecting the object's state after the |
TModel
|
update. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NiosError
|
Or a subclass for WAPI errors. |
Example
Tag a host record with a site attribute::
updated = await resource.set_extattrs(
"record:host/ZG5z...",
Site="NYC",
Owner="ops-team",
)