Class: Azure::ServerManagement::Mgmt::V2016_07_01_preview::Session

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb

Overview

REST API for Azure Server Management Service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Session

Creates and initializes a new instance of the Session class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientServerManagement (readonly)

Returns reference to the ServerManagement.

Returns:



22
23
24
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 22

def client
  @client
end

Instance Method Details

#begin_create(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil) ⇒ SessionResource

Creates a session for a node.

identifies the resource group within the user subscriptionId. values include: ‘Session’, ‘Persistent’ Possible values include: ‘RsaEncrypted’ thumbprint. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • user_name (String) (defaults to: nil)

    Encrypted User name to be used to connect to node.

  • password (String) (defaults to: nil)

    Encrypted Password associated with user name.

  • retention_period (RetentionPeriod) (defaults to: nil)

    Session retention period. Possible

  • credential_data_format (CredentialDataFormat) (defaults to: nil)

    Credential data format.

  • encryption_certificate_thumbprint (String) (defaults to: nil)

    Encryption certificate

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (SessionResource)

    operation results.



291
292
293
294
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 291

def begin_create(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil)
  response = begin_create_async(resource_group_name, node_name, session, user_name, password, retention_period, credential_data_format, encryption_certificate_thumbprint, custom_headers).value!
  response.body unless response.nil?
end

#begin_create_async(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil) ⇒ Concurrent::Promise

Creates a session for a node.

identifies the resource group within the user subscriptionId. values include: ‘Session’, ‘Persistent’ Possible values include: ‘RsaEncrypted’ thumbprint. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • user_name (String) (defaults to: nil)

    Encrypted User name to be used to connect to node.

  • password (String) (defaults to: nil)

    Encrypted Password associated with user name.

  • retention_period (RetentionPeriod) (defaults to: nil)

    Session retention period. Possible

  • credential_data_format (CredentialDataFormat) (defaults to: nil)

    Credential data format.

  • encryption_certificate_thumbprint (String) (defaults to: nil)

    Encryption certificate

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 340

def begin_create_async(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, 'session is nil' if session.nil?

  session_parameters = SessionParameters.new
  unless user_name.nil? && password.nil? && retention_period.nil? && credential_data_format.nil? && encryption_certificate_thumbprint.nil?
    session_parameters.user_name = user_name
    session_parameters.password = password
    session_parameters.retention_period = retention_period
    session_parameters.credential_data_format = credential_data_format
    session_parameters.encryption_certificate_thumbprint = encryption_certificate_thumbprint
  end

  request_headers = {}

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Serialize Request
  request_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::SessionParameters.mapper()
  request_content = @client.serialize(request_mapper,  session_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:put, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200 || status_code == 201 || status_code == 202
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::SessionResource.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::SessionResource.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#begin_create_with_http_info(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Creates a session for a node.

identifies the resource group within the user subscriptionId. values include: ‘Session’, ‘Persistent’ Possible values include: ‘RsaEncrypted’ thumbprint. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • user_name (String) (defaults to: nil)

    Encrypted User name to be used to connect to node.

  • password (String) (defaults to: nil)

    Encrypted Password associated with user name.

  • retention_period (RetentionPeriod) (defaults to: nil)

    Session retention period. Possible

  • credential_data_format (CredentialDataFormat) (defaults to: nil)

    Credential data format.

  • encryption_certificate_thumbprint (String) (defaults to: nil)

    Encryption certificate

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



316
317
318
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 316

def begin_create_with_http_info(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil)
  begin_create_async(resource_group_name, node_name, session, user_name, password, retention_period, credential_data_format, encryption_certificate_thumbprint, custom_headers).value!
end

#create(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil) ⇒ SessionResource

Creates a session for a node.

identifies the resource group within the user subscriptionId. values include: ‘Session’, ‘Persistent’ Possible values include: ‘RsaEncrypted’ thumbprint. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • user_name (String) (defaults to: nil)

    Encrypted User name to be used to connect to node.

  • password (String) (defaults to: nil)

    Encrypted Password associated with user name.

  • retention_period (RetentionPeriod) (defaults to: nil)

    Session retention period. Possible

  • credential_data_format (CredentialDataFormat) (defaults to: nil)

    Credential data format.

  • encryption_certificate_thumbprint (String) (defaults to: nil)

    Encryption certificate

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (SessionResource)

    operation results.



44
45
46
47
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 44

def create(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil)
  response = create_async(resource_group_name, node_name, session, user_name, password, retention_period, credential_data_format, encryption_certificate_thumbprint, custom_headers).value!
  response.body unless response.nil?
end

#create_async(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil) ⇒ Concurrent::Promise

identifies the resource group within the user subscriptionId. values include: ‘Session’, ‘Persistent’ Possible values include: ‘RsaEncrypted’ thumbprint. will be added to the HTTP request.

response.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • user_name (String) (defaults to: nil)

    Encrypted User name to be used to connect to node.

  • password (String) (defaults to: nil)

    Encrypted Password associated with user name.

  • retention_period (RetentionPeriod) (defaults to: nil)

    Session retention period. Possible

  • credential_data_format (CredentialDataFormat) (defaults to: nil)

    Credential data format.

  • encryption_certificate_thumbprint (String) (defaults to: nil)

    Encryption certificate

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 68

def create_async(resource_group_name, node_name, session, user_name = nil, password = nil, retention_period = nil, credential_data_format = nil, encryption_certificate_thumbprint = nil, custom_headers = nil)
  # Send request
  promise = begin_create_async(resource_group_name, node_name, session, user_name, password, retention_period, credential_data_format, encryption_certificate_thumbprint, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::SessionResource.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end

#delete(resource_group_name, node_name, session, custom_headers = nil) ⇒ Object

Deletes a session for a node.

identifies the resource group within the user subscriptionId. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that



97
98
99
100
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 97

def delete(resource_group_name, node_name, session, custom_headers = nil)
  response = delete_async(resource_group_name, node_name, session, custom_headers).value!
  nil
end

#delete_async(resource_group_name, node_name, session, custom_headers = nil) ⇒ Concurrent::Promise

Deletes a session for a node.

identifies the resource group within the user subscriptionId. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



130
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
168
169
170
171
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 130

def delete_async(resource_group_name, node_name, session, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, 'session is nil' if session.nil?


  request_headers = {}

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200 || status_code == 204
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?

    result
  end

  promise.execute
end

#delete_with_http_info(resource_group_name, node_name, session, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes a session for a node.

identifies the resource group within the user subscriptionId. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



114
115
116
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 114

def delete_with_http_info(resource_group_name, node_name, session, custom_headers = nil)
  delete_async(resource_group_name, node_name, session, custom_headers).value!
end

#get(resource_group_name, node_name, session, custom_headers = nil) ⇒ SessionResource

Gets a session for a node.

identifies the resource group within the user subscriptionId. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (SessionResource)

    operation results.



185
186
187
188
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 185

def get(resource_group_name, node_name, session, custom_headers = nil)
  response = get_async(resource_group_name, node_name, session, custom_headers).value!
  response.body unless response.nil?
end

#get_async(resource_group_name, node_name, session, custom_headers = nil) ⇒ Concurrent::Promise

Gets a session for a node.

identifies the resource group within the user subscriptionId. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 218

def get_async(resource_group_name, node_name, session, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'node_name is nil' if node_name.nil?
  fail ArgumentError, 'session is nil' if session.nil?


  request_headers = {}

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServerManagement/nodes/{nodeName}/sessions/{session}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'nodeName' => node_name,'session' => session},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::ServerManagement::Mgmt::V2016_07_01_preview::Models::SessionResource.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#get_with_http_info(resource_group_name, node_name, session, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Gets a session for a node.

identifies the resource group within the user subscriptionId. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The resource group name uniquely

  • node_name (String)

    The node name (256 characters maximum).

  • session (String)

    The sessionId from the user.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



202
203
204
# File 'lib/2016-07-01-preview/generated/azure_mgmt_server_management/session.rb', line 202

def get_with_http_info(resource_group_name, node_name, session, custom_headers = nil)
  get_async(resource_group_name, node_name, session, custom_headers).value!
end