Sha256: 383784614cf3de544a8fdddb6f369e3254cde897af6223a314034fdcb5dbd251
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
module Awspec::Type class S3Bucket < Base def initialize(id) super @resource = find_bucket(id) @id = id if @resource end def has_object?(key) res = @s3_client.head_object({ bucket: @id, key: key.sub(%r(\A/), '') }) res rescue false end def has_acl_grant?(grantee:, permission:) @acl = find_bucket_acl(@id) @acl.grants.find do |grant| next false if !grantee.nil? && grant.grantee.display_name != grantee && grant.grantee.id != grantee next false if !permission.nil? && grant.permission != permission true end end def acl_owner @acl = find_bucket_acl(@id) @acl.owner.display_name end def acl_grants_count @acl = find_bucket_acl(@id) @acl.grants.count end def has_cors_rule?(allowed_headers: [], allowed_methods:, allowed_origins:, expose_headers: [], max_age_seconds: nil) cors_rules.any? do |rule| (rule.allowed_headers - allowed_headers).empty? && (rule.allowed_methods - allowed_methods).empty? && (rule.allowed_origins - allowed_origins).empty? && (rule.expose_headers - expose_headers).empty? && rule.max_age_seconds == max_age_seconds end end def cors_rules_count cors_rules.count end def has_policy?(policy) bp = find_bucket_policy(@id) # newlines, spaces, etc.. are removed from policy which is returned from API bp ? (bp.policy.read == policy.gsub(/(\n|\r|\r\n|\s|\t)/, '')) : false end private def cors_rules cors = find_bucket_cors(@id) cors ? cors.cors_rules : [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
awspec-0.24.1 | lib/awspec/type/s3_bucket.rb |