Sha256: 4f75474a6f277209420e4f1a565c6d3c78b6a166a1545660c4c12f918ae857d5

Contents?: true

Size: 1.56 KB

Versions: 51

Compression:

Stored size: 1.56 KB

Contents

module Awspec::Helper
  module Finder
    module S3
      def find_bucket(id)
        res = s3_client.list_buckets
        ret = s3_client.list_buckets[:buckets].find do |bucket|
          bucket.name == id
        end
      end

      def find_bucket_acl(id)
        s3_client.get_bucket_acl(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def find_bucket_cors(id)
        s3_client.get_bucket_cors(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def find_bucket_policy(id)
        s3_client.get_bucket_policy(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def find_bucket_logging(id)
        s3_client.get_bucket_logging(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def find_bucket_tag(id, tag_key)
        tag = nil
        begin
          bucket_tagging = s3_client.get_bucket_tagging(bucket: id)
          tag_set = bucket_tagging.tag_set
          tag = tag_set.find { |tag_obj| tag_obj.key == tag_key }
        rescue Aws::S3::Errors::ServiceError
          nil
        end
        return tag if tag
      end

      def find_bucket_versioning(id)
        s3_client.get_bucket_versioning(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def find_bucket_lifecycle_configuration(id)
        s3_client.get_bucket_lifecycle_configuration(bucket: id)
      rescue Aws::S3::Errors::ServiceError
        nil
      end

      def select_all_buckets
        s3_client.list_buckets.buckets
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
awspec-1.14.1 lib/awspec/helper/finder/s3.rb
awspec-1.14.0 lib/awspec/helper/finder/s3.rb
awspec-1.13.0 lib/awspec/helper/finder/s3.rb
awspec-1.12.7 lib/awspec/helper/finder/s3.rb
awspec-1.12.6 lib/awspec/helper/finder/s3.rb
awspec-1.12.5 lib/awspec/helper/finder/s3.rb
awspec-1.12.4 lib/awspec/helper/finder/s3.rb
awspec-1.12.3 lib/awspec/helper/finder/s3.rb
awspec-1.12.2 lib/awspec/helper/finder/s3.rb
awspec-1.12.1 lib/awspec/helper/finder/s3.rb
awspec-1.12.0 lib/awspec/helper/finder/s3.rb
awspec-1.11.1 lib/awspec/helper/finder/s3.rb
awspec-1.11.0 lib/awspec/helper/finder/s3.rb
awspec-1.10.0 lib/awspec/helper/finder/s3.rb
awspec-1.9.0 lib/awspec/helper/finder/s3.rb
awspec-1.8.0 lib/awspec/helper/finder/s3.rb
awspec-1.7.0 lib/awspec/helper/finder/s3.rb
awspec-1.6.1 lib/awspec/helper/finder/s3.rb
awspec-1.6.0 lib/awspec/helper/finder/s3.rb
awspec-1.5.4 lib/awspec/helper/finder/s3.rb