Method: Warrant::Object.list

Defined in:
lib/warrant/models/object.rb

.list(filters = {}, options = {}) ⇒ Array<Object>

Lists all objects for your organization and environment

Examples:

List all objects

Warrant::Object.list()

Options Hash (filters):

  • :object_type (String)

    Only return objects with an object_type matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Raises:



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/warrant/models/object.rb', line 145

def self.list(filters = {}, options = {})
    res = APIOperations.get(URI.parse("#{::Warrant.config.api_base}/v2/objects"), params: Util.normalize_params(filters), options: options)

    case res
    when Net::HTTPSuccess
        list_result = JSON.parse(res.body, symbolize_names: true)
        objects = list_result[:results].map{ |object| Object.new(object[:objectType], object[:objectId], object[:meta], object[:createdAt]) }
        return ListResponse.new(objects, list_result[:prevCursor], list_result[:nextCursor])
    else
        APIOperations.raise_error(res)
    end
end