API Reference¶
Auto-generated reference for every public class, method, and model in the SDK. Pages are organized by domain - pick the one you need on the left, or use search.
The reference content is extracted directly from the source code on every docs build, so it always matches the installed SDK.
Client¶
NiosClient ¶
NiosClient(*, grid_url: str | None = None, username: str | None = None, password: str | None = None, wapi_version: str | None = None, use_session: bool = True, verify: bool | str | Path = True, ca_bundle: str | Path | None = None, timeout: float = 30.0, max_retries: int = 3, enforce_restrictions: bool = True, _transport: AsyncBaseTransport | None = None)
Entry point for the Infoblox NIOS SDK.
Per-domain services (dns, dhcp, ipam, ...) are exposed as
@cached_property attributes and lazily instantiated on first access.
The client supports use as an async context manager and reads configuration
from environment variables when constructor arguments are omitted.
Environment variables:
NIOS_GRID_URL: Fallback forgrid_url.NIOS_USERNAME: Fallback forusername.NIOS_PASSWORD: Fallback forpassword.NIOS_WAPI_VERSION: Fallback forwapi_version.
Example
Use as an async context manager::
async with NiosClient(
grid_url="https://192.168.1.2",
username="admin",
password="secret",
) as client:
records = await client.dns.a_record.list(name="host.example.com").all()
Initialize the NIOS client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_url
|
str | None
|
Base URL of the NIOS Grid Manager (e.g.
|
None
|
username
|
str | None
|
WAPI username. Falls back to |
None
|
password
|
str | None
|
WAPI password. Falls back to |
None
|
wapi_version
|
str | None
|
WAPI version string (e.g. |
None
|
use_session
|
bool
|
When True (default), authenticates via a session cookie
from |
True
|
verify
|
bool | str | Path
|
TLS certificate verification. Pass |
True
|
ca_bundle
|
str | Path | None
|
Convenience alias for a custom CA bundle path. When set,
overrides |
None
|
timeout
|
float
|
Request timeout in seconds for all WAPI calls. |
30.0
|
max_retries
|
int
|
Number of additional retry attempts on 429/5xx responses. |
3
|
enforce_restrictions
|
bool
|
When True (default), a resource method raises
:class: |
True
|
_transport
|
AsyncBaseTransport | None
|
Custom |
None
|
Raises:
| Type | Description |
|---|---|
NiosError
|
If |
Source code in src/ibx_nios_sdk/client.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
microsoftserver
cached
property
¶
Entry point for NIOS Microsoft Server resources.
federatedrealms
cached
property
¶
Entry point for NIOS Federated Realms resources.
notification
cached
property
¶
Entry point for NIOS Notification resources.
smartfolder
cached
property
¶
Entry point for NIOS Smart Folder resources.
threatinsight
cached
property
¶
Entry point for NIOS Threat Insight resources.
threatprotection
cached
property
¶
Entry point for NIOS Threat Protection resources.
read_raw
async
¶
Read an uncoerced WAPI collection or its schema through SDK transport.
This narrow fallback accepts only a single WAPI object type. Schema and
paging controls must be supplied through params; URLs, object refs,
embedded query strings, and credential-bearing parameters are rejected.
Prefer the typed resource APIs whenever one is available.
Source code in src/ibx_nios_sdk/client.py
read_schema
async
¶
Read the WAPI root schema or one collection object's schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_type
|
str | None
|
A safe WAPI collection object type. When omitted, the WAPI version root schema is returned. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The uncoerced JSON schema response from NIOS. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
NiosError
|
Or a subclass for transport or WAPI errors. |
Source code in src/ibx_nios_sdk/client.py
aclose
async
¶
Close the underlying HTTP client and release any active WAPI session.
Calls :meth:~ibx_nios_sdk._http.HttpClient.aclose, which logs out of
the WAPI session if one is active before closing the httpx.AsyncClient.
Example
Explicit lifecycle management::
client = NiosClient(grid_url=..., username=..., password=...)
try:
...
finally:
await client.aclose()
Source code in src/ibx_nios_sdk/client.py
Core Building Blocks¶
HTTP Client¶
The low-level transport. You normally won't touch this directly - it's
created by NiosClient and shared across services.
HttpClient ¶
HttpClient(*, grid_url: str, username: str, password: str, wapi_version: str = DEFAULT_WAPI_VERSION, use_session: bool = True, verify: bool | str | Path = True, timeout: float = 30.0, max_retries: int = 3, enforce_restrictions: bool = True, transport: AsyncBaseTransport | None = None)
Async HTTP client for Infoblox NIOS WAPI.
Wraps httpx.AsyncClient with WAPI-specific behaviour: session-cookie
auth (or Basic-auth fallback), automatic retry with exponential backoff on
429/5xx responses, one-shot 401 re-login, and structured error mapping via
:func:~ibx_nios_sdk._exceptions.exception_for_status.
Initialize the NIOS HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_url
|
str
|
Base URL of the NIOS Grid Manager (e.g.
|
required |
username
|
str
|
WAPI username for authentication. |
required |
password
|
str
|
WAPI password for authentication. |
required |
wapi_version
|
str
|
WAPI version string appended to the base URL (e.g.
|
DEFAULT_WAPI_VERSION
|
use_session
|
bool
|
When True, authenticates via a WAPI session cookie
( |
True
|
verify
|
bool | str | Path
|
TLS certificate verification. Pass |
True
|
timeout
|
float
|
Request timeout in seconds applied to all operations. |
30.0
|
max_retries
|
int
|
Maximum number of additional attempts after the first failure for retryable status codes (429, 502, 503, 504). |
3
|
enforce_restrictions
|
bool
|
When True (default), resources refuse
read/create/update/delete on object types whose WAPI schema
restricts them, raising |
True
|
transport
|
AsyncBaseTransport | None
|
Custom |
None
|
Source code in src/ibx_nios_sdk/_http.py
request
async
¶
request(method: str, path: str, *, params: dict[str, str] | None = None, json: dict[str, Any] | None = None) -> dict[str, Any] | None
Send a WAPI request with lazy login, retry, and one-shot 401 re-login.
If use_session is True and no session exists, authenticates first.
Retries on 429/5xx status codes up to max_retries times. On a 401
after a successful login, re-authenticates once and retries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
HTTP method string (e.g. |
required |
path
|
str
|
WAPI endpoint path relative to |
required |
params
|
dict[str, str] | None
|
Optional query-string parameters. |
None
|
json
|
dict[str, Any] | None
|
Optional JSON request body. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body as a dict, or None for 204 responses. |
Raises:
| Type | Description |
|---|---|
NiosConnectionError
|
If the connection fails before a response is received. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
get
async
¶
Send a GET request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
WAPI endpoint path relative to the base URL. |
required |
params
|
dict[str, str] | None
|
Optional query-string parameters. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body, or None for empty responses. |
Raises:
| Type | Description |
|---|---|
NiosConnectionError
|
If the connection fails before a response. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
post
async
¶
post(path: str, *, params: dict[str, str] | None = None, json: dict[str, Any] | None = None) -> dict[str, Any] | None
Send a POST request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
WAPI endpoint path relative to the base URL. |
required |
params
|
dict[str, str] | None
|
Optional query-string parameters (e.g. |
None
|
json
|
dict[str, Any] | None
|
Optional JSON request body. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body, or None for empty responses. |
Raises:
| Type | Description |
|---|---|
NiosConnectionError
|
If the connection fails before a response. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
put
async
¶
put(path: str, *, params: dict[str, str] | None = None, json: dict[str, Any] | None = None) -> dict[str, Any] | None
Send a PUT request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
WAPI endpoint path relative to the base URL. |
required |
params
|
dict[str, str] | None
|
Optional query-string parameters (e.g. |
None
|
json
|
dict[str, Any] | None
|
Optional JSON request body with the full resource representation. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body, or None for empty responses. |
Raises:
| Type | Description |
|---|---|
NiosConnectionError
|
If the connection fails before a response. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
delete
async
¶
Send a DELETE request.
WAPI DELETE responses return the deleted object's _ref as a plain
string, which _safe_json wraps as {"_value": ref}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
WAPI endpoint path relative to the base URL. |
required |
params
|
dict[str, str] | None
|
Optional query-string parameters. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body (typically |
dict[str, Any] | None
|
None for empty responses. |
Raises:
| Type | Description |
|---|---|
NiosConnectionError
|
If the connection fails before a response. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
get_with_return_fields
async
¶
get_with_return_fields(path: str, *, model_fields: list[str], return_fields: list[str] | None = None, return_fields_plus: list[str] | None = None, extra_params: dict[str, str] | None = None) -> dict[str, Any] | None
Send a GET request with _return_fields / _return_fields+ merged in.
Delegates field selection logic to
:func:~ibx_nios_sdk._query.build_return_fields_params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
WAPI endpoint path relative to the base URL. |
required |
model_fields
|
list[str]
|
Fields defined on the SDK model - used as the default
set when neither |
required |
return_fields
|
list[str] | None
|
Exact list of fields to request; mutually exclusive
with |
None
|
return_fields_plus
|
list[str] | None
|
Additional fields to append to |
None
|
extra_params
|
dict[str, str] | None
|
Additional query-string parameters merged after field
params (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The parsed JSON response body, or None for empty responses. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
NiosConnectionError
|
If the connection fails before a response. |
NiosError
|
Or a subclass for non-success status codes. |
Source code in src/ibx_nios_sdk/_http.py
aclose
async
¶
Close the client, logging out of any active WAPI session first.
If a session cookie is active, calls _logout to invalidate it
server-side before closing the underlying httpx.AsyncClient.
Example
Explicit close::
client = HttpClient(grid_url=..., username=..., password=...)
try:
...
finally:
await client.aclose()
Source code in src/ibx_nios_sdk/_http.py
Resource Base Class¶
Every resource on every domain inherits from WapiResource. The standard
list, list_page, get, create, update, delete, and
call_function methods are all defined here.
WapiResource ¶
Bases: Generic[TModel]
Base class for a single WAPI object type.
Provides list/get/create/update/delete/call_function operations against a NIOS WAPI endpoint. Subclasses must set three class variables:
_wapi_type: WAPI object type string, e.g."record:a"._model: Pydantic model class used to parse response rows._default_return_fields: Fields requested by default via_return_fields+.
Optionally set _readonly_fields to a set of field names that must be
stripped from PUT payloads on update. Set _create_only_fields for
fields that are writable on POST but readonly on PUT (WAPI supports
flag rw / rws - no u). These are kept on create() and
stripped on update().
Read/create/update/delete are gated on the object type's WAPI restrictions
(see :mod:ibx_nios_sdk._restrictions): an operation NIOS does not support
raises :class:~ibx_nios_sdk._exceptions.UnsupportedOperationError without
issuing a request. _restricted_ops is derived per subclass from
_wapi_type; a subclass may set it explicitly to override the table.
call_function is never gated - function-only types such as dtc
restrict every other operation.
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",
)
Source code in src/ibx_nios_sdk/_resource.py
Query Builder & Pagination¶
Translate Python kwargs into WAPI query parameters.
WAPI operator conventions
field=value -> exact match field~=value -> regex/substring match (kwarg: field__like) field<=value -> less than or equal (kwarg: field__lte) field>=value -> greater than or equal (kwarg: field__gte) field!=value -> not equal (kwarg: field__not) *EA_name=value -> extensible-attr filter (kwarg: extattr_EA_name)
build_filter_params ¶
Translate kwarg-style filters into WAPI query-param key/value pairs.
Keys with a __<op> suffix map to the corresponding WAPI operator
(like → ~, gte → >, lte → <, not → !).
Keys prefixed with extattr_ are mapped to *<EA_name> for
extensible-attribute filtering. None values are silently dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
dict[str, Any]
|
Dict of filter kwargs, typically the |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dict of WAPI query-parameter name/value pairs ready to pass as |
dict[str, str]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If an unknown |
Example
Build filters for a WAPI list request::
params = build_filter_params({"name": "foo", "comment__like": "bar"})
# {"name": "foo", "comment~": "bar"}
Source code in src/ibx_nios_sdk/_query.py
build_return_fields_params ¶
build_return_fields_params(*, model_fields: list[str], return_fields: list[str] | None, return_fields_plus: list[str] | None) -> dict[str, str]
Build the _return_fields / _return_fields+ query params.
Selection rules:
- Both
None→_return_fields+=<model_fields>so the full model can be populated from the response. return_fields=[..]→_return_fields=<exact list>(caller controls exactly which fields are returned).return_fields_plus=[..]→_return_fields+=<model_fields + extras>(model fields plus caller-specified extras).- Passing both →
ValueError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_fields
|
list[str]
|
Fields declared on the SDK model used as the default set. |
required |
return_fields
|
list[str] | None
|
Explicit list of fields; mutually exclusive with
|
required |
return_fields_plus
|
list[str] | None
|
Extra fields to append to |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dict containing either |
dict[str, str]
|
an empty dict when |
dict[str, str]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
Example
Request only specific fields::
params = build_return_fields_params(
model_fields=["name", "comment"],
return_fields=["name"],
return_fields_plus=None,
)
# {"_return_fields": "name"}
Source code in src/ibx_nios_sdk/_query.py
AsyncPageIterator - transparent multi-page async iteration over WAPI list responses.
AsyncPageIterator ¶
Bases: Generic[TModel]
Async iterator yielding parsed model instances from a paged WAPI response.
Callers pass a fetch coroutine that takes a page_id (or None
for the first page) and returns (rows, next_page_id). Iteration
terminates when next_page_id is None or "".
Initialize the page iterator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fetch
|
Fetcher
|
Async callable that accepts a |
required |
model
|
type[TModel]
|
Pydantic model class used to validate each row dict via
|
required |
Source code in src/ibx_nios_sdk/_paging.py
all
async
¶
Collect all pages into a single list.
Exhausts the iterator, fetching every page, and returns the combined
results. Prefer async iteration (async for) for large result sets
to avoid loading everything into memory at once.
Returns:
| Type | Description |
|---|---|
list[TModel]
|
A list of validated model instances from all pages. |
Example
Fetch all records at once::
iterator = resource.list(name="example")
records = await iterator.all()
Source code in src/ibx_nios_sdk/_paging.py
Object-Type Restrictions¶
The generated table of operations each WAPI object type refuses, consulted by
WapiResource before every read, create, update, and delete. Regenerate it with
tools/refresh_object_restrictions.py after refreshing the schema snapshot.
Per-object-type restrictions on read/create/update/delete.
Generated by tools/refresh_object_restrictions.py - do not edit by hand.
NIOS refuses operations an object type does not support, answering
AdmConProtoError: Operation <op> not allowed for <type>: a read-only
aggregate such as allrecords rejects every mutation, a singleton such as
grid rejects delete, and a function-only type such as dtc rejects
even read while still accepting call_function.
:class:~ibx_nios_sdk._resource.WapiResource consults this table so those calls
raise :class:~ibx_nios_sdk._exceptions.UnsupportedOperationError locally
instead of making a request the grid will refuse.
Source: grid ?_schema restrictions via tests/fixtures/wapi_schema_v2.14.json
restricted_ops ¶
Return the operations wapi_type does not support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wapi_type
|
str
|
WAPI object type string, e.g. |
required |
Returns:
| Type | Description |
|---|---|
frozenset[str]
|
A frozenset of operation names drawn from :data: |
frozenset[str]
|
the type supports every operation, or is unknown to the table. |
Source code in src/ibx_nios_sdk/_restrictions.py
Exceptions¶
Domain-aware exception hierarchy for the NIOS SDK.
NiosError ¶
NiosError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: Exception
Base exception for all NIOS SDK errors.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
NiosConnectionError ¶
NiosConnectionError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
TLS failure, DNS failure, connect timeout - pre-HTTP-response errors.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
AuthenticationError ¶
AuthenticationError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
401 - credentials rejected or session expired.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
NotFoundError ¶
NotFoundError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
404 - object does not exist.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
BadRequestError ¶
BadRequestError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
400 - malformed request or invalid field values.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
ConflictError ¶
ConflictError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
409 - object already exists or state conflict.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
RateLimitError ¶
RateLimitError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None, retry_after: float | None = None)
Bases: NiosError
429 - too many requests.
Initialize a rate-limit error with optional retry delay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code (typically 429). |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
retry_after
|
float | None
|
Seconds to wait before retrying, parsed from the
|
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
ServerError ¶
ServerError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
5xx - server-side failure.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
ValidationError ¶
ValidationError(*, status_code: int | None = None, message: str, response_body: dict[str, Any] | None = None, wapi_code: str | None = None, wapi_text: str | None = None, request_url: str | None = None)
Bases: NiosError
Pydantic parse failure - response did not match the expected model.
Initialize the base NIOS error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int | None
|
HTTP status code that triggered the error, or None for non-HTTP errors. |
None
|
message
|
str
|
Human-readable error description. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body from the WAPI, if available. |
None
|
wapi_code
|
str | None
|
WAPI-specific error code from the |
None
|
wapi_text
|
str | None
|
WAPI-specific error text from the |
None
|
request_url
|
str | None
|
Full URL of the request that caused the error. |
None
|
Source code in src/ibx_nios_sdk/_exceptions.py
UnsupportedOperationError ¶
Bases: NiosError
Object type does not support the requested operation - raised before the request.
NIOS restricts some operations per object type: allrecords is a read-only
aggregate, grid cannot be deleted, dtc accepts only function calls.
The grid answers those with AdmConProtoError: Operation <op> not allowed
for <type>; the SDK raises this instead, from the restriction table in
:mod:ibx_nios_sdk._restrictions.
Pass enforce_restrictions=False to :class:~ibx_nios_sdk.client.NiosClient
to skip the local check and let the grid decide - useful on a NIOS version
whose restrictions differ from the table's.
Initialize the error for one object type and operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wapi_type
|
str
|
WAPI object type that refused the operation. |
required |
operation
|
str
|
Operation name - |
required |
Source code in src/ibx_nios_sdk/_exceptions.py
exception_for_status ¶
exception_for_status(status_code: int, message: str, response_body: dict[str, Any] | None, *, retry_after: float | None = None, request_url: str | None = None) -> NiosError
Create the appropriate exception for an HTTP status code.
Maps well-known WAPI status codes to specific exception subclasses (e.g.
401 to AuthenticationError, 429 to RateLimitError). Codes in the
500–599 range produce ServerError; all other unrecognised codes produce
the base NiosError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_code
|
int
|
HTTP response status code. |
required |
message
|
str
|
Human-readable error message extracted from the response. |
required |
response_body
|
dict[str, Any] | None
|
Parsed JSON response body, or None. |
required |
retry_after
|
float | None
|
Seconds to wait before retrying; used only for 429
responses where a |
None
|
request_url
|
str | None
|
Full URL of the request that triggered the error. |
None
|
Returns:
| Type | Description |
|---|---|
NiosError
|
A |