lib/fog/internet_archive/models/storage/directory.rb in fog-1.10.0 vs lib/fog/internet_archive/models/storage/directory.rb in fog-1.10.1
- old
+ new
@@ -1,38 +1,41 @@
require 'fog/core/model'
require 'fog/internet_archive/models/storage/files'
-require 'fog/internet_archive/models/storage/versions'
+require 'fog/internet_archive/models/storage/ia_attributes.rb'
module Fog
module Storage
class InternetArchive
class Directory < Fog::Model
- VALID_ACLS = ['private', 'public-read', 'public-read-write', 'authenticated-read']
- # See http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html
- INVALID_LOCATIONS = ['us-east-1']
+ extend Fog::Storage::IAAttributes::ClassMethods
+ include Fog::Storage::IAAttributes::InstanceMethods
- attr_reader :acl
-
identity :key, :aliases => ['Name', 'name']
attribute :creation_date, :aliases => 'CreationDate'
+ # treat these differently
+ attribute :collections
+ attribute :subjects
+
+ ia_metadata_attribute :ignore_preexisting_bucket
+ ia_metadata_attribute :interactive_priority
+
+ # acl for internet archive is always public-read
+ def acl
+ 'public-read'
+ end
+
def acl=(new_acl)
- unless VALID_ACLS.include?(new_acl)
- raise ArgumentError.new("acl must be one of [#{VALID_ACLS.join(', ')}]")
- else
- @acl = new_acl
- end
+ 'public-read'
end
+ # See http://archive.org/help/abouts3.txt
def destroy
- requires :key
- service.delete_bucket(key)
- true
- rescue Excon::Errors::NotFound
+ Fog::Logger.warning("fog: Internet Archive does not support deleting a Bucket (i.e. Item). For details see: See http://archive.org/help/abouts3.txt")
false
end
def location
requires :key
@@ -61,48 +64,28 @@
requires :key
service.put_request_payment(key, new_payer)
@payer = new_payer
end
- def versioning?
- requires :key
- data = service.get_bucket_versioning(key)
- data.body['VersioningConfiguration']['Status'] == 'Enabled'
- end
-
- def versioning=(new_versioning)
- requires :key
- service.put_bucket_versioning(key, new_versioning ? 'Enabled' : 'Suspended')
- end
-
- def versions
- @versions ||= Fog::Storage::InternetArchive::Versions.new(:directory => self, :service => service)
- end
-
def public=(new_public)
- self.acl = new_public ? 'public-read' : 'private'
- new_public
+ 'public-read'
end
def public_url
requires :key
- if service.get_bucket_acl(key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
- if key.to_s =~ Fog::InternetArchive::COMPLIANT_BUCKET_NAMES
- "https://#{key}.s3.#{Fog::InternetArchive::DOMAIN_NAME}"
- else
- "https://s3.#{Fog::InternetArchive::DOMAIN_NAME}/#{key}"
- end
- else
- nil
- end
+ "http://#{Fog::InternetArchive::DOMAIN_NAME}/details/#{key}"
end
def save
requires :key
options = {}
- options['x-amz-acl'] = acl if acl
+ options['x-archive-ignore-preexisting-bucket'] = ignore_preexisting_bucket if ignore_preexisting_bucket
+ options['x-archive-interactive-priority'] = interactive_priority if interactive_priority
+
+ set_metadata_array_headers(:collections, options)
+ set_metadata_array_headers(:subjects, options)
if location = attributes[:location] || (self.service.region != 'us-east-1' && self.service.region)
options['LocationConstraint'] = location
end