Convenient libraries for introspection data
Convert vmware.vapi.data.definition.DataDefinition object to vmware.vapi.data.value.DataValue object. The type of the object returned is a struct value that corresponds to DataDefinition VMODL2 type present in introspection service.
Parameters: | data_def (vmware.vapi.data.definition.DataDefinition) – Data definition |
---|---|
Return type: | vmware.vapi.data.value.DataValue |
Returns: | Data value representing the data definition object |
Convert vmware.vapi.data.value.DataValue object that corresponds to DataDefinition structure in introspection VMODL2 into vmware.vapi.data.definition.DataDefinition object.
Parameters: | data_value (vmware.vapi.data.value.DataValue) – Data value representing the data definition object |
---|---|
Return type: | vmware.vapi.data.definition.DataDefinition |
Returns: | Data definition |
Json rpc de/serializer
Bases: json.encoder.JSONEncoder
Class that adds capability of encoding decimal in JSON
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is False, then it is a TypeError to attempt encoding of keys that are not str, int, long, float or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is True, the output is guaranteed to be str objects with all incoming unicode characters escaped. If ensure_ascii is false, the output will be unicode object.
If check_circular is True, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.
If allow_nan is True, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is True, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be a (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘). To get the most compact JSON representation you should specify (‘,’, ‘:’) to eliminate whitespace.
If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.
If encoding is not None, then all input strings will be transformed into unicode using that encoding prior to JSON-encoding. The default is UTF-8.
Bases: vmware.vapi.data.serializers.jsonrpc.JsonRpcError
json rpc 2.0 error
Json rpc 2.0 error
Parameters: |
|
---|
Bases: vmware.vapi.data.serializers.jsonrpc.JsonRpcRequest
Json rpc 2.0 request
Json rpc 2.0 request init
Parameters: |
|
---|
Serialize a json rpc 2.0 notification
Return type: | str |
---|---|
Returns: | json rpc notification str |
Validate a json rpc 2.0 response. Check for version / id mismatch with request
Parameters: | response (JsonRpcResponse) – json rpc response object to validate |
---|
Bases: vmware.vapi.data.serializers.jsonrpc.JsonRpcResponse
Json rpc 2.0 response
Json rpc 2.0 response init Either result or error must be set, but not both
Parameters: |
|
---|
Bases: object
Json rpc dict to vapi type
Json rpc dict to vapi type init
get application context from jsonrpc dict
Parameters: | ctx (dict) – json application context |
---|---|
Return type: | str |
Returns: | operation identifier |
get data value from new jsonrpc dict
# TODO: Structure names and its fields are converted from # u’’ format to str format. This will break if we allow non # ASCII characters in the IDL
Parameters: | value (dict) – json data value |
---|---|
Return type: | subclass of vmware.vapi.data.value.DataValue |
Returns: | subclass of data value |
get error value from jsonrpc dict
Parameters: | msg (dict) – json error value |
---|---|
Return type: | vmware.vapi.data.value.ErrorValue |
Returns: | error value |
get execution context from jsonrpc dict
Parameters: | ctx (dict) – json execution context |
---|---|
Return type: | vmware.vapi.core.ExecutionContext |
Returns: | execution context |
get method result from jsonrpc dict
Parameters: | result (dict) – json method result |
---|---|
Return type: | vmware.vapi.core.MethodResult |
Returns: | method result |
get security context from jsonrpc dict
Parameters: | ctx (dict) – json security context |
---|---|
Return type: | vmware.vapi.core.SecurityContext |
Returns: | json user session |
Bases: exceptions.Exception
json rpc error base class
json rpc error base class constructor
Parameters: | error (dict) – json rpc error |
---|
Bases: object
Json rpc request base class
Json rpc request base class constructor
Parameters: |
|
---|
Validate a json rpc response. Check for version / id mismatch with request
Parameters: | response (JsonRpcResponse) – json rpc response object to validate |
---|
Bases: object
Json rpc response base class
Json rpc response base class constructor
Parameters: |
|
---|
Bases: json.encoder.JSONEncoder
Custon JSON encoder that converts vAPI runtime types directly into JSON string representation.
Encode a given vAPI runtime object
Parameters: | value (object) – vAPI runtime object |
---|---|
Return type: | str |
Returns: | JSON string |
This is the default visit method if the type of the input value does not match any type in the keys present in dispatch map.
Parameters: | value (object) – Python object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a dictionary. Application context and Security Context in vAPI is a free form object, so it can contain a dictionary.
Parameters: | value (dict) – Dictionary value |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a DoubleValue object
Parameters: | value (vmware.vapi.data.value.DoubleValue) – Double value object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit an ExecutionContext object
Parameters: | value (vmware.vapi.core.ExecutionContext) – ExecutionContext object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a ListValue object
Parameters: | value (vmware.vapi.data.value.ListValue) – List value object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a MethodResult object
Parameters: | value (vmware.vapi.core.MethodResult) – MethodResult object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a OptionalValue object
Parameters: | value (vmware.vapi.data.value.OptionalValue) – Optional value object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit one of StringValue, IntegerValue, BooleanValue or VoidValue
Parameters: | value (vmware.vapi.data.value.StringValue (or) vmware.vapi.data.value.IntegerValue (or) vmware.vapi.data.value.BooleanValue (or) vmware.vapi.data.value.VoidValue (or)) – StringValue, IntegerValue, BooleanValue or VoidValue object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit one of BlobValue or SecretValue
Parameters: | value (vmware.vapi.data.value.BlobValue (or) vmware.vapi.data.value.SecretValue) – BlobValue or SecretValue object |
---|---|
Return type: | str |
Returns: | JSON string |
Visit a StructValue object
Parameters: | value (vmware.vapi.data.value.StructValue) – Struct value object |
---|---|
Return type: | str |
Returns: | JSON string |
Canonicalize double based on XML schema double canonical format
The exponent must be indicated by “E”. Leading zeroes and the preceding optional “+” sign are prohibited in the exponent. If the exponent is zero, it must be indicated by “E0”. For the mantissa, the preceding optional “+” sign is prohibited and the decimal point is required. Leading and trailing zeroes are prohibited subject to the following: number representations must be normalized such that there is a single digit which is non-zero to the left of the decimal point and at least a single digit to the right of the decimal point unless the value being represented is zero. The canonical representation for zero is 0.0E0 http://www.w3.org/TR/xmlschema-2/#double
Parameters: | o (decimal.Decimal) – Decimal object to be canonicalized |
---|---|
Return type: | str |
Returns: | Canonical string representation of the decimal |
Deserialize a json rpc request
Parameters: | request_str (str or bytes: or file) – json rpc request str or a file like object |
---|---|
Return type: | JsonRpcRequest |
Returns: | json rpc request |
Deserialize a json rpc response
Parameters: | response_str (str or bytes) – json rpc response str |
---|---|
Return type: | JsonRpcResponse |
Returns: | json rpc response |
Json rpc request factory For json 2.0: set jsonrpc to ‘2.0’ For json 1.1: set version to ‘1.1’ For json 1.0: set neither jsonrpc / version The parameters accepted depends on json version See corresponding json rpc request class for init parameters
Parameters: |
|
---|---|
Return type: | |
Returns: | json rpc request object |
Json rpc response factory For json 2.0: set jsonrpc to ‘2.0’ For json 1.1: set version to ‘1.1’ For json 1.0: set neither jsonrpc / version The parameters accepted depends on json version See corresponding json rpc response class for init parameters
Parameters: |
|
---|---|
Return type: | |
Returns: | json rpc response object |
Convert a unicode key dict into str key dict
Parameters: | dictionary (dict) – unicode dictionary |
---|---|
Return type: | dict |
Returns: | string key dict |
vapi json rpc internal error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc invalid params error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc invalid request error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc method not found error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc parse error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc transport error
Parameters: | data (dict) – json rpc error object |
---|---|
Return type: | JsonRpcError |
Returns: | json rpc error object |
vapi json rpc notification factory
Parameters: |
|
---|---|
Return type: | |
Returns: | json rpc request object |
Json rpc request factory
Parameters: |
|
---|---|
Return type: | |
Returns: | json rpc request object |
vapi json rpc response factory
Parameters: |
|
---|---|
Return type: | |
Returns: | json rpc response object |
Convenience methods to convert to/from python native values to data values
Converts a native python value to data value using the provided data definition
Parameters: |
|
---|---|
Return type: | |
Returns: | Data value |
” Converts a data value to python native value impl input is required to create Struct class instances
Parameters: |
|
---|---|
Return type: | object |
Returns: | Native python value |