# 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.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
  module Storage
    module Property
      class BucketLifecycleRuleCondition
        attr_reader :age_days

        attr_reader :created_before

        attr_reader :is_live

        attr_reader :matches_storage_class

        attr_reader :num_newer_versions

        def initialize(args = nil, parent_identifier = nil)
          return if args.nil?
          @parent_identifier = parent_identifier
          @age_days = args['age']
          @created_before = parse_time_string(args['createdBefore'])
          @is_live = args['isLive']
          @matches_storage_class = args['matchesStorageClass']
          @num_newer_versions = args['numNewerVersions']
        end

        def to_s
          "#{@parent_identifier} BucketLifecycleRuleCondition"
        end

        # Handles parsing RFC3339 time string
        def parse_time_string(time_string)
          time_string ? Time.parse(time_string) : nil
        end
      end
    end
  end
end
