=begin
#Datadog API V1 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

 Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
 This product includes software developed at Datadog (https://www.datadoghq.com/).
 Copyright 2020-Present Datadog, Inc.

=end

require 'date'
require 'time'

module DatadogAPIClient::V1
  # The steps used in a Synthetics multistep API test.
  class SyntheticsAPIStep
    include BaseGenericModel

    # Whether the object has unparsed attributes
    # @!visibility private
    attr_accessor :_unparsed

    # Determines whether or not to continue with test if this step fails.
    attr_accessor :allow_failure

    # Array of assertions used for the test.
    attr_accessor :assertions

    # Array of values to parse and save as variables from the response.
    attr_accessor :extracted_values

    # Determines whether or not to consider the entire test as failed if this step fails.
    # Can be used only if `allowFailure` is `true`.
    attr_accessor :is_critical

    # The name of the step.
    attr_accessor :name

    # Object describing the Synthetic test request.
    attr_accessor :request

    # Object describing the retry strategy to apply to a Synthetic test.
    attr_accessor :_retry

    # The subtype of the Synthetic multistep API test step, currently only supporting `http`.
    attr_accessor :subtype

    # Attribute mapping from ruby-style variable name to JSON key.
    # @!visibility private
    def self.attribute_map
      {
        :'allow_failure' => :'allowFailure',
        :'assertions' => :'assertions',
        :'extracted_values' => :'extractedValues',
        :'is_critical' => :'isCritical',
        :'name' => :'name',
        :'request' => :'request',
        :'_retry' => :'retry',
        :'subtype' => :'subtype'
      }
    end

    # Returns all the JSON keys this model knows about
    # @!visibility private
    def self.acceptable_attributes
      attribute_map.values
    end

    # Attribute type mapping.
    # @!visibility private
    def self.openapi_types
      {
        :'allow_failure' => :'Boolean',
        :'assertions' => :'Array<SyntheticsAssertion>',
        :'extracted_values' => :'Array<SyntheticsParsingOptions>',
        :'is_critical' => :'Boolean',
        :'name' => :'String',
        :'request' => :'SyntheticsTestRequest',
        :'_retry' => :'SyntheticsTestOptionsRetry',
        :'subtype' => :'SyntheticsAPIStepSubtype'
      }
    end

    # List of attributes with nullable: true
    # @!visibility private
    def self.openapi_nullable
      Set.new([
      ])
    end

    # Initializes the object
    # @param attributes [Hash] Model attributes in the form of hash
    # @!visibility private
    def initialize(attributes = {})
      if (!attributes.is_a?(Hash))
        fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::SyntheticsAPIStep` initialize method"
      end

      # check to see if the attribute exists and convert string to symbol for hash key
      attributes = attributes.each_with_object({}) { |(k, v), h|
        if (!self.class.attribute_map.key?(k.to_sym))
          fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::SyntheticsAPIStep`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
        end
        h[k.to_sym] = v
      }

      if attributes.key?(:'allow_failure')
        self.allow_failure = attributes[:'allow_failure']
      end

      if attributes.key?(:'assertions')
        if (value = attributes[:'assertions']).is_a?(Array)
          self.assertions = value
        end
      else
        self.assertions = []
      end

      if attributes.key?(:'extracted_values')
        if (value = attributes[:'extracted_values']).is_a?(Array)
          self.extracted_values = value
        end
      end

      if attributes.key?(:'is_critical')
        self.is_critical = attributes[:'is_critical']
      end

      if attributes.key?(:'name')
        self.name = attributes[:'name']
      end

      if attributes.key?(:'request')
        self.request = attributes[:'request']
      end

      if attributes.key?(:'_retry')
        self._retry = attributes[:'_retry']
      end

      if attributes.key?(:'subtype')
        self.subtype = attributes[:'subtype']
      end
    end

    # Show invalid properties with the reasons. Usually used together with valid?
    # @return Array for valid properties with the reasons
    # @!visibility private
    def list_invalid_properties
      invalid_properties = Array.new
      if @assertions.nil?
        invalid_properties.push('invalid value for "assertions", assertions cannot be nil.')
      end
      if @name.nil?
        invalid_properties.push('invalid value for "name", name cannot be nil.')
      end
      if @request.nil?
        invalid_properties.push('invalid value for "request", request cannot be nil.')
      end
      if @subtype.nil?
        invalid_properties.push('invalid value for "subtype", subtype cannot be nil.')
      end
      invalid_properties
    end

    # Check to see if the all the properties in the model are valid
    # @return true if the model is valid
    # @!visibility private
    def valid?
      return false if @assertions.nil?
      return false if @name.nil?
      return false if @request.nil?
      return false if @subtype.nil?
      true
    end

    # Custom attribute writer method with validation
    # @param assertions [Object] Object to be assigned
    # @!visibility private
    def assertions=(assertions)
      if assertions.nil?
        fail ArgumentError, 'invalid value for "assertions", assertions cannot be nil.'
      end
      @assertions = assertions
    end

    # Custom attribute writer method with validation
    # @param name [Object] Object to be assigned
    # @!visibility private
    def name=(name)
      if name.nil?
        fail ArgumentError, 'invalid value for "name", name cannot be nil.'
      end
      @name = name
    end

    # Custom attribute writer method with validation
    # @param request [Object] Object to be assigned
    # @!visibility private
    def request=(request)
      if request.nil?
        fail ArgumentError, 'invalid value for "request", request cannot be nil.'
      end
      @request = request
    end

    # Custom attribute writer method with validation
    # @param subtype [Object] Object to be assigned
    # @!visibility private
    def subtype=(subtype)
      if subtype.nil?
        fail ArgumentError, 'invalid value for "subtype", subtype cannot be nil.'
      end
      @subtype = subtype
    end

    # Checks equality by comparing each attribute.
    # @param o [Object] Object to be compared
    # @!visibility private
    def ==(o)
      return true if self.equal?(o)
      self.class == o.class &&
          allow_failure == o.allow_failure &&
          assertions == o.assertions &&
          extracted_values == o.extracted_values &&
          is_critical == o.is_critical &&
          name == o.name &&
          request == o.request &&
          _retry == o._retry &&
          subtype == o.subtype
    end

    # @see the `==` method
    # @param o [Object] Object to be compared
    # @!visibility private
    def eql?(o)
      self == o
    end

    # Calculates hash code according to all attributes.
    # @return [Integer] Hash code
    # @!visibility private
    def hash
      [allow_failure, assertions, extracted_values, is_critical, name, request, _retry, subtype].hash
    end
  end
end
