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::ApiInterfaceStub Class Reference
Inheritance diagram for Com::Vmware::Vapi::Bindings::ApiInterfaceStub:

## Avaliable Methods
public method | get_interface_identifier ()
public method | get_method ()
public method | invoke ()
public method | new ()

## Detailed Description

Defines the interface for generated Stub class

Assumptions:
  None.

Dependencies:
  None.

## Member Function Documentation

public method Com::Vmware::Vapi::Bindings::ApiInterfaceStub::get_interface_identifier | ( |  | ) |

Gets the interface identifier.

Return values

  An interface identifier id. |

Side Effects:
  None

Code:
click to view
# Number of lines of code in get_interface_identifier: 4
sub get_interface_identifier {
my ($self) = shift;
return $self->{iface_id};
}

public method Com::Vmware::Vapi::Bindings::ApiInterfaceStub::get_method | ( |  | ) |

Gets the method name

Parameters

  method_name | - method name needs to be invoked

Return values

  method name | Code: click to view # Number of lines of code in get_method: 6 sub get_method { my ( $self, %params ) = @_; my $methodName = $params{method_name}; return $self->{iface_name} . "::" . ucfirst($methodName) . "Method"; }

public method Com::Vmware::Vapi::Bindings::ApiInterfaceStub::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

  An interface identifier id. |

Side Effects:
  None

Code:
click to view
# Number of lines of code in invoke: 87
sub invoke {
my ( $self, %params ) = @_;
my $ctx = $params{ctx};
my $api_provider = $self->{api_provider};
my $methodName = $params{method_name};
my $methodArgs = $params{method_args};
#
# Get the method meta data from the stub class
#
my $operation = $self->{operations}->{$methodName};
if ( !defined($operation) ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Bindings.ApiInterfaceStub.MethodNameNotFound',
args => [$methodName]
);
throw MethodNameNotFound( $msg->str() );
}
log_debug(MSG => "Converting perl to vAPI data value");
my $dataValue = Com::Vmware::Vapi::Bindings::Type::Converter::convert_to_vapi(
binding_type => $operation->{input_type},
perl_value => $methodArgs
);
log_debug(MSG => "Completed perl to vAPI data value conversion.");
log_dumper(MSG => $dataValue);
#############################################################
# Data Layer Integration
#############################################################
my $methodIdentifier = new Com::Vmware::Vapi::Core::MethodIdentifier(
interface_id => $self->{iface_id},
method => $methodName
);
my $serviceId = $methodIdentifier->get_interface_id();
my $operationId = $methodIdentifier->get_method_name();
my $data = $api_provider->invoke(
service_id => $serviceId,
operation_id => $operationId,
ctx => $ctx,
input => $dataValue
);
my $response = $api_provider->received(
json_response => $data,
output_type => $operation->{output_type},
errors => $operation->{errors}
);
log_dumper( MSG => $response );
my $vAPIDataValue = undef;
my $bindingType = undef;
if ( $response->get_success() eq 1 ) {
$vAPIDataValue = $response->get_output();
$bindingType = $operation->{output_type};
}
else {
$vAPIDataValue = $response->get_error();
#
# Get the class name of the error
#
my $errorClassName = $vAPIDataValue->get_name();
#$bindingType = $operation->{errors}->{$errorClassName};
#$bindingType = $bindingType->get_resolved_type();
my $package = Com::Vmware::Vapi::Util::Helper::get_package_name('name'=> $errorClassName);
$bindingType = $package->new()->get_binding_type();
}
my $perlValue = Com::Vmware::Vapi::Bindings::Type::Converter::convert_to_perl(
binding_type => $bindingType,
data_value => $vAPIDataValue
);
#
# Throw exception if the response is not successful
#
if ( $response->get_success() ne 1 ) {
#Exception::Class::Base->throw( error => $perlValue);
log_warning(MSG=>$perlValue);
die $perlValue;
}
return $perlValue;
}

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

Constructor to initialize the ApiMethod skeleton object

Parameters

  iface_name | - Interface name
  api_provider | - api_provider data for vAPI stubs
  operations | - Hash of operation name to operation information

Return values

  Blessed Object | Code: click to view # Number of lines of code in new: 11 sub new { my ( $class, %params ) = @_; my $self = $class->SUPER::new(); $self->{api_provider} = $params{api_provider}; $self->{iface_name} = $params{iface_name}; $self->{iface_id} = $self->{iface_name}; $self->{operations} = $params{operations}; bless( $self, $class ); log_dumper( MSG => $self ); return ($self); }

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

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