morpheus-cli 2.12.5 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +5 -0
- data/lib/morpheus/api/api_client.rb +15 -30
- data/lib/morpheus/api/app_templates_interface.rb +34 -7
- data/lib/morpheus/api/apps_interface.rb +20 -1
- data/lib/morpheus/api/archive_buckets_interface.rb +124 -0
- data/lib/morpheus/api/archive_files_interface.rb +182 -0
- data/lib/morpheus/api/{network_pools_interface.rb → image_builder_boot_scripts_interface.rb} +6 -6
- data/lib/morpheus/api/{policies_interface.rb → image_builder_image_builds_interface.rb} +20 -15
- data/lib/morpheus/api/image_builder_interface.rb +26 -0
- data/lib/morpheus/api/{network_proxies_interface.rb → image_builder_preseed_scripts_interface.rb} +6 -6
- data/lib/morpheus/cli.rb +10 -9
- data/lib/morpheus/cli/alias_command.rb +10 -9
- data/lib/morpheus/cli/app_templates.rb +1566 -457
- data/lib/morpheus/cli/apps.rb +284 -108
- data/lib/morpheus/cli/archives_command.rb +2184 -0
- data/lib/morpheus/cli/boot_scripts_command.rb +382 -0
- data/lib/morpheus/cli/cli_command.rb +9 -35
- data/lib/morpheus/cli/error_handler.rb +2 -0
- data/lib/morpheus/cli/hosts.rb +15 -3
- data/lib/morpheus/cli/image_builder_command.rb +1208 -0
- data/lib/morpheus/cli/instances.rb +118 -47
- data/lib/morpheus/cli/man_command.rb +27 -24
- data/lib/morpheus/cli/mixins/print_helper.rb +19 -5
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +20 -20
- data/lib/morpheus/cli/option_types.rb +45 -14
- data/lib/morpheus/cli/preseed_scripts_command.rb +381 -0
- data/lib/morpheus/cli/remote.rb +1 -0
- data/lib/morpheus/cli/roles.rb +2 -2
- data/lib/morpheus/cli/shell.rb +3 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/ext/hash.rb +22 -0
- data/lib/morpheus/formatters.rb +33 -0
- data/lib/morpheus/terminal.rb +1 -1
- metadata +13 -21
- data/lib/morpheus/api/cloud_policies_interface.rb +0 -47
- data/lib/morpheus/api/group_policies_interface.rb +0 -47
- data/lib/morpheus/api/network_domains_interface.rb +0 -47
- data/lib/morpheus/api/network_groups_interface.rb +0 -47
- data/lib/morpheus/api/network_pool_servers_interface.rb +0 -47
- data/lib/morpheus/api/network_services_interface.rb +0 -47
- data/lib/morpheus/api/networks_interface.rb +0 -54
- data/lib/morpheus/cli/network_domains_command.rb +0 -571
- data/lib/morpheus/cli/network_groups_command.rb +0 -602
- data/lib/morpheus/cli/network_pool_servers_command.rb +0 -430
- data/lib/morpheus/cli/network_pools_command.rb +0 -495
- data/lib/morpheus/cli/network_proxies_command.rb +0 -594
- data/lib/morpheus/cli/network_services_command.rb +0 -148
- data/lib/morpheus/cli/networks_command.rb +0 -855
- data/lib/morpheus/cli/policies_command.rb +0 -847
- data/scripts/generate_morpheus_commands_help.morpheus +0 -1313
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3fa16d252ec2e2f560df9dd102509a85153589
|
4
|
+
data.tar.gz: d6f3b71230d52999891206f460ca95f0c444d8ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f139c587f694b214cc19b28d2a8ba47d52a3d2a172bfb5ef8eb1e45c303b4c496d5fa8d7c6a5800f8954768d4613a0d5880490c2ffb3711b478fce4617e2f7e0
|
7
|
+
data.tar.gz: 3ff339def831669445ad4380faa0e3eb6eca9761a6f1fa4c04adba080970bdd1fdf0c74d936173117b31294752e2239b758bd453e8e24adb14e9ecfc0f1adbb2
|
data/Dockerfile
ADDED
@@ -191,43 +191,28 @@ class Morpheus::APIClient
|
|
191
191
|
# monitoring.incidents
|
192
192
|
# end
|
193
193
|
|
194
|
-
def
|
195
|
-
Morpheus::
|
194
|
+
def archive_buckets
|
195
|
+
Morpheus::ArchiveBucketsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
196
196
|
end
|
197
197
|
|
198
|
-
def
|
199
|
-
Morpheus::
|
198
|
+
def archive_files
|
199
|
+
Morpheus::ArchiveFilesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
200
200
|
end
|
201
201
|
|
202
|
-
def
|
203
|
-
Morpheus::
|
202
|
+
def image_builder
|
203
|
+
Morpheus::ImageBuilderInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
204
204
|
end
|
205
205
|
|
206
|
-
def
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
def network_groups
|
211
|
-
Morpheus::NetworkGroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
212
|
-
end
|
213
|
-
|
214
|
-
def network_pools
|
215
|
-
Morpheus::NetworkPoolsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
216
|
-
end
|
217
|
-
|
218
|
-
def network_services
|
219
|
-
Morpheus::NetworkServicesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
220
|
-
end
|
206
|
+
# def image_builds
|
207
|
+
# Morpheus::ImageBuildsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
208
|
+
# end
|
221
209
|
|
222
|
-
def
|
223
|
-
|
224
|
-
end
|
210
|
+
# def preseed_scripts
|
211
|
+
# Morpheus::PreseedScriptsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
212
|
+
# end
|
225
213
|
|
226
|
-
def
|
227
|
-
|
228
|
-
end
|
214
|
+
# def boot_scripts
|
215
|
+
# Morpheus::BootScriptsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
216
|
+
# end
|
229
217
|
|
230
|
-
def network_proxies
|
231
|
-
Morpheus::NetworkProxiesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
232
|
-
end
|
233
218
|
end
|
@@ -36,6 +36,31 @@ class Morpheus::AppTemplatesInterface < Morpheus::APIClient
|
|
36
36
|
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
37
37
|
end
|
38
38
|
|
39
|
+
def save_image(id, options)
|
40
|
+
url = "#{@base_url}/api/app-templates/#{id}"
|
41
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
42
|
+
payload = options
|
43
|
+
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# multipart image upload
|
48
|
+
def save_image(id, image_file, params={})
|
49
|
+
url = "#{@base_url}/api/app-templates/#{id}/image"
|
50
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}"}
|
51
|
+
payload = {}
|
52
|
+
payload[:templateImage] = image_file
|
53
|
+
payload[:multipart] = true
|
54
|
+
execute(method: :post, url: url, headers: headers, payload: payload)
|
55
|
+
end
|
56
|
+
|
57
|
+
def duplicate(id, options)
|
58
|
+
url = "#{@base_url}/api/app-templates/#{id}/duplicate"
|
59
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
60
|
+
payload = options
|
61
|
+
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
62
|
+
end
|
63
|
+
|
39
64
|
def destroy(id)
|
40
65
|
url = "#{@base_url}/api/app-templates/#{id}"
|
41
66
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -49,10 +74,12 @@ class Morpheus::AppTemplatesInterface < Morpheus::APIClient
|
|
49
74
|
execute(method: :get, url: url, headers: headers)
|
50
75
|
end
|
51
76
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
77
|
+
# unused, prefer /options/instanceTypes
|
78
|
+
# def list_types(options={})
|
79
|
+
# url = "#{@base_url}/api/app-templates/types"
|
80
|
+
# headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
81
|
+
# headers[:params].merge!(options)
|
82
|
+
# execute(method: :get, url: url, headers: headers)
|
83
|
+
# end
|
84
|
+
|
85
|
+
end
|
@@ -23,6 +23,24 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
23
23
|
execute(opts)
|
24
24
|
end
|
25
25
|
|
26
|
+
def validate(options)
|
27
|
+
# url = "#{@base_url}/api/apps/validate-instance"
|
28
|
+
url = "#{@base_url}/api/apps/validate"
|
29
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
30
|
+
payload = options
|
31
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
32
|
+
execute(opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate_instance(options)
|
36
|
+
# url = "#{@base_url}/api/apps/validate-instance"
|
37
|
+
url = "#{@base_url}/api/apps/validate-instance"
|
38
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
39
|
+
payload = options
|
40
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
41
|
+
execute(opts)
|
42
|
+
end
|
43
|
+
|
26
44
|
def create(options)
|
27
45
|
url = "#{@base_url}/api/apps"
|
28
46
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -55,9 +73,10 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
55
73
|
execute(opts)
|
56
74
|
end
|
57
75
|
|
58
|
-
def destroy(id)
|
76
|
+
def destroy(id, params={})
|
59
77
|
url = "#{@base_url}/api/apps/#{id}"
|
60
78
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
79
|
+
headers[:params] = params
|
61
80
|
opts = {method: :delete, url: url, headers: headers}
|
62
81
|
execute(opts)
|
63
82
|
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class Morpheus::ArchiveBucketsInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(id, params={})
|
13
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
14
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(id)}"
|
15
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
16
|
+
opts = {method: :get, url: url, headers: headers}
|
17
|
+
execute(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def list(params={})
|
21
|
+
url = "#{@base_url}/api/archives/buckets"
|
22
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
23
|
+
opts = {method: :get, url: url, headers: headers}
|
24
|
+
execute(opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(payload)
|
28
|
+
url = "#{@base_url}/api/archives/buckets"
|
29
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
30
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
31
|
+
execute(opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, payload)
|
35
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(id.to_s)}"
|
36
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
37
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
38
|
+
execute(opts)
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy(id, params={})
|
42
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(id.to_s)}"
|
43
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
44
|
+
opts = {method: :delete, url: url, timeout: 30, headers: headers}
|
45
|
+
execute(opts)
|
46
|
+
end
|
47
|
+
|
48
|
+
def list_files(id, file_path, params={})
|
49
|
+
if file_path.to_s.strip == "/"
|
50
|
+
file_path = ""
|
51
|
+
end
|
52
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(id.to_s)}" + "/files/#{URI.escape(file_path)}".squeeze('/')
|
53
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
54
|
+
opts = {method: :get, url: url, headers: headers}
|
55
|
+
execute(opts)
|
56
|
+
end
|
57
|
+
|
58
|
+
# upload a file without multipart
|
59
|
+
def upload_file(bucket_id, local_file, destination, params={})
|
60
|
+
# puts "upload_file #{local_file} to destination #{destination}"
|
61
|
+
# destination should be the full filePath, but the api looks like directory?filename=
|
62
|
+
path = destination.to_s.squeeze("/")
|
63
|
+
if !path || path == "" || path == "/" || path == "."
|
64
|
+
raise "#{self.class}.upload_file() passed a bad destination: '#{destination}'"
|
65
|
+
end
|
66
|
+
if path[0].chr == "/"
|
67
|
+
path = path[1..-1]
|
68
|
+
end
|
69
|
+
path_chunks = path.split("/")
|
70
|
+
filename = path_chunks.pop
|
71
|
+
safe_dirname = path_chunks.collect {|it| URI.escape(it) }.join("/")
|
72
|
+
# filename = File.basename(destination)
|
73
|
+
# dirname = File.dirname(destination)
|
74
|
+
# if filename == "" || filename == "/"
|
75
|
+
# filename = File.basename(local_file)
|
76
|
+
# end
|
77
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(bucket_id.to_s)}" + "/files/#{safe_dirname}".squeeze('/')
|
78
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/octet-stream'}
|
79
|
+
headers[:params][:filename] = filename # File.basename(destination)
|
80
|
+
if !local_file.kind_of?(File)
|
81
|
+
local_file = File.new(local_file, 'rb')
|
82
|
+
end
|
83
|
+
payload = local_file
|
84
|
+
headers['Content-Length'] = local_file.size # File.size(local_file)
|
85
|
+
execute(method: :post, url: url, headers: headers, payload: payload)
|
86
|
+
end
|
87
|
+
|
88
|
+
def download_bucket_zip_chunked(bucket_id, outfile, params={})
|
89
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(bucket_id.to_s)}" + ".zip"
|
90
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
91
|
+
opts = {method: :get, url: url, headers: headers}
|
92
|
+
# execute(opts, false)
|
93
|
+
if Dir.exists?(outfile)
|
94
|
+
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
95
|
+
end
|
96
|
+
# if @verify_ssl == false
|
97
|
+
# opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
|
98
|
+
# end
|
99
|
+
if @dry_run
|
100
|
+
return opts
|
101
|
+
end
|
102
|
+
http_response = nil
|
103
|
+
File.open(outfile, 'w') {|f|
|
104
|
+
block = proc { |response|
|
105
|
+
response.read_body do |chunk|
|
106
|
+
# writing to #{outfile} ..."
|
107
|
+
f.write chunk
|
108
|
+
end
|
109
|
+
}
|
110
|
+
opts[:block_response] = block
|
111
|
+
http_response = RestClient::Request.new(opts).execute
|
112
|
+
# RestClient::Request.execute(opts)
|
113
|
+
}
|
114
|
+
return http_response
|
115
|
+
end
|
116
|
+
|
117
|
+
def recalc(id, params={})
|
118
|
+
url = "#{@base_url}/api/archives/buckets/#{URI.escape(id.to_s)}/recalc"
|
119
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
120
|
+
opts = {method: :get, url: url, headers: headers, payload: payload.to_json}
|
121
|
+
execute(opts)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
|
3
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
4
|
+
@access_token = access_token
|
5
|
+
@refresh_token = refresh_token
|
6
|
+
@base_url = base_url
|
7
|
+
@expires_at = expires_at
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(file_id, params={})
|
11
|
+
raise "#{self.class}.get() passed a blank id!" if file_id.to_s == ''
|
12
|
+
url = "#{@base_url}/api/archives/files/#{file_id}"
|
13
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
14
|
+
opts = {method: :get, url: url, headers: headers}
|
15
|
+
execute(opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
# full_file_path is $bucketName/$filePath
|
19
|
+
def download_file_by_path(full_file_path, params={})
|
20
|
+
raise "#{self.class}.download_file_by_path() passed a blank file path!" if full_file_path.to_s == ''
|
21
|
+
url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
|
22
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
23
|
+
opts = {method: :get, url: url, headers: headers}
|
24
|
+
execute(opts, false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def download_file_by_path_chunked(full_file_path, outfile, params={})
|
28
|
+
raise "#{self.class}.download_file_by_path_chunked() passed a blank file path!" if full_file_path.to_s == ''
|
29
|
+
url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
|
30
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
31
|
+
opts = {method: :get, url: url, headers: headers}
|
32
|
+
# execute(opts, false)
|
33
|
+
if Dir.exists?(outfile)
|
34
|
+
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
35
|
+
end
|
36
|
+
# if @verify_ssl == false
|
37
|
+
# opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
|
38
|
+
# end
|
39
|
+
if @dry_run
|
40
|
+
return opts
|
41
|
+
end
|
42
|
+
http_response = nil
|
43
|
+
File.open(outfile, 'w') {|f|
|
44
|
+
block = proc { |response|
|
45
|
+
response.read_body do |chunk|
|
46
|
+
# writing to #{outfile} ..."
|
47
|
+
f.write chunk
|
48
|
+
end
|
49
|
+
}
|
50
|
+
opts[:block_response] = block
|
51
|
+
http_response = RestClient::Request.new(opts).execute
|
52
|
+
# RestClient::Request.execute(opts)
|
53
|
+
}
|
54
|
+
return http_response
|
55
|
+
end
|
56
|
+
|
57
|
+
def download_public_file_by_path_chunked(full_file_path, outfile, params={})
|
58
|
+
raise "#{self.class}.download_public_file_by_path_chunked() passed a blank file path!" if full_file_path.to_s == ''
|
59
|
+
url = "#{@base_url}/public-archives/download" + "/#{full_file_path}".squeeze('/')
|
60
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
61
|
+
opts = {method: :get, url: url, headers: headers}
|
62
|
+
# execute(opts, false)
|
63
|
+
if Dir.exists?(outfile)
|
64
|
+
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
65
|
+
end
|
66
|
+
# if @verify_ssl == false
|
67
|
+
# opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
|
68
|
+
# end
|
69
|
+
if @dry_run
|
70
|
+
return opts
|
71
|
+
end
|
72
|
+
http_response = nil
|
73
|
+
File.open(outfile, 'w') {|f|
|
74
|
+
block = proc { |response|
|
75
|
+
response.read_body do |chunk|
|
76
|
+
# writing to #{outfile} ..."
|
77
|
+
f.write chunk
|
78
|
+
end
|
79
|
+
}
|
80
|
+
opts[:block_response] = block
|
81
|
+
http_response = RestClient::Request.new(opts).execute
|
82
|
+
# RestClient::Request.execute(opts)
|
83
|
+
}
|
84
|
+
return http_response
|
85
|
+
end
|
86
|
+
|
87
|
+
def download_file_by_link_chunked(link_key, outfile, params={})
|
88
|
+
raise "#{self.class}.download_file_by_link_chunked() passed a blank file path!" if full_file_path.to_s == ''
|
89
|
+
url = "#{@base_url}/public-archives/link"
|
90
|
+
params['s'] = link_key
|
91
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
92
|
+
opts = {method: :get, url: url, headers: headers}
|
93
|
+
# execute(opts, false)
|
94
|
+
if Dir.exists?(outfile)
|
95
|
+
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
96
|
+
end
|
97
|
+
# if @verify_ssl == false
|
98
|
+
# opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
|
99
|
+
# end
|
100
|
+
if @dry_run
|
101
|
+
return opts
|
102
|
+
end
|
103
|
+
http_response = nil
|
104
|
+
File.open(outfile, 'w') {|f|
|
105
|
+
block = proc { |response|
|
106
|
+
response.read_body do |chunk|
|
107
|
+
# writing to #{outfile} ..."
|
108
|
+
f.write chunk
|
109
|
+
end
|
110
|
+
}
|
111
|
+
opts[:block_response] = block
|
112
|
+
http_response = RestClient::Request.new(opts).execute
|
113
|
+
# RestClient::Request.execute(opts)
|
114
|
+
}
|
115
|
+
return http_response
|
116
|
+
end
|
117
|
+
|
118
|
+
def history(file_id, params={})
|
119
|
+
raise "#{self.class}.history() passed a blank id!" if file_id.to_s == ''
|
120
|
+
url = "#{@base_url}/api/archives/files/#{file_id}/history"
|
121
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
122
|
+
opts = {method: :get, url: url, headers: headers}
|
123
|
+
execute(opts)
|
124
|
+
end
|
125
|
+
|
126
|
+
def list_links(file_id, params={})
|
127
|
+
raise "#{self.class}.links() passed a blank id!" if file_id.to_s == ''
|
128
|
+
url = "#{@base_url}/api/archives/files/#{file_id}/links"
|
129
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
130
|
+
opts = {method: :get, url: url, headers: headers}
|
131
|
+
execute(opts)
|
132
|
+
end
|
133
|
+
|
134
|
+
def create_file_link(file_id, params={})
|
135
|
+
url = "#{@base_url}/api/archives/files/#{file_id}/links"
|
136
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
137
|
+
opts = {method: :post, url: url, headers: headers}
|
138
|
+
execute(opts)
|
139
|
+
end
|
140
|
+
|
141
|
+
def download_file_link(link_key, params={})
|
142
|
+
end
|
143
|
+
|
144
|
+
def destroy_file_link(file_id, link_id, params={})
|
145
|
+
url = "#{@base_url}/api/archives/files/#{file_id}/links/#{link_id}"
|
146
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
147
|
+
opts = {method: :delete, url: url, timeout: 30, headers: headers}
|
148
|
+
execute(opts)
|
149
|
+
end
|
150
|
+
|
151
|
+
# for now upload() and list_files() are available in ArchiveBucketsInterface
|
152
|
+
# the url is like /api/archives/buckets/$id/files
|
153
|
+
|
154
|
+
# def list(params={})
|
155
|
+
# url = "#{@base_url}/api/archives/files"
|
156
|
+
# headers = { params: params, authorization: "Bearer #{@access_token}" }
|
157
|
+
# opts = {method: :get, url: url, headers: headers}
|
158
|
+
# execute(opts)
|
159
|
+
# end
|
160
|
+
|
161
|
+
# def create(payload)
|
162
|
+
# url = "#{@base_url}/api/archives/files"
|
163
|
+
# headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
164
|
+
# opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
165
|
+
# execute(opts)
|
166
|
+
# end
|
167
|
+
|
168
|
+
# def update(id, payload)
|
169
|
+
# url = "#{@base_url}/api/archives/files/#{id}"
|
170
|
+
# headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
171
|
+
# opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
172
|
+
# execute(opts)
|
173
|
+
# end
|
174
|
+
|
175
|
+
def destroy(id, params={})
|
176
|
+
url = "#{@base_url}/api/archives/files/#{id}"
|
177
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
178
|
+
opts = {method: :delete, url: url, timeout: 30, headers: headers}
|
179
|
+
execute(opts)
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|