vmware.vapi package
Subpackages
Submodules
vmware.vapi.core module
Core Protocol Definition classes
- class vmware.vapi.core.ApiInterface
- Bases: - object- The 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
- Returns
- Interface definition 
 
 - get_identifier()
- Returns interface identifier - Return type
- Returns
- Interface identifier 
 
 - get_method_definition(method_id)
- Returns the method definition - Return type
- Returns
- 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 
 
 
- class vmware.vapi.core.ApiProvider
- Bases: - object- The ApiProvider interface is used for invocation of operations - abstract 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 
 
 
- class vmware.vapi.core.ApplicationContext(*args, **kwargs)
- Bases: - vmware.vapi.core.CustomDict- Interface 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: - dict- Interface 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(key, val=None)
- Insert key with a value of default if key is not in the dictionary. - Return the value for key if key is in the dictionary, else default. 
 - 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, runtime_data=None)
- Bases: - object- This 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: - object- The 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 ( - listof- MethodIdentifier) – List of method identifiers of the methods exposed by this interface
 
 - get_identifier()
- Returns the interface identifier - Return type
- Returns
- 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
- listof- MethodIdentifier
- Returns
- List of method identifiers of the methods exposed by this interface 
 
 
- class vmware.vapi.core.InterfaceIdentifier(iface)
- Bases: - object- InterfaceIdentifier 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
- str
- Returns
- String identifier of the interface 
 
 
- class vmware.vapi.core.MethodDefinition(id_, input_, output, errors)
- Bases: - object- This 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 return
- Return type
- vmware.vapi.data.definition.ErrorDefinition
- Returns
- 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
- setof- vmware.vapi.data.definition.ErrorDefinition
- Returns
- Set of error definitions describing the errors that this method can report 
 
 - get_identifier()
- Returns the method identifier - Return type
- Returns
- 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.StructDefinition
- Returns
- 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.DataDefinition
- Returns
- Data definition of the method’s output 
 
 
- class vmware.vapi.core.MethodIdentifier(iface, method)
- Bases: - object- This class identifies a - ApiMethodinstance- Initialize 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
- Returns
- InterfaceIdentifier of this method 
 
 - get_name()
- Returns the string identifier of the method - Return type
- str
- Returns
- String identifier of the method 
 
 
- class vmware.vapi.core.MethodResult(output=None, error=None)
- Bases: - object- The 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
- output – Method output 
- error – Method error 
 
 - Initialize MethodResult - Parameters
- output ( - vmware.vapi.data.value.DataValue) – Method output
- error ( - vmware.vapi.data.value.ErrorValue) – Method error
 
 - property error
- Return type
- vmware.vapi.data.value.ErrorValue
- Returns
- Method error 
 
 - property output
- Return type
- vmware.vapi.data.value.DataValue
- Returns
- Method output 
 
 - success()
- Check if the method completed successfully. - Return type
- bool
- Returns
- False if the method reported an error, True otherwise 
 
 
- class vmware.vapi.core.ProviderDefinition(name)
- Bases: - object- The 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
- str
- Returns
- Provider identifier 
 
 
- class vmware.vapi.core.RuntimeData(*args, **kwargs)
- Bases: - vmware.vapi.core.CustomDict- Implementations of this interface will provide custom runtime data. 
- class vmware.vapi.core.SecurityContext(*args, **kwargs)
- Bases: - vmware.vapi.core.CustomDict- Implementations 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: - Exception- This 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
 - property messages
- Return type
- generator of - vmware.vapi.message.Message
- Returns
- 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: - object- This 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 ( - listof- string) – The arguments to be used for the messsage
 
 
- class vmware.vapi.message.MessageBundle(messages)
- Bases: - object- Base class for all message bundle classes. - Initialize MessageBundle. - Parameters
- messages ( - dictof- str,- 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 identifier
- Return type
- str
- Returns
- Message template 
- Raises
- KeyError – If the message identifier is not found 
 
 
- class vmware.vapi.message.MessageFactory(msg_bundle, formatter)
- Bases: - object- A 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 ( - listof- object) – 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: - object- Base class for all message formatter classes - classmethod format_msg(msg, args)
- Format the message using the specified arguments - Parameters
- msg ( - str) – Message template
- args ( - listof- object) – Arguments for the message
 
- Return type
- str
- Returns
- Localized message