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::Protocol::ProtocolConnectionFactory Class Reference

## Avaliable Methods
private method | _create_http_client_transport ()
public method | get_http_connection ()
public method | get_connection ()
public method | get_insecure_connection ()
public method | new ()

## Detailed Description

Class to allow encapsulation of connections. This is likely a placeholder.

## Member Function Documentation

private method Com::Vmware::Vapi::Protocol::ProtocolConnectionFactory::_create_http_client_transport | ( |  | ) |

Create Http transport client

Parameters

  uri | - URI representing the server to connect. Must not be null. Should be of the form: http(s)://<IP_address>:<port>/<Service_endpoint>.
  http_config | - Com::Vmware::Vapi::Protocol::HttpConfiguration object

Return values

  Com::Vmware::Vapi::Protocol::Client::Rpc::Http::HttpClient | object

Code:
click to view
# Number of lines of code in _create_http_client_transport: 26
sub _create_http_client_transport {
my ( $self, %args ) = @_;
my $uri = $args{'uri'};
my $httpConfig = $args{'http_config'};
if ( !$httpConfig ) {
my $httpBuilder =
Com::Vmware::Vapi::Protocol::HttpConfiguration::Builder->new();
$httpConfig = $httpBuilder->get_config();
}
# TODO: Check 3rd party Library used, if any
# if ( !$httpConfig->{LibraryType} ) {
# if ( $httpConfig->LibraryType eq "3rd_party_lib" ) {
#
# # TODO: Make HttpClient for each library type
# }
my $httpClient =
Com::Vmware::Vapi::Protocol::Client::Rpc::Http::HttpClient->new(
'uri' => $uri,
'http_config' => $httpConfig,
);
return $httpClient;
}

public method Com::Vmware::Vapi::Protocol::ProtocolConnectionFactory::get_connection | ( |  | ) |

Get Secured Protocol Connection of specified type, if CertificatePath info has been passed

Parameters

  protocol_type | - Protocol type [http / https etc]. Must not be null.
  uri | - URI representing the server to connect. Must not be null. Should be of the form: http(s)://<IP_address>:<port>/<Service_endpoint>.
  http_config | [optional] - Com::Vmware::Vapi::Protocol::HttpConfiguration object
  certificate_path | [optional] - Complete certificate [.der file] path

Return values

  Com::Vmware::Vapi::Protocol::ProtocolConnectionImpl | object

Code:
click to view
# Number of lines of code in get_connection: 67
sub get_connection {
my ( $self, %args ) = @_;
my $protocolType = $args{'protocol_type'};
my $uri = $args{'uri'};
my $config = $args{'http_config'};
my $cert = $args{'certificate_path'};
if ( !$protocolType || !$uri ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.InvalidParameter',
args => ['protocol_type and uri']
);
throw InvalidParameter( $msg->str() );
}
if ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTPS )
{
if ( !$cert ) {
$cert = undef;
}
my $httpBuilder =
Com::Vmware::Vapi::Protocol::HttpConfiguration::Builder->new();
my $sslConfig =
Com::Vmware::Vapi::Protocol::HttpConfiguration::SslConfiguration->new(
'trust_store' => $cert );
$httpBuilder->set_ssl_configuration( 'ssl_config_builder' => $sslConfig );
if (defined $config) {
$httpBuilder->set_so_timeout(
'so_timeout_builder' => $config->get_sso_timeout() );
$httpBuilder->set_io_thread_count(
'io_thread_count_builder' => $config->get_io_thread_count() );
$httpBuilder->set_library_type(
'library_type_builder' => $config->get_library_type() );
}
my $httpConfig = $httpBuilder->get_config();
return $self->get_http_connection(
'uri' => $uri,
'client_config' => undef,
'http_config' => $httpConfig,
);
}
elsif ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTP )
{
return $self->get_insecure_connection(
protocol_type => $protocolType,
uri => $uri,
http_config => $config,
);
}
else {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.UnsupportedProtocolTypeException',
args => [ UnsupportedProtocolTypeException->description ]
);
throw UnsupportedProtocolTypeException( $msg->str() );
}
}

public method Com::Vmware::Vapi::Protocol::ProtocolConnectionFactory::get_http_connection | ( |  | ) |

Get Http Connection

Parameters

  uri | - URI representing the server to connect. Must not be null. Should be of the form: http(s)://<IP_address>:<port>/<Service_endpoint>.
  client_config | - Com::Vmware::Vapi::Protocol::ClientConfiguration object
  http_config | - Com::Vmware::Vapi::Protocol::HttpConfiguration object

Return values

  Com::Vmware::Vapi::Protocol::ProtocolConnectionImpl | object

Code:
click to view
# Number of lines of code in get_http_connection: 22
sub get_http_connection {
my ( $self, %args ) = @_;
my $uri = $args{'uri'};
my $httpConfig = $args{'http_config'};
my $clientTransport = $self->_create_http_client_transport(
'uri' => $uri,
'http_config' => $httpConfig,
);
my $provider =
Com::Vmware::Vapi::Protocol::Client::Msg::JsonApiProvider->new(
'uri' => $uri,
'client' => $clientTransport,
'config' => $httpConfig,
);
return Com::Vmware::Vapi::Protocol::ProtocolConnectionImpl->new(
'transport' => $clientTransport,
'provider' => $provider,
);
}

public method Com::Vmware::Vapi::Protocol::ProtocolConnectionFactory::get_insecure_connection | ( |  | ) |

Get insecured Protocol Connection of specified type

Parameters

  protocol_type | - Protocol type [http / https etc]. Must not be null.
  uri | - URI representing the server to connect. Must not be null. Should be of the form: http(s)://<IP_address>:<port>/<Service_endpoint>.
  http_config | [optional] - Com::Vmware::Vapi::Protocol::HttpConfiguration object

Return values

  Com::Vmware::Vapi::Protocol::ProtocolConnectionImpl | object

Code:
click to view
# Number of lines of code in get_insecure_connection: 54
sub get_insecure_connection {
my ( $self, %args ) = @_;
my $protocolType = $args{'protocol_type'};
my $uri = $args{'uri'};
my $config = $args{'http_config'};
if ( !$uri ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.InvalidParameter',
args => ['uri']
);
throw InvalidParameter( $msg->str() );
}
if ( !$protocolType ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.InvalidParameter',
args => ['protocol_type']
);
throw InvalidParameter( $msg->str() );
}
if ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTP )
{
return $self->get_http_connection(
'uri' => $uri,
'http_config' => $config,
);
}
elsif ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTPS )
{
return $self->get_connection(
'protocol_type' => 'https',
'uri' => $uri,
'http_config' => $config,
);
}
else {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.UnsupportedProtocolTypeException',
args => [ UnsupportedProtocolTypeException->description ]
);
throw UnsupportedProtocolTypeException( $msg->str() );
}
}

public method Com::Vmware::Vapi::Protocol::ProtocolConnectionFactory::new | ( |  | ) |

Constructor

Parameters

  None |

Return values

  Blessed object | Code: click to view # Number of lines of code in new: 6 sub new { my ( $class, %args ) = @_; my $self = {}; return bless( $self, $class ); }

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

- Com/Vmware/Vapi/Protocol/ProtocolConnectionFactory.pm