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
Classes | List of all members
Com::Vmware::Cis::Session Class Reference
Inheritance diagram for Com::Vmware::Cis::Session:

## Classes
class | Info

## Avaliable Methods
public method | create ()
public method | get ()
public method | delete ()
public method | new ()

## Detailed Description

The `Com::Vmware::Cis::Session` interface allows API clients to manage session tokens including creating, deleting and obtaining information about sessions.

- The :func:`Com::Vmware::Cis::Session.create` method creates session token in exchange for another authentication token.
- The :func:`Com::Vmware::Cis::Session.delete` method invalidates a session token.
- The :func:`Com::Vmware::Cis::Session.get` retrieves information about a session token.

The call to the :func:`Com::Vmware::Cis::Session.create` method is part of the overall authentication process for API clients. For example, the sequence of steps for establishing a session with SAML token is:

- Connect to lookup service.
- Discover the secure token service (STS) endpoint URL.
- Connect to the secure token service to obtain a SAML token.
- Authenticate to the lookup service using the obtained SAML token.
- Discover the API endpoint URL from lookup service.
- Call the :func:`Com::Vmware::Cis::Session.create` method . The :func:`Com::Vmware::Cis::Session.create` call must include the SAML token.

See the programming guide and samples for additional information about establishing API sessions.

Execution Context and Security Context

To use session based authentication a client should supply the session token obtained through the :func:`Com::Vmware::Cis::Session.create` method . The client should add the session token in the security context when using SDK classes. Clients using the REST API should supply the session token as a HTTP header.

Session Lifetime

A session begins with call to the :func:`Com::Vmware::Cis::Session.create` method to exchange a SAML token for a API session token. A session ends under the following circumstances:

- Call to the :func:`Com::Vmware::Cis::Session.delete` method .
- The session expires. Session expiration may be caused by one of the following situations:
  - Client inactivity - For a particular session identified by client requests that specify the associated session ID, the lapsed time since the last request exceeds the maximum interval between requests.
  - Unconditional or absolute session expiration time: At the beginning of the session, the session logic uses the SAML token and the system configuration to calculate absolute expiration time.

When a session ends, the authentication logic will reject any subsequent client requests that specify that session. Any operations in progress will continue to completion.

Error Handling

The class Com::Vmware::Cis::Session returns the following errors :

- class Com::Vmware::Vapi::Std::Errors::Unauthenticated error for any errors* related to the request.
- class Com::Vmware::Vapi::Std::Errors::ServiceUnavailable error for all errors* caused by internal service failure.

## Member Function Documentation

public method Com::Vmware::Cis::Session::create | ( |  | ) |

Creates a session with the API. This is the equivalent of login. This method exchanges user credentials supplied in the security context for a session identifier that is to be used for authenticating subsequent calls. To authenticate subsequent calls clients are expected to include the session key.

Return values

  Newly | created session identifier to be used for authenticating further requests. The return type will be str

Exceptions

  Com::Vmware::Vapi::Std::Errors::Unauthenticated | if the session creation fails due to request specific issues. Due to the security nature of the API the details of the error are not disclosed.

Please check the following preconditions if using a SAML token to authenticate:

- the supplied token is delegate-able.
- the time of client and server system are synchronized.
- the token supplied is valid.
- if bearer tokens are used check that system configuration allows the API endpoint to accept such tokens.

Exceptions

  Com::Vmware::Vapi::Std::Errors::ServiceUnavailable | if session creation fails due to server specific issues, for example connection to a back end component is failing. Due to the security nature of this API further details will not be disclosed in the error . Please refer to component health information, administrative logs and product specific documentation for possible causes.

Code:
click to view
# Number of lines of code in create: 4
sub create {
my ($self, %args) = @_;
return $self->invoke(method_name => 'create', method_args => {});
}

public method Com::Vmware::Cis::Session::delete | ( |  | ) |

Terminates the validity of a session token. This is the equivalent of log out.

A session identifier is expected as part of the request.

Exceptions

  Com::Vmware::Vapi::Std::Errors::Unauthenticated | if the session id is missing from the request or the corresponding session object cannot be found.
  Com::Vmware::Vapi::Std::Errors::ServiceUnavailable | if session deletion fails due to server specific issues, for example connection to a back end component is failing. Due to the security nature of this API further details will not be disclosed in the error . Please refer to component health information, administrative logs and product specific documentation for possible causes.

Code:
click to view
# Number of lines of code in delete: 4
sub delete {
my ($self, %args) = @_;
return $self->invoke(method_name => 'delete', method_args => {});
}

public method Com::Vmware::Cis::Session::get | ( |  | ) |

Returns information about the current session. This method expects a valid session identifier to be supplied.

A side effect of invoking this method may be a change to the session's last accessed time to the current time if this is supported by the session implementation. Invoking any other method in the API will also update the session's last accessed time.

This API is meant to serve the needs of various front end projects that may want to display the name of the user. Examples of this include various web based user interfaces and logging facilities.

Return values

  Information | about the session. The return type will be Com::Vmware::Cis::Session::Info

Exceptions

  Com::Vmware::Vapi::Std::Errors::Unauthenticated | if the session id is missing from the request or the corresponding session object cannot be found.
  Com::Vmware::Vapi::Std::Errors::ServiceUnavailable | if session retrieval fails due to server specific issues e.g. connection to back end component is failing. Due to the security nature of this API further details will not be disclosed in the error. Please refer to component health information, administrative logs and product specific documentation for possible causes.

Code:
click to view
# Number of lines of code in get: 4
sub get {
my ($self, %args) = @_;
return $self->invoke(method_name => 'get', method_args => {});
}

public method Com::Vmware::Cis::Session::new | ( |  | ) |

Constructor to initialize the object

Parameters

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

Return values

  Blessed | object

Code:
click to view
# Number of lines of code in new: 11
sub new {
my ($class, %args) = @_;
$class = ref($class) || $class;
my $stub_config = $args {stub_config};
my $api_provider = $args {api_provider};
my $self = $class->SUPER::new('stub_config' => $stub_config,
'api_provider' => $api_provider);
bless $self, $class;
return $self;
}

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

- Com/Vmware/Cis/Session.pm