Class: MsRestAzure::AsyncOperationStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/ms_rest_azure/async_operation_status.rb

Overview

Defines values for AsyncOperationStatus enum.

Constant Summary collapse

IN_PROGRESS_STATUS =
'InProgress'
RUNNING =
'Running'
SUCCESS_STATUS =
'Succeeded'
FAILED_STATUS =
'Failed'
CANCELED_STATUS =
'Canceled'
ALL_STATUSES =
[FAILED_STATUS, CANCELED_STATUS, SUCCESS_STATUS, IN_PROGRESS_STATUS, RUNNING]
FAILED_STATUSES =
[FAILED_STATUS, CANCELED_STATUS]
TERMINAL_STATUSES =
[FAILED_STATUS, CANCELED_STATUS, SUCCESS_STATUS]
DEFAULT_DELAY =
30

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#errorMsRestAzure::CloudErrorData

Returns error information about async operation.

Returns:



26
27
28
# File 'lib/ms_rest_azure/async_operation_status.rb', line 26

def error
  @error
end

#retry_afterInteger

Returns delay in seconds which should be used for polling for result of async operation.

Returns:

  • (Integer)

    delay in seconds which should be used for polling for result of async operation.



23
24
25
# File 'lib/ms_rest_azure/async_operation_status.rb', line 23

def retry_after
  @retry_after
end

#statusStirng

Returns status of polling.

Returns:

  • (Stirng)

    status of polling.



29
30
31
# File 'lib/ms_rest_azure/async_operation_status.rb', line 29

def status
  @status
end

Class Method Details

.deserialize_object(object) ⇒ AsyncOperationStatus

Deserializes given hash into AsyncOperationStatus object.

Parameters:

  • object (Hash)

    object to deserialize.

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ms_rest_azure/async_operation_status.rb', line 63

def self.deserialize_object(object)
  return if object.nil?
  output_object = AsyncOperationStatus.new

  fail AzureOperationError, "Invalid status was recieved during polling: #{object['status']}" unless ALL_STATUSES.include?(object['status'])
  output_object.status = object['status']

  output_object.error = CloudErrorData.deserialize_object(object['error'])

  output_object.retry_after = Integer(object['retryAfter']) unless object['retryAfter'].nil?

  output_object
end

.is_failed_status(status) ⇒ Boolean

Checks if given status is failed one.

Parameters:

  • status (String)

    status to verify

Returns:

  • (Boolean)

    True if given status is failed one, false otherwise.



45
46
47
# File 'lib/ms_rest_azure/async_operation_status.rb', line 45

def self.is_failed_status(status)
  FAILED_STATUSES.any? { |st| st == status }
end

.is_successful_status(status) ⇒ Boolean

Checks if given status is successful one.

Parameters:

  • status (String)

    status to verify

Returns:

  • (Boolean)

    True if given status is successful one, false otherwise.



54
55
56
# File 'lib/ms_rest_azure/async_operation_status.rb', line 54

def self.is_successful_status(status)
  return status == SUCCESS_STATUS
end

.is_terminal_status(status) ⇒ Boolean

Checks if given status is terminal one.

Parameters:

  • status (String)

    status to verify

Returns:

  • (Boolean)

    True if given status is terminal one, false otherwise.



36
37
38
# File 'lib/ms_rest_azure/async_operation_status.rb', line 36

def self.is_terminal_status(status)
  TERMINAL_STATUSES.any? { |st| st == status }
end