class Aspose::Cloud::Tasks::Resources

Public Class Methods

new(filename) click to toggle source
# File lib/tasks/resources.rb, line 5
def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri =  Aspose::Cloud::Common::Product.product_uri + '/tasks/' + @filename
end

Public Instance Methods

add_resource(resource_name, after_resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '') click to toggle source

Add a Resource to Project @param number resource_name The Name of the new resource. @param number after_resource_id The id of the resource to insert the new resource after.

# File lib/tasks/resources.rb, line 39
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 = '') click to toggle source

Delete Resource form Project @param number resource_id The id of the resource.

# File lib/tasks/resources.rb, line 57
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 = JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))
  json['Code'] == 200 ? true : false
end
get_resource(resource_id, folder_name = '', storage_type = 'Aspose', storage_name = '') click to toggle source

Get a Particular Resource form Project @param number resource_id The id of the resource.

# File lib/tasks/resources.rb, line 25
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 = '') click to toggle source

Get all Resources form Project

# File lib/tasks/resources.rb, line 14
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