vmware.vapi package¶
Subpackages¶
Submodules¶
vmware.vapi.core module¶
Core Protocol Definition classes
- 
class 
vmware.vapi.core.ApiInterface¶ Bases:
objectThe ApiInterface interface provides introspection APIs for a vAPI interface; it is implemented by API providers.
Initialize the Api Interface instance
- 
get_definition()¶ Returns interface definition
Return type: InterfaceDefinitionReturns: Interface definition 
- 
get_identifier()¶ Returns interface identifier
Return type: InterfaceIdentifierReturns: Interface identifier 
- 
get_method_definition(method_id)¶ Returns the method definition
Return type: MethodDefinitionReturns: Method definition 
- 
invoke(ctx, method_id, input_value)¶ Invokes the specified method using the execution context and the input provided
Parameters: - ctx (
ExecutionContext) – Execution context for this method - method_id (
MethodIdentifier) – Method identifier - input_value (
vmware.vapi.data.value.StructValue) – Method input parameters 
Return type: Returns: Result of the method invocation
- ctx (
 
- 
 
- 
class 
vmware.vapi.core.ApiProvider¶ Bases:
objectThe ApiProvider interface is used for invocation of operations
- 
invoke(service_id, operation_id, input_value, ctx)¶ Invokes the specified method using the input value and the the execution context provided
Parameters: - service_id (
str) – Service identifier - operation_id (
str) – Operation identifier - input_value (
vmware.vapi.data.value.StructValue) – Input parameters for the method - ctx (
ExecutionContext) – Execution context for the method 
Return type: Returns: Result of the method invocation
- service_id (
 
- 
 
- 
class 
vmware.vapi.core.ApplicationContext(*args, **kwargs)¶ Bases:
vmware.vapi.core.CustomDictInterface representing additional data associated with the request for method execution represented by this ExecutionContext. The additional data format is key-value pairs of String.
This additional data is provided by the client initiating the execution, it is then transported as is over the wire and is available for the provider-side service implementations on the server. This extra data is completely opaque for the infrastructure, in other words it is a contract between the client and the service implementation only.
- 
class 
vmware.vapi.core.CustomDict¶ Bases:
dictInterface for implementing Custom dict classes with additional constraints.
Overriding __setitem__ as not enough for adding additional constraints on key/value pairs of dictionaries. We also have to override update and setdefault, so that even they use __setitem__.
- 
setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶ 
- 
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 
 
- 
class 
vmware.vapi.core.ExecutionContext(application_context=None, security_context=None)¶ Bases:
objectThis class provides out-of-band context information that is passed along with a method invocation
Initialize Execution Context
- 
class 
vmware.vapi.core.InterfaceDefinition(id_, method_ids)¶ Bases:
objectThe InterfaceDefinition class contains detailed information about a vAPI interface. This should contain all the information required to address an interface in the vAPI runtime.
Initialize the InterfaceDefinition
Parameters: - id (
InterfaceIdentifier) – InterfaceIdentifier of this interface - method_ids (
listofMethodIdentifier) – List of method identifiers of the methods exposed by this interface 
- 
get_identifier()¶ Returns the interface identifier
Return type: InterfaceIdentifierReturns: Returns the interface identifer of this interface 
- 
get_method_identifiers()¶ Returns the list of method identifiers of the methods exposed by this interface. Each method identifier is unique within an interface. The method identifiers returned are unordered
Return type: listofMethodIdentifierReturns: List of method identifiers of the methods exposed by this interface 
- id (
 
- 
class 
vmware.vapi.core.InterfaceIdentifier(iface)¶ Bases:
objectInterfaceIdentifier has the information required to uniquely address a vAPI interface
Initialize an InterfaceIdentifier
Parameters: iface ( str) – String identifier of the interface- 
get_name()¶ Returns the string identifier of the interface
Return type: strReturns: String identifier of the interface 
- 
 
- 
class 
vmware.vapi.core.MethodDefinition(id_, input_, output, errors)¶ Bases:
objectThis class contains detailed information about a vAPI method. This should contain all the information required to address a method in the vAPI runtime.
Initialize MethodDefinition
Parameters: - id (
MethodIdentifier) – MethodIdentifier of this method - input (
vmware.vapi.data.definition.StructDefinition) – Struct definition corresponding to the method’s input parameters - output (
vmware.vapi.data.definition.DataDefinition) – Data definition of the method’s output - errors (iterable of
vmware.vapi.data.definition.ErrorDefinition) – Error definitions describing the errors that this method can report 
- 
get_error_definition(error_name)¶ Returns the error definition with the specified name reported by this method or None if this method doesn’t report an error with the specified name.
Parameters: error_name ( str) – Name of the error definition to returnReturn type: vmware.vapi.data.definition.ErrorDefinitionReturns: Error definition with the specified name reported by this method or None if this method doesn’t report an error with the specified name. 
- 
get_error_definitions()¶ Returns a set of error definitions describing the errors that this method can report
Return type: setofvmware.vapi.data.definition.ErrorDefinitionReturns: Set of error definitions describing the errors that this method can report 
- 
get_identifier()¶ Returns the method identifier
Return type: MethodIdentifierReturns: MethodIdentifier of this method 
- 
get_input_definition()¶ Returns the struct definition corresponding to the method’s input parameters. The field names in the struct definition are the parameter names and the field values correspond to the data definition of the respective fields.
Return type: vmware.vapi.data.definition.StructDefinitionReturns: StructDefinition correspoding to the method’s input 
- 
get_output_definition()¶ Returns the data definition of the method’s output
Return type: vmware.vapi.data.definition.DataDefinitionReturns: Data definition of the method’s output 
- id (
 
- 
class 
vmware.vapi.core.MethodIdentifier(iface, method)¶ Bases:
objectThis class identifies a
ApiMethodinstanceInitialize the MethodIdentifier
Parameters: - iface (
InterfaceIdentifier) – InterfaceIdentifier of this method - method (
str) – String identifier of this method 
- 
get_interface_identifier()¶ Returns the interface identifier of the method
Return type: InterfaceIdentifierReturns: InterfaceIdentifier of this method 
- 
get_name()¶ Returns the string identifier of the method
Return type: strReturns: String identifier of the method 
- iface (
 
- 
class 
vmware.vapi.core.MethodResult(output=None, error=None)¶ Bases:
objectThe MethodResult class contains the result of a method call. It contains either the output of the method invocation or an error reported by the method invocation. These are mutually exclusive.
Variables: Initialize MethodResult
Parameters: - output (
vmware.vapi.data.value.DataValue) – Method output - error (
vmware.vapi.data.value.ErrorValue) – Method error 
- 
error¶ Return type: vmware.vapi.data.value.ErrorValueReturns: Method error 
- 
output¶ Return type: vmware.vapi.data.value.DataValueReturns: Method output 
- 
success()¶ Check if the method completed successfully.
Return type: boolReturns: False if the method reported an error, True otherwise 
- output (
 
- 
class 
vmware.vapi.core.ProviderDefinition(name)¶ Bases:
objectThe ProviderDefinition class contains details information about a vAPI provider
Initialize the ProviderDefinition
Parameters: name ( str) – Name of the provider- 
get_identifier()¶ Returns the provider identifier.
Return type: strReturns: Provider identifier 
- 
 
- 
class 
vmware.vapi.core.SecurityContext(*args, **kwargs)¶ Bases:
vmware.vapi.core.CustomDictImplementations of this interface will provide all needed data for authentication for the given invocation.
vmware.vapi.exception module¶
vAPI CoreException Class
- 
exception 
vmware.vapi.exception.CoreException(message, cause=None)¶ Bases:
ExceptionThis exception is raised by various components of the vAPI runtime infrastructure to indicate failures in that infrastructure.
Server-side the exception is caught by specific components and an internal_server_error is reported to the client that invoked the request. Client-side the exception may be raised for certain failures before a request was sent to the server or after the response was received from the server. Similarly, server-side the exception may be raised for failures that occur when a provider implementation invokes the vAPI runtime.
This exception is not part of the vAPI message protocol, and it must never be raised by provider implementations.
Variables: messages – Generator of error messages describing why the Exception was raised Initialize CoreException
Parameters: message ( vmware.vapi.message.Message) – Description regarding why the Exception was raised- 
messages¶ Return type: generator of vmware.vapi.message.MessageReturns: Generator of error messages describing why the Exception was raised 
- 
 
vmware.vapi.message module¶
vAPI Message class
- 
class 
vmware.vapi.message.Message(id_, def_msg, *args)¶ Bases:
objectThis class encapsulates the concept of a localizable message.
Variables: - id – The unique message identifier
 - def_msg – An english language default
 - args – The arguments to be used for the messsage
 
Initializes the message object
Parameters: - id (
string) – The unique message identifier - def_msg (
string) – An english language default - args (
listofstring) – The arguments to be used for the messsage 
- 
class 
vmware.vapi.message.MessageBundle(messages)¶ Bases:
objectBase class for all message bundle classes.
Initialize MessageBundle.
Parameters: messages ( dictofstr,str) – Dictionary with message identifiers as keys and message templates as values.- 
get(msg_id)¶ Returns the message template for the given message identifier
Parameters: msg_id ( str) – Message identifierReturn type: strReturns: Message template Raises: KeyError – If the message identifier is not found 
- 
 
- 
class 
vmware.vapi.message.MessageFactory(msg_bundle, formatter)¶ Bases:
objectA factory class to generate localizable messages
Initializes the message object
Parameters: - messages – The message dictionary for the message factory
 - formatter (
vmware.vapi.formatter.MessageFormatter) – Formatter for the message 
- 
get_message(id_, *args)¶ Return a message object for the given id with the given args. If the message is not found, a default unknown message is returned.
Parameters: - id (string) – The unique message identifier
 - args (
listofobject) – The arguments to be used for constructing this message 
Return type: Returns: The message object constructed using the given arguments
- 
class 
vmware.vapi.message.MessageFormatter¶ Bases:
objectBase class for all message formatter classes
- 
classmethod 
format_msg(msg, args)¶ Format the message using the specified arguments
Parameters: - msg (
str) – Message template - args (
listofobject) – Arguments for the message 
Return type: strReturns: Localized message
- msg (
 
- 
classmethod