# ironicclient.common.apiclient.base module

Base utilities to build API operation managers and objects on top of.

class ironicclient.common.apiclient.base.BaseManager(client: Any)

  Bases: `HookableMixin`

  Basic manager type providing common operations.

  Managers interact with a particular type of API (servers, flavors, images, etc.) and provide CRUD operations for them.

  resource_class: type[Resource] | None = None

class ironicclient.common.apiclient.base.CrudManager(client: Any)

  Bases: `BaseManager`

  Base manager class for manipulating entities.

  Children of this class are expected to define a collection_key and key.

  - collection_key: Usually a plural noun by convention (e.g. entities); used to refer collections in both URL’s (e.g. /v3/entities) and JSON objects containing a list of member resources (e.g. {‘entities’: [{}, {}, {}]}).

  - key: Usually a singular noun by convention (e.g. entity); used to refer to an individual member of the collection.

  build_url(base_url: str | None = None, **kwargs: Any) → str

    Builds a resource URL for the given kwargs.

    Given an example collection where collection_key = ‘entities’ and key = ‘entity’, the following URL’s could be generated.

    By default, the URL will represent a collection of entities, e.g.:

        /entities

    If kwargs contains an entity_id, then the URL will represent a specific member, e.g.:

        /entities/{entity_id}

    Parameters:

      base_url – if provided, the generated URL will be appended to it

  collection_key: str | None = None
  create(**kwargs: Any) → Resource
  delete(**kwargs: Any) → Any
  find(base_url: str | None = None, **kwargs: Any) → Resource

    Find a single item with attributes matching `**kwargs`.

    Parameters:

      base_url – if provided, the generated URL will be appended to it

  get(**kwargs: Any) → Resource
  head(**kwargs: Any) → bool
  key: str | None = None
  list(base_url: str | None = None, **kwargs: Any) → list[Resource]

    List the collection.

    Parameters:

      base_url – if provided, the generated URL will be appended to it

  put(base_url: str | None = None, **kwargs: Any) → Resource | None

    Update an element.

    Parameters:

      base_url – if provided, the generated URL will be appended to it

  update(**kwargs: Any) → Resource

class ironicclient.common.apiclient.base.Extension(name: str, module: Any)

  Bases: `HookableMixin`

  Extension descriptor.

  SUPPORTED_HOOKS: tuple[str, ...] = ('__pre_parse_args__', '__post_parse_args__')
  manager_class: type[BaseManager] | None = None

class ironicclient.common.apiclient.base.HookableMixin

  Bases: `object`

  Mixin so classes can register and run hooks.

  classmethod add_hook(hook_type: str, hook_func: Callable[[...], Any]) → None

    Add a new hook of specified type.

    Parameters:

      - cls – class that registers hooks

      - hook_type – hook type, e.g., ‘__pre_parse_args__’

      - hook_func – hook function

  classmethod run_hooks(hook_type: str, *args: Any, **kwargs: Any) → None

    Run all hooks of specified type.

    Parameters:

      - cls – class that registers hooks

      - hook_type – hook type, e.g., ‘__pre_parse_args__’

      - args – args to be passed to every hook function

      - kwargs – kwargs to be passed to every hook function

class ironicclient.common.apiclient.base.ManagerWithFind(client: Any)

  Bases: `BaseManager`

  Manager with additional find()/findall() methods.

  find(**kwargs: Any) → Resource

    Find a single item with attributes matching `**kwargs`.

    This isn’t very efficient: it loads the entire list then filters on the Python side.

  findall(**kwargs: Any) → Sequence[Resource]

    Find all items with attributes matching `**kwargs`.

    This isn’t very efficient: it loads the entire list then filters on the Python side.

  abstractmethod list() → list[Resource]

class ironicclient.common.apiclient.base.Resource(manager: BaseManager, info: dict[str, Any], loaded: bool = False)

  Bases: `object`

  Base class for OpenStack resources (tenant, user, etc.).

  This is pretty much just a bag for attributes.

  HUMAN_ID: bool = False
  NAME_ATTR: str = 'name'
  get() → None

    Support for lazy loading details.

    Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.

  property human_id: str | None

    Human-readable ID which can be used for bash completion.

  is_loaded() → bool
  set_loaded(val: bool) → None
  to_dict() → dict[str, Any]

ironicclient.common.apiclient.base.getid(obj: Any) → Any

  Return id if argument is a Resource.

  Abstracts the common pattern of allowing both an object or an object’s ID (UUID) as a parameter when dealing with relationships.

this page last updated: 2026-02-27 11:39:19

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug