# Number of lines of code in validate_args: 54
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;
}