/
bucket.rb
88 lines (71 loc) · 3.08 KB
/
bucket.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# encoding: ascii-8bit
# Copyright 2022 OpenC3, Inc.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.
ENV['OPENC3_CLOUD'] ||= 'local'
# Interface class implemented by each cloud provider: AWS, GCS, Azure
module OpenC3
class Bucket
# Raised when the underlying bucket does not exist
class NotFound < RuntimeError
end
def self.getClient
raise 'OPENC3_CLOUD environment variable is required' unless ENV['OPENC3_CLOUD']
# Base is AwsBucket which works with MINIO, Enterprise implements additional
bucket_class = ENV['OPENC3_CLOUD'].capitalize + 'Bucket'
klass = OpenC3.require_class('openc3/utilities/'+bucket_class.class_name_to_filename)
klass.new
end
def initialize
# Setup the client instance
end
def create(bucket)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def ensure_public(bucket)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def exist?(bucket)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def delete(bucket)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def get_object(bucket:, key:, path: nil)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def list_objects(bucket:, prefix: nil, max_request: nil, max_total: nil)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def list_files(bucket:, path:, only_directories: false, metadata: false)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def put_object(bucket:, key:, body:, content_type: nil, cache_control: nil, metadata: nil)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def check_object(bucket:, key:, retries: true)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def delete_object(bucket:, key:)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def delete_objects(bucket:, keys:)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def presigned_request(bucket:, key:, method:, internal: true)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
end
end