Class: Aspose::Cloud::Tasks::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/resources.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Resources

Returns a new instance of Resources.



22
23
24
25
26
# File 'lib/tasks/resources.rb', line 22

def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri =  Aspose::Cloud::Common::Product.product_uri + '/tasks/' + @filename
end

Instance Method Details

#add_resource(resource_name, after_resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/tasks/resources.rb', line 44

def add_resource(resource_name, after_resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'resource_name not specified.' if resource_name.empty?
  raise 'after_resource_id not specified.' if after_resource_id.nil?

  str_uri = "#{@base_uri}/resources"
  qry = { :resourceName => resource_name, :afterResourceId => after_resource_id }
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)

  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  JSON.parse(RestClient.post(signed_str_uri, '', {:accept=>'application/json'}))['ResourceItem']
end

#delete_resource(resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/tasks/resources.rb', line 58

def delete_resource(resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'resource_id not specified.' if resource_id.nil?

  str_uri = "#{@base_uri}/resources/#{resource_id}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))
end

#get_resource(resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/tasks/resources.rb', line 35

def get_resource(resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'resource_id not specified.' if resource_id.nil?

  str_uri = "#{@base_uri}/resources/#{resource_id}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Resource']
end

#get_resources(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object



28
29
30
31
32
33
# File 'lib/tasks/resources.rb', line 28

def get_resources(folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/resources"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Resources']['ResourceItem']
end