ibm_aigov_facts_client.factsheet.asset_utils_inventory module

class AIGovInventoryUtilities(assets_client: Assets, inventory_id: str, inventory_name: str = None, inventory_description: str = None, inventory_creator_name: str = None, inventory_creator_id: str = None)

Bases: object

AI asset utilities. Running client.assets.get_inventory and client.assets.list_inventories makes all methods in AIGovAssetUtilities object available to use.

classmethod from_dict(_dict: Dict[str, Any]) AIGovInventoryUtilities

Initialize an AIGovInventoryUtilities object from a dictionary.

to_dict() Dict[str, Any]

Return a dictionary representing this model.

get_info() dict

Retrieve and return information related to the Inventory.

This method does not take any parameters.

Returns:

dict: A dictionary containing inventory details.

Example:
>>> inventory_info = inventory.get_info()
get_id() str

Retrieve the Inventory ID.

This method does not take any parameters and returns the Inventory ID.

Returns:

str: The ID of the inventory.

Example:
>>> inventory_id = inventory.get_id()
set_detail(name: str = None, description: str = None)

set details of an inventory item.

It allows updating the name and/or description of the inventory.

Parameters:
  • name (str, optional): The new name to set for the inventory. If not provided, the name will not be changed.

  • description (str, optional): The new description to set for the inventory. If not provided, the description will not be changed.

Example:
>>> innventory.set_detail(name="New Name", description="Updated description")
delete_inventory(force_delete: bool = False)

Delete the inventory.

This method also deletes the associated bucket created in IBM Cloud. Use this function with caution, as deletion is irreversible.

Args:

force_delete (bool): If True, forces the deletion without checking for assets. Default is False.

Example:
>>> inventory.delete_inventory(force_delete=True)
list_collaborators() List[Dict[str, str | None]]

Retrieve a list of collaborators for the inventory.

If no collaborators are found or if the collaborator information is unavailable, an empty list is returned.

Returns:

List[Dict[str, Optional[str]]]: A list of dictionaries with details about each collaborator, or an empty list if no collaborators are found.

Example:
>>> collaborators = inventory.list_collaborators()
add_collaborator(role: str, user_id: str | int = None, access_group_id: str | int = None)

Add a collaborator to the inventory.

This method assigns a user or an access group to the inventory with a specified role.

Parameters:
  • role (str): The role to assign to the collaborator. Available options are in Role.

  • user_id (str, optional): The ID of the user to be added as a collaborator.

  • access_group_id (str, optional): The ID of the access group to be added as a collaborator.

Note:
  • Ensure that you have the correct user ID or access group ID format based on the platform you are using.

  • Both user_id and access_group_id cannot be provided simultaneously.

Example:
>>> inventory.add_collaborator(role="Editor", user_id="IBMid-11000***")
>>> inventory.add_collaborator(role="Viewer", access_group_id="access-group-12345")
remove_collaborator(user_id: str = None, access_group_id: str = None)

Remove a collaborator from the inventory.

This method removes a user from the inventory.

Parameters:
  • user_id (str,optional): The ID of the user to be removed from the collaborators.

  • access_group_id (str, optional): The ID of the access group to be added as a collaborator.

Note:
  • Ensure that you have the correct user ID or access group ID format based on the platform you are using.

  • Both user_id and access_group_id cannot be provided simultaneously.

Example:
>>> inventory.remove_collaborator(user_id="IBMid-11000***")
>>> inventory.remove_collaborator(access_group_id="access-group-12345")
set_collaborator_role(role: str, user_id: str = None, access_group_id: str = None)

set the role of an existing collaborator in the inventory.

This method changes the role assigned to a user in the inventor.

Parameters:
  • role (str): The role to assign to the user.Available options are in Role

  • user_id (str,optional): The ID of the user whose role is to be updated.

  • access_group_id (str, optional): The ID of the access group to be added as a collaborator.

Note:
  • Ensure that you have the correct user ID or access group ID format based on the platform you are using.

  • Both user_id and access_group_id cannot be provided simultaneously.

Example:
>>> inventory.set_collaborator_role(role="Viewer", user_id="IBMid-11000***")
>>> inventory.set_collaborator(role="Viewer", access_group_id="access-group-12345")