# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::ARM::Compute module Models # # The Compute service response for long-running operations. # class ComputeLongRunningOperationResult include MsRestAzure # @return [String] Gets the operation identifier. attr_accessor :operation_id # @return [ComputeOperationStatus] Gets the operation status. Possible # values for this property include: 'InProgress', 'Failed', # 'Succeeded', 'Preempted'. attr_accessor :status # @return [DateTime] Gets the operation start time attr_accessor :start_time # @return [DateTime] Gets the operation end time attr_accessor :end_time # @return [ComputeLongRunningOperationProperties] attr_accessor :properties # @return [ApiError] Gets the operation error, if any occurred. attr_accessor :error # # Validate the object. Throws ValidationError if validation fails. # def validate @properties.validate unless @properties.nil? @error.validate unless @error.nil? end # # Serializes given Model object into Ruby Hash. # @param object Model object to serialize. # @return [Hash] Serialized object in form of Ruby Hash. # def self.serialize_object(object) object.validate output_object = {} serialized_property = object.operation_id output_object['operationId'] = serialized_property unless serialized_property.nil? serialized_property = object.status output_object['status'] = serialized_property unless serialized_property.nil? serialized_property = object.start_time serialized_property = serialized_property.new_offset(0).strftime('%FT%TZ') output_object['startTime'] = serialized_property unless serialized_property.nil? serialized_property = object.end_time serialized_property = serialized_property.new_offset(0).strftime('%FT%TZ') output_object['endTime'] = serialized_property unless serialized_property.nil? serialized_property = object.properties unless serialized_property.nil? serialized_property = ComputeLongRunningOperationProperties.serialize_object(serialized_property) end output_object['properties'] = serialized_property unless serialized_property.nil? serialized_property = object.error unless serialized_property.nil? serialized_property = ApiError.serialize_object(serialized_property) end output_object['error'] = serialized_property unless serialized_property.nil? output_object end # # Deserializes given Ruby Hash into Model object. # @param object [Hash] Ruby Hash object to deserialize. # @return [ComputeLongRunningOperationResult] Deserialized object. # def self.deserialize_object(object) return if object.nil? output_object = ComputeLongRunningOperationResult.new deserialized_property = object['operationId'] output_object.operation_id = deserialized_property deserialized_property = object['status'] if (!deserialized_property.nil? && !deserialized_property.empty?) enum_is_valid = ComputeOperationStatus.constants.any? { |e| ComputeOperationStatus.const_get(e).to_s.downcase == deserialized_property.downcase } fail MsRest::DeserializationError.new('Error occured while deserializing the enum', nil, nil, nil) unless enum_is_valid end output_object.status = deserialized_property deserialized_property = object['startTime'] deserialized_property = DateTime.parse(deserialized_property) unless deserialized_property.to_s.empty? output_object.start_time = deserialized_property deserialized_property = object['endTime'] deserialized_property = DateTime.parse(deserialized_property) unless deserialized_property.to_s.empty? output_object.end_time = deserialized_property deserialized_property = object['properties'] unless deserialized_property.nil? deserialized_property = ComputeLongRunningOperationProperties.deserialize_object(deserialized_property) end output_object.properties = deserialized_property deserialized_property = object['error'] unless deserialized_property.nil? deserialized_property = ApiError.deserialize_object(deserialized_property) end output_object.error = deserialized_property output_object.validate output_object end end end end