# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
#     ***     AUTO GENERATED CODE    ***    AUTO GENERATED CODE     ***
#
# ----------------------------------------------------------------------------
#
#     This file is automatically generated by Magic Modules and manual
#     changes will be clobbered when the file is regenerated.
#
#     Please read more about how to change this file in README.md and
#     CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/cloudbuild/property/trigger_build_steps_volumes'
module GoogleInSpec
  module CloudBuild
    module Property
      class TriggerBuildSteps
        attr_reader :arguments

        attr_reader :name

        attr_reader :args

        attr_reader :env

        attr_reader :id

        attr_reader :entrypoint

        attr_reader :dir

        attr_reader :secret_env

        attr_reader :timeout

        attr_reader :timing

        attr_reader :volumes

        attr_reader :wait_for

        def initialize(arguments = nil, parent_identifier = nil)
          @arguments = arguments
          return if arguments.nil?
          @parent_identifier = parent_identifier
          @name = arguments['name']
          @args = arguments['args']
          @env = arguments['env']
          @id = arguments['id']
          @entrypoint = arguments['entrypoint']
          @dir = arguments['dir']
          @secret_env = arguments['secretEnv']
          @timeout = arguments['timeout']
          @timing = arguments['timing']
          @volumes = GoogleInSpec::CloudBuild::Property::TriggerBuildStepsVolumesArray.parse(arguments['volumes'], to_s)
          @wait_for = arguments['waitFor']
        end

        def to_s
          "#{@parent_identifier} TriggerBuildSteps"
        end

        def self.un_parse(item, current_path)
          return if item.nil?
          way_to_parse = {
            'name' => ->(x, path) { x.nil? ? [] : ["its('#{path}.name') { should cmp #{x.inspect} }"] },
            'args' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.args') { should include #{single.inspect} }" } },
            'env' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.env') { should include #{single.inspect} }" } },
            'id' => ->(x, path) { x.nil? ? [] : ["its('#{path}.id') { should cmp #{x.inspect} }"] },
            'entrypoint' => ->(x, path) { x.nil? ? [] : ["its('#{path}.entrypoint') { should cmp #{x.inspect} }"] },
            'dir' => ->(x, path) { x.nil? ? [] : ["its('#{path}.dir') { should cmp #{x.inspect} }"] },
            'secret_env' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.secret_env') { should include #{single.inspect} }" } },
            'timeout' => ->(x, path) { x.nil? ? [] : ["its('#{path}.timeout') { should cmp #{x.inspect} }"] },
            'timing' => ->(x, path) { x.nil? ? [] : ["its('#{path}.timing') { should cmp #{x.inspect} }"] },
            'volumes' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.volumes') { should include '#{single.to_json}' }" } },
            'wait_for' => ->(x, path) { x.nil? ? [] : x.map { |single| "its('#{path}.wait_for') { should include #{single.inspect} }" } },
          }
          way_to_parse.map do |k, v|
            v.call(item.method(k).call, current_path)
          end
        end

        def to_json(*_args)
          @arguments.to_json
        end

        # other is a string representation of this object
        def ==(other)
          @arguments == JSON.parse(other)
        end
      end

      class TriggerBuildStepsArray
        def self.parse(value, parent_identifier)
          return if value.nil?
          return TriggerBuildSteps.new(value, parent_identifier) unless value.is_a?(::Array)
          value.map { |v| TriggerBuildSteps.new(v, parent_identifier) }
        end

        def self.un_parse(arr, path)
          return if arr.nil?
          value.map { |v| TriggerBuildSteps.un_parse(v, path) }
        end
      end
    end
  end
end
