data Package

data Package

definition Module

DataDefinition classes

class vmware.vapi.data.definition.AnyErrorDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for ‘Exception’ type in IDL

Initialize AnyErrorDefinition

validate(value)[source]

The validation for AnyErrorDefinition will succeed against any ErrorValue.

Parameters:value (vmware.vapi.data.value.DataValue) – the data value to validate
Return type:list of vmware.vapi.message.Message or None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.BlobDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for binary values

Initialize BlobDefinition

new_value(value='')[source]

Create a new BlobValue

Return type:vmware.vapi.data.value.BlobValue
Returns:Newly created BlobValue
class vmware.vapi.data.definition.BooleanDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for bool values

Initialize BooleanDefinition

new_value(value=False)[source]

Create a new BooleanValue

Return type:vmware.vapi.data.value.BooleanValue
Returns:Newly created BooleanValue
class vmware.vapi.data.definition.DataDefinition(data_type=None)[source]

Bases: object

Base class for all types in the vAPI run-time type system

Variables:type – String representation of the type

Initialize the data definition instance

Parameters:data_type (str) – String representation of the type
accept(visitor)[source]

Applies a visitor to this data-definition.

Parameters:visitor (SimpleDefinitionVisitor) – the visitor operating on this data-definition
complete_value(value)[source]

Fill the optional fields of StructValues. Also includes the StructValues present in other generic types: List and Optional.

Parameters:value (vmware.vapi.data.value.DataValue) – DataValue
valid_instance_of(value)[source]

Validates that the specified vmware.vapi.data.value.DataValue is an instance of this data-definition

Parameters:value (vmware.vapi.data.value.DataValue) – the data value to validate
Return type:bool
Returns:true if the value is an instance of this data-definition, false, otherwise
validate(value)[source]

Validates that the specified vmware.vapi.data.value.DataValue is an instance of this data-definition

Parameters:value (vmware.vapi.data.value.DataValue) – the data value to validate
Return type:list of vmware.vapi.message.Message or None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.DoubleDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for floats

Initialize DoubleDefinition

new_value(value=0.0)[source]

Create a new DoubleValue

Return type:vmware.vapi.data.value.DoubleValue
Returns:Newly created DoubleValue
class vmware.vapi.data.definition.DynamicStructDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for dynamic structs

Initialize DynamicStructDefinition

validate(value)[source]

The validation for DynamicStructDefinition will succeed against any StructValue.

Parameters:value (vmware.vapi.data.value.DataValue) – the data value to validate
Return type:list of vmware.vapi.message.Message or None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.ErrorDefinition(name, fields)[source]

Bases: vmware.vapi.data.definition.StructDefinition

DataDefinition for errors

Initialize ErrorDefinition

Parameters:
  • name (str) – Name of the Error
  • fields (tuple of (str, DataDefinition)) – A tuple consisting of the field name and the field definition for all the fields inside this StructDefinition
new_value()[source]

Create a new ErrorValue

Return type:vmware.vapi.data.value.ErrorValue
Returns:Newly created ErrorValue
class vmware.vapi.data.definition.IntegerDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for long values

Initialize IntegerDefinition

new_value(value=0)[source]

Create a new IntegerValue

Return type:vmware.vapi.data.value.IntegerValue
Returns:Newly created IntegerValue
class vmware.vapi.data.definition.ListDefinition(element_type)[source]

Bases: vmware.vapi.data.definition.DataDefinition

DataDefinition for lists

Initialize ListDefinition

Parameters:element_type (DataDefinition) – DataDefinition of the elements inside ListDefinition
complete_value(value)[source]

Fill the optional values inside StructValues

Parameters:value (vmware.vapi.data.value.DataValue) – DataValue
new_value(values=None)[source]

Create a new ListValue

Parameters:values (list of vmware.vapi.data.value.DataValue) – List of elements
Return type:vmware.vapi.data.value.ListValue
Returns:Newly created ListValue
validate(list_value)[source]

Apart from the validation checks specified in the validate method of DataDefinition class, this method does some additional checks

Validation will fail if any element in the ListValue does not validate against the DataDefinition of the elementType of this ListDefinition

Parameters:other (vmware.vapi.data.value.ListValue) – ListValue to be validated
Return type:list of vmware.vapi.message.Message or None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.OpaqueDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for opaque

Initialize OpaqueDefinition

validate(value)[source]

The validation for OpaqueDefinition will succeed against any DataValue. Only validates that supplied value is not None

Parameters:value (vmware.vapi.data.value.DataValue) – DataValue to be validated
Return type:list of vmware.vapi.message.Message or None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.OptionalDefinition(element_type)[source]

Bases: vmware.vapi.data.definition.DataDefinition

An OptionalDefinition instance defines an optional type with a specified element type

Variables:
  • type – String representation of the type
  • element_type – The type of the element that is optional

Initialize OptionalDefinition

Parameters:element_type (vmware.vapi.data.type.Type) – Type of the DataDefinition
complete_value(value)[source]

Fill the optional values inside StructValues

Parameters:value (vmware.vapi.data.value.OptionalValue) – DataValue
new_value(value=None)[source]

Create and return a new OptionalValue using this optional-definition.

Parameters:value (vmware.vapi.data.value.DataValue) – The element value
Return type:vmware.vapi.data.value.OptionalValue
Returns:A new optional value using the given data-definition
validate(value)[source]

Apart from the validation checks specified in the validate method of DataDefinition class, this method does some additional checks.

Since this is an OptionalValue, validation will succeed if the element value is None. If the element value is not None, validation will fail if element in the OptionalValue does not validate against the DataDefinition of the element_type of this OptionalDefinition.

Parameters:other (vmware.vapi.data.value.OptionalValue) – OptionalValue to be validated
Return type:list of vmware.vapi.message.Message
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.ReferenceResolver[source]

Bases: object

Resolves all the StructRefDefinition objects

Initialize ReferenceResolver

add_definition(definition)[source]

Adds a new structure definition to the context

Parameters:definition (StructDefinition) – StructDefinition
add_reference(reference)[source]

Adds a new structure refernce to the context

Parameters:refernce (StructRefDefinition) – StructRefDefinition
is_defined(name)[source]

Determines whether the context contains a definition for the specified structure

Return type:bool
Returns:True if the structure is already defined, false otherwise
resolve()[source]

Traverses all references and resolves the unresolved ones.

class vmware.vapi.data.definition.SecretDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for Secrets. Only strings are allowed to be secrets.

Initialize SecretDefinition

new_value(value='')[source]

Create a new SecretValue

Return type:vmware.vapi.data.value.SecretValue
Returns:Newly created SecretValue
class vmware.vapi.data.definition.SimpleDefinitionVisitor[source]

Bases: vmware.vapi.lib.visitor.VapiVisitor

Base no-op implementation of a definition visitor

visit_blob(defn)[source]

Visit a BlobDefinition

Parameters:defn (BlobDefinition) – Data definition
visit_boolean(defn)[source]

Visit a BooleanDefinition

Parameters:defn (BooleanDefinition) – Data definition
visit_double(defn)[source]

Visit a DoubleDefinition

Parameters:defn (DoubleDefinition) – Data definition
visit_error(defn)[source]

Visit an ErrorDefinition

Parameters:defn (ErrorDefinition) – Data definition
visit_integer(defn)[source]

Visit a IntegerDefinition

Parameters:defn (IntegerDefinition) – Data definition
visit_list(defn)[source]

Visit a ListDefinition

Parameters:defn (ListDefinition) – Data definition
visit_opaque(defn)[source]

Visit a OpaqueDefinition

Parameters:defn (OpaqueDefinition) – Data definition
visit_optional(defn)[source]

Visit a OptionalDefinition

Parameters:defn (OptionalDefinition) – Data definition
visit_secret(defn)[source]

Visit a SecretDefinition

Parameters:defn (SecretDefinition) – Data definition
visit_string(defn)[source]

Visit a StringDefinition

Parameters:defn (StringDefinition) – Data definition
visit_struct(defn)[source]

Visit a StructDefinition

Parameters:defn (StructDefinition) – Data definition
visit_struct_ref(defn)[source]

Visit a StructRefDefinition

Parameters:defn (StructRefDefinition) – StructRefDefinition object
visit_void(defn)[source]

Visit a VoidDefinition

Parameters:defn (VoidDefinition) – Data definition
class vmware.vapi.data.definition.SingletonDefinition(data_type)[source]

Bases: vmware.vapi.data.definition.DataDefinition

Base class for all the primitive data definition classes. All the derived classes of this class will have only one instance.

Initialize SingletonDefinition

Parameters:data_type (vmware.vapi.data.type.Type) – Type of the DataDefinition
class vmware.vapi.data.definition.StringDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition for strings

Initialize StringDefinition

new_value(value='')[source]

Create a new StringValue

Return type:vmware.vapi.data.value.StringValue
Returns:Newly created StringValue
class vmware.vapi.data.definition.StructDefinition(name, fields, data_type='Structure')[source]

Bases: vmware.vapi.data.definition.DataDefinition

DataDefinition for structures

Initialize StructDefinition

Parameters:
  • name (str) – Name of the Structure
  • fields (tuple of (str, DataDefinition)) – A tuple consisting of the field name and the field definition for all the fields inside this StructDefinition
complete_value(value)[source]

Fill out all the unset optional fields in a structure based on the StructDefinition

Parameters:value (vmware.vapi.data.value.StructValue) – Input Struct Value
get_field(field)[source]

Returns the field definition of the specified field

Return type:DataDefinition
Returns:field definition of the specified field
get_field_names()[source]

Returns the list of field names in this struct definition. The ordering of fields is not preserved.

Return type:list of str
Returns:List of field names in this struct definition
new_value()[source]

Create a new StructValue

Return type:vmware.vapi.data.value.StructValue
Returns:Newly created StructValue
validate(other)[source]

Apart from the validation checks specified in the validate method of DataDefinition class, this method does some additional checks

Validation will fail if - the name of the input StructValue does not match the name of this StructDefinition. - any of the fields (either required or optional) in this StructDefinition are not present in the input StructValue - the validation fails for any field value in the input StructValue with its corresponding definition in this StructDefinition

The method performs inclusive validation. i.e. If there are any extra fields in the input StructValue which are not present in the StructDefinition, validation will not fail.

Parameters:other (vmware.vapi.data.value.StructValue) – StructValue to be validated
Return type:list of vmware.vapi.message.Message of None
Returns:a stack of messages indicating why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.StructRefDefinition(name, definition=None)[source]

Bases: vmware.vapi.data.definition.DataDefinition

Reference to a StructDefinition. If the reference is resolved, it is bound to a specific StructDefinition target. If the reference is unresolved, its target is None.

Variables:name – Structure name

Initialize StructRefDefinition

Parameters:
  • name (str) – Structure name
  • definition (DataDefinition) – If definition is passed, it creates a resolved reference
check_resolved()[source]

Check if the reference is resolved or not

target[source]

Returns the target structure definition of this reference.

Return type:DataDefinition or None
Returns:The target of this reference. The value will be None for unresolved reference
validate(other)[source]

Validate using the target if the reference is resolved

Parameters:other (vmware.vapi.data.value.StructValue) – StructValue to be validated
Return type:list of vmware.vapi.message.Message of None
Returns:a stack of messages indicating that the reference is not resolved or why the value is not an instance of this data-definition, or None if the value is an instance of this data-definition
class vmware.vapi.data.definition.VoidDefinition[source]

Bases: vmware.vapi.data.definition.SingletonDefinition

DataDefinition class for void

Initialize VoidDefinition

new_value()[source]

Create a new VoidValue

Return type:vmware.vapi.data.value.VoidValue
Returns:Newly created VoidValue
vmware.vapi.data.definition.data_definition_factory(data_type, *args, **kwargs)[source]

data definition factory

Parameters:
  • data_type (str) – Type name defined in vmware.vapi.data.type
  • args (set) – Positional arguments to data definition constructor
  • kwargs (dict) – Dict arguments to data definition constructor

type Module

List of Data types supported

class vmware.vapi.data.type.Type[source]

Bases: object

Enum of all the data types used in vAPI Runtime

ANY_ERROR = 'AnyError'
BLOB = 'Blob'
BOOLEAN = 'Boolean'
DOUBLE = 'Double'
DYNAMIC_STRUCTURE = 'DynamicStructure'
ERROR = 'Error'
INTEGER = 'Integer'
LIST = 'List'
OPAQUE = 'Opaque'
OPTIONAL = 'Optional'
SECRET = 'Secret'
STRING = 'String'
STRUCTURE = 'Structure'
STRUCTURE_REF = 'StructureRef'
VOID = 'Void'

validator Module

Data Validator classes

class vmware.vapi.data.validator.HasFieldsOfValidator[source]

Bases: vmware.vapi.data.validator.Validator

HasFieldsOfValidator validator class that validates the data_value has reuired fields of the class specified

validate(data_value, data_type=None)[source]

Validates a struct value for union consistency

:type data_value vmware.vapi.data.value.DataValue :param data_value The struct value that needs to be validated :type data_type vmware.vapi.binding.type.BindingType :param data_type The Struct binding type :rtype: list of vmware.vapi.message.Message or None :return List of error messages if validation fails or None

class vmware.vapi.data.validator.UnionValidator(discriminant_name, case_map)[source]

Bases: vmware.vapi.data.validator.Validator

Union Validator class that validates a struct value for union consistency

Initialize the union validator class

:type discriminant_name str :param discriminant_name Name of a structure field that represents a

union discriminant

:type case_map dict :param case_map Python dict with string value of the discriminant as

dictionary key and list of tuple of structure field associated with it and a boolean representing whether it is rqeuired as dictionary value
validate(data_value, data_type=None)[source]

Validates a struct value for union consistency

:type data_value vmware.vapi.data.value.DataValue :param data_value The struct value that needs to be validated :type data_type vmware.vapi.binding.type.BindingType :param data_type The Struct binding type :rtype: list of vmware.vapi.message.Message or None :return List of error messages if validation fails or None

class vmware.vapi.data.validator.Validator[source]

Bases: object

vAPI Data object validator class This is an abstract class.

validate(data_value, data_type=None)[source]

This method validates a data value

:type data_value vmware.vapi.data.value.DataValue :param data_value The struct value that needs to be validated :type data_type vmware.vapi.binding.type.BindingType :param data_type The Struct binding type :rtype: list of vmware.vapi.message.Message or None :return List of error messages if validation fails or None

value Module

vAPI DataValues

class vmware.vapi.data.value.BlobValue(value='')[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for binary values

Variables:value – Binary present in BlobValue

Initialize BooleanValue

Parameters:value (bytes) – Binary value to be initialized
class vmware.vapi.data.value.BooleanValue(value=False)[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for bool values

Variables:value – Bool present in BooleanValue

Initialize BooleanValue

Parameters:value (bool) – Bool value to be initialized
class vmware.vapi.data.value.ComparableValueMixin[source]

Bases: object

Helper class to implement the rich comparator operations.

class vmware.vapi.data.value.DataValue(data_type=None)[source]

Bases: object

A piece of introspectable value in vAPI infrastructure

Variables:type – Type of DataValue

Initialize DataValue

Parameters:data_type (vmware.vapi.data.type.Type) – Type of DataValue
accept(visitor)[source]

Applies a visitor to this DataValue

Parameters:visitor (SimpleValueVisitor) – visitor operating on this DataValue
class vmware.vapi.data.value.DoubleValue(value=0.0)[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for float values

Variables:value – 64 bit signed float present in DoubleValue

Initialize DoubleValue

Parameters:value (float or decimal.Decimal) – Float or decimal.Decimal value to be initialized
class vmware.vapi.data.value.ErrorValue(name=None, values=None)[source]

Bases: vmware.vapi.data.value.StructValue

DataValue class for Errors

Initialize ErrorValue

Parameters:name (str) – Name of the ErrorValue
class vmware.vapi.data.value.IntegerValue(value=0)[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for integer values

Variables:value – 64 bit signed int present in IntegerValue

Initialize IntegerValue

Parameters:value (int) – Integer value to be initialized
class vmware.vapi.data.value.ListValue(values=None)[source]

Bases: vmware.vapi.data.value.DataValue

DataValue class for lists

Initialize ListValue

add(value)[source]

Add an element to ListValue

Parameters:value (DataValue) – DataValue to be added
add_all(values)[source]

Add all the elements from input list to ListValue

Parameters:values (list of DataValue) – List of DataValues to be added
is_empty()[source]

Returns true if the list is empty

Return type:bool
Returns:True if the list is empty, false otherwise
size()[source]

Returns the size of the list

Return type:int
Returns:Size of the list value
class vmware.vapi.data.value.OptionalValue(value=None)[source]

Bases: vmware.vapi.data.value.DataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for optionals

Variables:value – DataValue present in this OptionalValue

Initialize OptionalValue

Parameters:value (DataValue) – DataValue to be used in OptionalValue
is_set()[source]

Returns true if OptionalValue has a DataValue present in it

Return type:bool
Returns:Returns true if OptionalValue is initialized with some DataValue, false otherwise
class vmware.vapi.data.value.PrimitiveDataValue(*args, **kwargs)[source]

Bases: vmware.vapi.data.value.DataValue

Base class for all primitive DataValues

Variables:value – Primitive value
class vmware.vapi.data.value.SecretValue(value='')[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for secret values. Only strings are allowed to be secrets.

Variables:value – String present in SecretValue

Initialize StringValue

Parameters:value (str) – String value to be initialized
class vmware.vapi.data.value.SimpleValueVisitor[source]

Bases: vmware.vapi.lib.visitor.VapiVisitor

Base no-op implementation of a DataValue visitor

Initialize SimpleValueVisitor

visit_blob(value)[source]

Visit a BlobValue

Parameters:value (BlobValue) – Data value
visit_boolean(value)[source]

Visit a BooleanValue

Parameters:value (BooleanValue) – Data value
visit_double(value)[source]

Visit a DoubleValue

Parameters:value (DoubleValue) – Data value
visit_error(value)[source]

Visit an ErrorValue

Parameters:value (ErrorValue) – Data value
visit_integer(value)[source]

Visit a IntegerValue

Parameters:value (IntegerValue) – Data value
visit_list(value)[source]

Visit a ListValue

Parameters:value (ListValue) – Data value
visit_optional(value)[source]

Visit a OptionalValue

Parameters:value (OptionalValue) – Data value
visit_secret(value)[source]

Visit a SecretValue

Parameters:value (SecretValue) – Data value
visit_string(value)[source]

Visit a StringValue

Parameters:value (StringValue) – Data value
visit_struct(value)[source]

Visit a StructValue

Parameters:value (StructValue) – Data value
visit_void(value)[source]

Visit a VoidValue

Parameters:value (VoidValue) – Data value
class vmware.vapi.data.value.StringValue(value='')[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue, vmware.vapi.data.value.ComparableValueMixin

DataValue class for strings

Variables:value – String present in StringValue

Initialize StringValue

Parameters:value (str) – String value to be initialized
class vmware.vapi.data.value.StructValue(name=None, data_type='Structure', values=None)[source]

Bases: vmware.vapi.data.value.DataValue

DataValue class for Structures

Variables:name – Name of the structure

Initialize StructValue

Parameters:name (str) – Name of the StructValue
get_field(field)[source]

Returns the field value of the field present in the StructValue

Parameters:field (str) – Name of the field
Return type:DataValue
Returns:Returns the field value of the field present in the StructValue
get_field_names()[source]

Returns the list of field names present in this StructValue. The ordering of fields is not preserved.

Return type:list of str
Returns:List of field names present in this StructValue
get_fields()[source]

Returns the map of field names and values present in this StructValue.

Return type:dict of str and DataValue
Returns:Fields in this struct value
has_field(field)[source]

Returns true if the field is present in the StructValue, false otherwise

Parameters:field (str) – Name of the field
Return type:bool
Returns:Returns true if the field is present in the StructValue, false otherwise
keys()[source]

Returns the list of field names

Return type:list or str
Returns:List of field names
set_field(field, value)[source]

Set the field value for the field name passed in the argument

Parameters:
  • field (str) – Name of the field
  • field – Name of the field to be set
  • value (DataValue) – DataValue to be used for the field
class vmware.vapi.data.value.VoidValue[source]

Bases: vmware.vapi.data.value.PrimitiveDataValue

DataValue class for None

Initialize VoidValue

vmware.vapi.data.value.data_value_factory(data_type, *args)[source]

Convenience method to create datavalues

Parameters:
  • data_type (str) – String representation of the data value type
  • args – The argument list to be passed to the data value constructor

Table Of Contents

Previous topic

bindings Package

Next topic

serializers Package

This Page