VMware vSphere Automation SDK Perl The VMware vSphere Automation SDK for Perl supports the client-side vSphere Automation API for access to vSphere services and capabilities

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions
List of all members
Com::Vmware::Vapi::Bindings::VapiInterface Class Reference
Inheritance diagram for Com::Vmware::Vapi::Bindings::VapiInterface:

## Avaliable Methods
private method | _build_default_security_context ()
private method | _build_default_app_data ()
public method | invoke ()
public method | new ()
public method | validate_args ()

## Detailed Description

vAPI Interface class is used by the python client side bindings. This encapsulates the ApiInterfaceStub instance

Assumptions:
  None.

Dependencies:
  None.

## Member Function Documentation

private method Com::Vmware::Vapi::Bindings::VapiInterface::_build_default_app_data | ( |  | ) |

[Private Method] Method to generate randon UUID to be used in JSON-RPC 2.0 requests and pass it into ApplicationData instance.

Parameters

  None |

Return values

  ApplicationData object | Code: click to view # Number of lines of code in _build_default_app_data: 6 sub _build_default_app_data { my $uuid = UUID::Random::generate; my $data = {}; $data->{op_id} = $uuid; return new Com::Vmware::Vapi::Core::ApplicationData( app_data => $data ); }

private method Com::Vmware::Vapi::Bindings::VapiInterface::_build_default_security_context | ( |  | ) |

[Private Method] Responsible for building security context and passing SAML related stuffs

Parameters

  None |

Return values

  SecurityContextProcessor object,if | user explicitly sets the parameter 'saml_token_security_context' on current object
  undef otherwise | Code: click to view # Number of lines of code in _build_default_security_context: 48 sub _build_default_security_context { my ( $self, %args ) = @_; my $invocationConfig = $args{invocation_config}; my $stubConfig = $self->{stub_config}; my $securityContext = $stubConfig->get_security_context(); if ( !$securityContext ) { return undef; } # finding the securitycontext type if ( $securityContext->isa( 'Com::Vmware::Vapi::Security::SessionSecurityContext') ) { return new Com::Vmware::Vapi::Dsig::Json::JsonSessionProcessor( 'session_security_context' => $securityContext ); } my $samlToken = $securityContext->get_property( key => "saml_token" ); my $privateKey = $securityContext->get_property( key => "private_key" ); my $signingProcessor = new Com::Vmware::Vapi::Dsig::Json::JsonSigningProcessor( 'private_key' => $privateKey ); $signingProcessor->create_default_timestamp(); # Manipulating 'scheme-id' attribute my $signVeriyProcessor = new Com::Vmware::Vapi::Dsig::Json::JsonSignatureVerificationProcessor(); $signVeriyProcessor->create_default_scheme_id( saml_token_security_context => $securityContext ); # Manipulating 'signature' attribute my $signStruct = new Com::Vmware::Vapi::Dsig::Json::JsonSignatureStruct(); $signStruct->create_default_alg( saml_token_security_context => $securityContext ); #$signature->createDefaultValue( # saml_token_security_context => $securityContext ); $signStruct->set_saml_token( saml_token => $samlToken ); return new Com::Vmware::Vapi::Dsig::Json::SecurityContextProcessor( json_signing_processor => $signingProcessor, json_signature_verification_processor => $signVeriyProcessor, json_signature_struct => $signStruct ); }

public method Com::Vmware::Vapi::Bindings::VapiInterface::invoke | ( |  | ) |

Invokes the ApiMethod corresponding to the given method name with the args

Parameters

  method_name | - Method name needs to be invoked
  method_args | - Method arguments

Return values

  Method result | Code: click to view # Number of lines of code in invoke: 21 sub invoke { my ( $self, %args ) = @_; my $methodName = $args{method_name}; my $methodArgs = $args{method_args}; my $invocationConfig = $args{login_context}; my $ctx = new Com::Vmware::Vapi::Core::ExecutionContext( wire_data => $self->_build_default_app_data(), security_context => $self->_build_default_security_context( invocation_config => $invocationConfig ) ); my $retValue = $self->{api_interface_stub}->invoke( ctx => $ctx, method_name => $methodName, method_args => $methodArgs ); return $retValue; }

public method Com::Vmware::Vapi::Bindings::VapiInterface::new | ( |  | ) |

Constructor to initialize the VapiInterface object

Parameters

  api_provider | - protocol connection to use with stubs created by this factory
  stub_config | - Stub's additional configuration

Return values

  Blessed object | Code: click to view # Number of lines of code in new: 14 sub new { my ( $class, %args ) = @_; my $self = {}; $self->{stub_config} = $args{stub_config}; $self->{api_provider} = $args{api_provider}; my $stubName = caller() . "Stub"; $self->{api_interface_stub} = $stubName->new( 'api_provider' => $self->{api_provider} ); bless( $self, $class ); return ($self); }

public method Com::Vmware::Vapi::Bindings::VapiInterface::validate_args | ( |  | ) |

Validate the args passed to a vAPI method

Parameters

  method_name | - Name of the method
  method_args | - Arguments of the method

Code:
click to view
# Number of lines of code in validate_args: 54
sub validate_args {
my ( $self, %args ) = @_;
my $methodName = $args{method_name};
my $methodArgs = $args{method_args};
if ( !defined( $self->{api_interface_stub}->{operations}->{$methodName} ) ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Bindings.VapiInterface.InvalidMethod',
args => [$methodName]
);
throw InvalidMethod( $msg->str() );
}
#
# Iterate each mandatory parameters defined in the stub and throw exception,
# if the mandatory parameter is not passed.
#
my $inputType = $self->{api_interface_stub}->{operations}->{$methodName}->{input_type};
my %argsHash = %$methodArgs;
my @inputFieldNames = $inputType->get_field_names();
while (@inputFieldNames) {
my $field = pop(@inputFieldNames);
my $type = $inputType->get_field($field);
if ( !defined( $argsHash{$field} )
&& !$type->isa('Com::Vmware::Vapi::Bindings::Type::OptionalType') )
{
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Bindings.VapiInterface.MandatoryParameterMissing',
args => [$field, $methodName]
);
throw InvalidParameter( $msg->str() );
}
delete $argsHash{$field};
}
#
# Check any parameters are passed which are not supported by the given method.
#
if ( scalar( keys %argsHash ) > 0 ) {
my $tostr = join( ' , ', keys(%argsHash) );
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Bindings.VapiInterface.InvalidParameter',
args => [$tostr, $methodName]
);
throw InvalidParameter( $msg->str() );
}
return;
}

The documentation for this class was generated from the following file:

- Com/Vmware/Vapi/Bindings/VapiInterface.pm