Containers API in Wasabi AiR
    • 20 May 2024
    • 2 Minutes to read
    • PDF

    Containers API in Wasabi AiR

    • PDF

    Article summary

    A container houses many Items. Harvesting can be initiated on containers using the Containers API. Refer to the description of Storage to learn about why containers are important.

    Container Object

    A Container Object has the following structure:

    {
    	"id": "something123",
    	"location_id": "AVhdTJJguT9afTJxvbUD",
    	"version": 34,
    	"enabled": true,
    	"last_harvested": "2016-09-14T12:19:36.660671975Z",
    	"request_id": "57d9405828e65b67d978a8b5be9d272a",
    	"harvest_success_count": 26,
    	"harvest_failure_count": 0,
    	"last_harvested_failure": "0001-01-01T00:00:00Z",
    	"groups": []
    }
    • id - (string) The ID of this container (unique to the location).
    • location_id - (string) The ID of the location.
    • version - (int) The number of times this container has been harvested.
    • enabled - (bool) An indication of whether or not harvesting is enabled for this container.
    • last_harvested - (timestamp) The time when the container was last harvested.
    • request_id - (string) Optional. The ID of the request that caused this container to be harvested.
    • harvest_success_count - (int) The number of items that were successfully harvested.
    • harvest_failure_count - (int) The number of items where harvesting failed.
    • groups - (array) The groups associated with this container (see the Users and Groups API).

    Reading Containers From a Location

    To access the containers at a location, make the following request:

    GET /api/data/locations/{id}/containers?prefix={prefix}&cursor={cursor}
    • {id} - (string) The ID of the location.
    • {prefix} - (string) Optional. Only containers with the specified prefix are returned.
    • {cursor} - (string) Optional. A cursor that indicates the start of the items to get. This must be a value of next_cursor from the previous request.

    Response

    You are presented with a page of Container Objects wrapped inside an object that provides some context about the response:

    {
    	"containers": [
    		{container-objects},
    		{container-objects},
    		{container-objects}
    	],
    	"prefix": "{prefix}",
    	"next_cursor": "{next_cursor}"
    }
    
    • container-objects - (array) A list of container objects.
    • prefix - (string) Optional. A prefix used to find this page of containers.
    • next_cursor - (string) The cursor to use to get the next page of results. If empty (""), you have reached the end of the list.

    Enabling Containers for Harvest

    Containers that are enabled are harvested by Wasabi AiR. This can be toggled using the following API request:

    PUT /api/data/containers
    {
    	"id": "{id}",
    	"location_id": "{location_id}",
    	"enabled": "{enabled}"
    }
    
    • id - (string) The ID of the container (see Read Containers from a Location above).
    • location_id - (string) The ID of the location of this container.
    • enabled - (bool) An indication of whether or not this container should be harvested (true for yes, false for no).

    Reading Enabled Containers

    An enabled container is actively being harvested by Wasabi AiR. You can obtain a filtered list with the following API:

    GET /api/data/containers/enabled

    Response

    You receive an array of enabled containers:

    [
    	{container-objects},
    	{container-objects},
    	{container-objects}
    ]
    • container-objects - (array) A list of Container Objects.

    Getting the Name of a Container

    This endpoint retrieves the Stow container name for a given container.

    GET /api/data/v3/containers/{id}/name
    • id - The hash ID of the container (not the Stow container ID).

    Response

    {
        "name": "bmp13"
    }
    • name - (string) The Stow container name.