/usr/lib/ruby/vendor_ruby/ms_rest_azure/async_operation_status.rb is in ruby-ms-rest-azure 0.6.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 75 76 77 78 | # encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
module MsRestAzure
#
# Defines values for AsyncOperationStatus enum.
#
class AsyncOperationStatus
ACCEPTED = 'Accepted'
IN_PROGRESS_STATUS = 'InProgress'
RUNNING = 'Running'
SUCCESS_STATUS = 'Succeeded'
FAILED_STATUS = 'Failed'
CANCELED_STATUS = 'Canceled'
ALL_STATUSES = [ACCEPTED, 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
# @return [Integer] delay in seconds which should be used for polling for result of async operation.
attr_accessor :retry_after
# @return [MsRestAzure::CloudErrorData] error information about async operation.
attr_accessor :error
# @return [Stirng] status of polling.
attr_accessor :status
#
# Checks if given status is terminal one.
# @param status [String] status to verify
#
# @return [Boolean] True if given status is terminal one, false otherwise.
def self.is_terminal_status(status)
TERMINAL_STATUSES.any? { |st| st == status }
end
#
# Checks if given status is failed one.
# @param status [String] status to verify
#
# @return [Boolean] True if given status is failed one, false otherwise.
def self.is_failed_status(status)
FAILED_STATUSES.any? { |st| st == status }
end
#
# Checks if given status is successful one.
# @param status [String] status to verify
#
# @return [Boolean] True if given status is successful one, false otherwise.
def self.is_successful_status(status)
return status == SUCCESS_STATUS
end
#
# Deserializes given hash into AsyncOperationStatus object.
# @param object [Hash] object to deserialize.
#
# @return [AsyncOperationStatus] deserialized object.
def self.deserialize_object(object)
return if object.nil?
output_object = AsyncOperationStatus.new
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
end
end
|