Class: VSphereAutomation::CIS::SessionApi

Inherits:
Object
  • Object
show all
Defined in:
lib/vsphere-automation-cis/api/session_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SessionApi

Returns a new instance of SessionApi.



16
17
18
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 16

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



14
15
16
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#create(vmware_use_header_authn, opts = {}) ⇒ CisSessionCreateResult|VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|

Creates a session with the API. This is the equivalent of login. This operation 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.

Parameters:

  • vmware_use_header_authn

    Custom header to protect against CSRF attacks in browser based clients

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



23
24
25
26
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 23

def create(vmware_use_header_authn, opts = {})
  data, _status_code, _headers = create_with_http_info(vmware_use_header_authn, opts)
  data
end

#create_with_http_info(vmware_use_header_authn, opts = {}) ⇒ Array<(CisSessionCreateResult|VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a session with the API. This is the equivalent of login. This operation 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.

Parameters:

  • vmware_use_header_authn

    Custom header to protect against CSRF attacks in browser based clients

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 33

def create_with_http_info(vmware_use_header_authn, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SessionApi.create ...'
  end
  # verify the required parameter 'vmware_use_header_authn' is set
  if @api_client.config.client_side_validation && vmware_use_header_authn.nil?
    fail ArgumentError, "Missing the required parameter 'vmware_use_header_authn' when calling SessionApi.create"
  end
  # resource path
  local_var_path = '/com/vmware/cis/session'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'vmware-use-header-authn'] = vmware_use_header_authn

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic_auth']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
	:return_type => {
	  '200' => 'CIS::CisSessionCreateResult',
	  '401' => 'CIS::VapiStdErrorsUnauthenticatedError',
	  '503' => 'CIS::VapiStdErrorsServiceUnavailableError',
	})
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SessionApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete(opts = {}) ⇒ |VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|nil

Terminates the validity of a session token. This is the equivalent of log out. A session identifier is expected as part of the request.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



78
79
80
81
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 78

def delete(opts = {})
  delete_with_http_info(opts)
  nil
end

#delete_with_http_info(opts = {}) ⇒ Array<(|VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|nil, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Terminates the validity of a session token. This is the equivalent of log out. A session identifier is expected as part of the request.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 87

def delete_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SessionApi.delete ...'
  end
  # resource path
  local_var_path = '/com/vmware/cis/session'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SessionApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get(opts = {}) ⇒ CisSessionResult|VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|

Returns information about the current session. This operation expects a valid session identifier to be supplied. A side effect of invoking this operation 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 operation 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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



122
123
124
125
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 122

def get(opts = {})
  data, _status_code, _headers = get_with_http_info(opts)
  data
end

#get_with_http_info(opts = {}) ⇒ Array<(CisSessionResult|VapiStdErrorsUnauthenticatedError|VapiStdErrorsServiceUnavailableError|, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns information about the current session. This operation expects a valid session identifier to be supplied. A side effect of invoking this operation may be a change to the session&#39;s last accessed time to the current time if this is supported by the session implementation. Invoking any other operation in the API will also update the session&#39;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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/vsphere-automation-cis/api/session_api.rb', line 131

def get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SessionApi.get ...'
  end
  # resource path
  local_var_path = '/com/vmware/cis/session?~action=get'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
	:return_type => {
	  '200' => 'CIS::CisSessionResult',
	  '401' => 'CIS::VapiStdErrorsUnauthenticatedError',
	  '503' => 'CIS::VapiStdErrorsServiceUnavailableError',
	})
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SessionApi#get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end