Serializer vAPI data values to clean (human readable/writable) json documents
Bases: object
Converter class that converts values from vAPI DataValue to clean JSON objects.
Convert the given data value to a JSON string representation
| Parameters: | data_value (vmware.vapi.data.value.DataValue) – Data value to be converted |
|---|---|
| Return type: | str |
| Returns: | JSON representation of the data value |
Bases: json.encoder.JSONEncoder
Custon JSON encoder that converts vAPI runtime values directly into JSON string representation.
Encode a given vAPI runtime object
| Parameters: | value (object) – vAPI runtime object |
|---|---|
| Return type: | str |
| Returns: | JSON string |
Visit BlobValue
| Parameters: | value (vmware.vapi.data.value.BlobValue) – BlobValue 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 DoubleValue object
| Parameters: | value (vmware.vapi.data.value.DoubleValue) – Double value 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 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 a StructValue object
| Parameters: | value (vmware.vapi.data.value.StructValue) – Struct value object |
|---|---|
| Return type: | str |
| Returns: | JSON string |
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: 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
Custom 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 |
Visit BlobValue
| Parameters: | value (vmware.vapi.data.value.BlobValue) – BlobValue 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 SecretValue
| Parameters: | value (vmware.vapi.data.value.SecretValue) – 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 |
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 |