REST API - query

cis data resource model: query

Executes the provided cis.data.resource_model.query_spec instance, i.e. retrieve a snapshot of the resource model data as specified in the query.

Request:

HTTP request

POST https://{server}/rest/com/vmware/cis/data/resource-model?~action=query

Request Body Structure:

{
    "query_spec"{
        "resource_models"[
            "string",
            "string"
        ],
        "filter"{
            "criteria"[
                {
                    "comparable_value""opaque_string_value",
                    "property""string",
                    "comparable_list"[
                        "opaque_string_value",
                        "opaque_string_value"
                    ],
                    "operator""EQUAL"
                },
                {
                    "comparable_value""opaque_string_value",
                    "property""string",
                    "comparable_list"[
                        "opaque_string_value",
                        "opaque_string_value"
                    ],
                    "operator""EQUAL"
                }
            ],
            "operator""AND"
        },
        "sort_criteria"[
            {
                "sort_direction""ASCENDING",
                "property""string"
            },
            {
                "sort_direction""ASCENDING",
                "property""string"
            }
        ],
        "offset"1,
        "limit"1,
        "properties"[
            "string",
            "string"
        ],
        "return_total_count"true
    }
}

Request Body Parameters:

Name Type Description
bold = required
query_spec query_spec The query that defines the resource model data to retrieve.
query_spec.properties string[] The names of the (resource model) properties to be included in the result set for the query.

Each property name could be either a single property name, in case of an immediate property of the resource model or a property path, i.e. chain of property names, separated with / symbol to indicate a child property, e.g. relatives/father.

In case a requested property is present in more than one of the queried resource models (specified in cis.data.resource_model.query_spec.resource_models) the property name should be prefixed by the fully-qualified name of the resource model of interest, followed by / symbol before the actual property name, e.g. com.acme.PersonModel/relatives/father.

Corresponds to the SELECT clause in SQL, where the property names correspond to column names.

The list must not be empty. Otherwise, vapi.std.errors.invalid_argument error will be thrown.

query_spec.resource_models string[] The names of the resource models to be queried. All properties used in the query should belong to one of those resource models. If a property from another model is used somewhere else in the query an vapi.std.errors.invalid_argument error will be thrown to indicate this violation. Multiple resource models could be specified here only if they all belong to the same resource type. In case multiple resoruce models are specified they are implicitly joined on their primary key @modelKey property.

Each resource model name should be fully-qualified, e.g. com.acme.PersonModel

Corresponds to the FROM clause in SQL where the resource models correspond to tables.

The list must not be empty. Otherwise, vapi.std.errors.invalid_argument error will be thrown.

query_spec.filter filter Restricts (filters) the set of resource models whose properties should be returned based on conditions/predicates on their property values.

Corresponds to the WHERE clause in SQL.

Optional. If unset, the query matches all instances of the resource models specified in the cis.data.resource_model.query_spec.resource_models field (FROM clause).

query_spec.filter.criteria property_predicate[] A set of conditions on the resource model properties that together define the criteria for filtering/matching the resources whose data to retrieve.

The list must not be empty. Otherwise, vapi.std.errors.invalid_argument error will be thrown.

query_spec.filter.criteria[].property string Specifies the resource model property to be compared.

The property name could be either a single property name, in case of an immediate property of the resource model or a property path, i.e. chain of property names, separated with / symbol to indicate a child property, e.g. relatives/father.

In case the specified property is present in more than one of the queried resource models (specified in cis.data.resource_model.query_spec.resource_models) the property name should be prefixed by the fully-qualified name of the resource model of interest, followed by / symbol before the actual property name, e.g. com.acme.PersonModel/relatives/father.

query_spec.filter.criteria[].operator string The operator to use for comparison of the property value.

Defines the possible operators to use when comparing the values of individual resource model properties.

When comparing values of different types, one of the values can be promoted from one type to another (if needed in order to perform correct comparison) according to the following rules:

  • When comparing numeric values, a comparable of type long could be promoted (converted) to type double. The result value will be the same as the original value.
  • When comparing to a boolean value, a comparable of type string can be converted to boolean if the value is parsable to boolean, i.e. either false or true in lower case.
Value is one of:
EQUAL: Equality operator
NOT_EQUAL: Inequality operator
GREATER: Greater than operator
GREATER_OR_EQUAL: Greater than or equal to operator
LESS: Less than operator
LESS_OR_EQUAL: Less than or equal to operator
IN: Checks for equality with at least one of a list of values
query_spec.filter.criteria[].comparable_value opaque The primitive value that the property should be compared to. Note that only the following primitive value types could be used for comparison:
  • integer
  • floating point number
  • boolean
  • string
If any other type is provided, vapi.std.errors.invalid_argument exception will be returned.

Please, note that when comparing with resource identifier, i.e. @modelKey property, the comparable value should be of string type.

Optional. It is only relevant when operator has value [EQUAL, NOT_EQUAL, GREATER, GREATER_OR_EQUAL, LESS, LESS_OR_EQUAL]. This field is optional and it is only relevant when the value of operator is one of EQUAL, NOT_EQUAL, GREATER, GREATER_OR_EQUAL, LESS, or LESS_OR_EQUAL.

query_spec.filter.criteria[].comparable_list opaque[] The list of primitive values to test for equality with the property value when operator IN is used. The list cannot be empty. See cis.data.resource_model.property_predicate.comparable_value for the list of allowable primitive value types.

Optional. It is only relevant when operator has value IN. This field is optional and it is only relevant when the value of operator is IN.

query_spec.filter.operator string The logical operator which defines how the property predicates should be combined in order to filter a given resource.

Optional. If unset, defaults to AND.

query_spec.sort_criteria sort_criterion[] Defines how the final result set should be sorted by comparing the values of one or more properties of the items in the result set. Represents a list of one or more sorting criteria, where those with lower indices in the list takes precedence over the specs with higher indices.

Corresponds to the ORDER BY clause in SQL.

Optional. If unset, no sorting will be applied.

query_spec.offset long The offset into the result set. Must be non-negative number.

If the offset is N then items from N to N + limit - 1 will be returned.

Optional. If unset, resources starting from the very first element will be returned.

query_spec.limit long The maximum number of result items to return. Could be used only if sorting criteria cis.data.resource_model.query_spec.sort_criteria is applied. If used, the value should be positive integer.

Optional. If unset, all resources will be returned. Note that the service defines its own limit that cannot be overriden here. If the more resources than this default limit, an vapi.std.errors.invalid_argument error will be thrown.

query_spec.return_total_count boolean Indicates whether the total number of resources that matched the query should be computed and returned. This is meaningful only in cases where the number of resources that match the query could be more than the limit of the result items to be returned as specified in cis.data.resource_model.query_spec.limit, or if the client wants to retrieve only the number of items that matched the query, but without the items themselves. If unset, defaults to false.

The total number of matched resources depends solely on the cis.data.resource_model.query_spec.filter and the cis.data.resource_model.query_spec.resource_models. It does not depend on the requested cis.data.resource_model.query_spec.properties, i.e. the total count is similar to but less expressive than the SQL count function.

NOTE: Use this with particular caution and only when it's absolutely needed as the computation of this value could have noticeable performance overhead.

Optional. If unset, it will be automatically assigned as false.

Response:

HTTP Status Code: 200

Representation:

{
    "value"{
        "total_count"1,
        "items"[
            {
                "property_values"[
                    "opaque_string_value",
                    "opaque_string_value"
                ]
            },
            {
                "property_values"[
                    "opaque_string_value",
                    "opaque_string_value"
                ]
            }
        ],
        "properties"[
            "string",
            "string"
        ]
    }
}

Response Type:

Name Type Description
bold = required
value result_set The resource model data retrieved for the provided query.
value.properties string[] The names of the (resource model) properties (as requested in cis.data.resource_model.query_spec.properties) returned for each resource item in the result set. The position (index) of each model property in this list corresponds to the position of the model property value in each resource item's values list. That is, the name of each resource model property in the cis.data.resource_model.resource_item.property_values list is given by the string with the same index (position) in this list.

Could be empty only in case the cis.data.resource_model.result_set.items list is empty.

value.items resource_item[] The list of result items. Each item corresponds to a particular resource that matched the conditions in the specified cis.data.resource_model.query_spec instance and containing the property data retrieved for that resource.

Could be empty if no items matched the query.

value.items[].property_values opaque[] The model property values for the resource. The name of each model property value is given by the model property name with the same index in cis.data.resource_model.result_set.properties. In other words, the position of a property value in this list should be the same as the position of the property in the cis.data.resource_model.result_set.properties list.

A property value may be unset if the respective property is unset or doesn't exist for the resource. For example, if the optional VirtualMachine/config property is unset then its child property VirtualMachine/config/modified doesn't exist; they both will manifest as unset values in the property_values list.

value.total_count long The total number of resources that matched the query, regardless of the actual number that is returned in cis.data.resource_model.result_set.items.

Optional. This value is set if and only if it has been explicitly requested in the query, i.e. if the cis.data.resource_model.query_spec.return_total_count flag has been set to true.

Errors:

HTTP Status Code Type Description
400 invalid_argument If cis.data.resource_model.query_spec.offset value is negative.
401 unauthenticated If a session has not been created, has expired due to inactivity or explicit log out, or if a session the service itself has created with an underlying data provider has expired and cannot be reestablished. In all cases the client should login again and retry the query.