nvx-sds 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -78,3 +78,11 @@
78
78
  #The master account has a unique set of children and file system per application key but only one set of account contact information. This means each application key is a unique space under the master account. You can read more about this relationship in the official Nirvanix API Documentation.
79
79
  #
80
80
  #As a master account you will not need the password of the child account only the username you wish to impersonate.
81
+ #=== Transcoding
82
+ #
83
+ #There are two transcoding namespaces Audio and Video. The transcode methods let you convert files from one format into another. in the video namespace there is also the ability to extract frames, this is useful for pulling out a certain number of frames from a video or generating thumbnails or preview images.
84
+ #
85
+ #===Searching
86
+ #
87
+ #You can search in three primary ways, file system, Metadata and Tags. Each search method can be called from the session object and returns an array of SearchItem objects.
88
+ #
@@ -44,6 +44,17 @@ module NVX
44
44
  @@logoutcmd
45
45
  end
46
46
 
47
+ @@changepasswordcmd = nil
48
+ def APICommand.ChangePassword
49
+ @@changepasswordcmd = new("Authentication/ChangePassword.ashx", false) unless @@changepasswordcmd
50
+ @@changepasswordcmd
51
+ end
52
+
53
+ @@setchildaccountpasswordcmd = nil
54
+ def APICommand.SetChildAccountPassword
55
+ @@setchildaccountpasswordcmd = new("Authentication/SetChildAccountPassword.ashx", false) unless @@setchildaccountpasswordcmd
56
+ @@setchildaccountpasswordcmd
57
+ end
47
58
 
48
59
  #IMFS Namespace
49
60
 
@@ -119,6 +130,24 @@ module NVX
119
130
  @@getuploadnodecmd
120
131
  end
121
132
 
133
+ @@getdownloadlinkscmd = nil
134
+ def APICommand.GetDownloadLinks
135
+ @@getdownloadlinkscmd = new("IMFS/GetDownloadLinks.ashx", false) unless @@getdownloadlinkscmd
136
+ @@getdownloadlinkscmd
137
+ end
138
+
139
+ @@searchfilesystemcmd = nil
140
+ def APICommand.SearchFileSystem
141
+ @@searchfilesystemcmd = new("IMFS/SearchFileSystem.ashx", false) unless @@searchfilesystemcmd
142
+ @@searchfilesystemcmd
143
+ end
144
+
145
+ @@sideloadcmd = nil
146
+ def APICommand.Sideload
147
+ @@sideloadcmd = new("IMFS/Sideload.ashx", false) unless @@sideloadcmd
148
+ @@sideloadcmd
149
+ end
150
+
122
151
  # MetaData Namespace
123
152
 
124
153
  @@deleteallmetadatacmd = nil
@@ -169,6 +198,30 @@ module NVX
169
198
  @@settagscmd
170
199
  end
171
200
 
201
+ @@searchmetadatacmd = nil
202
+ def APICommand.SearchMetadata
203
+ @@searchmetadatacmd = new("Metadata/SearchMetadata.ashx", false) unless @@searchmetadatacmd
204
+ @@searchmetadatacmd
205
+ end
206
+
207
+ @@searchtagscmd = nil
208
+ def APICommand.SearchTags
209
+ @@searchtagscmd = new("Metadata/SearchTags.ashx", false) unless @@searchtagscmd
210
+ @@searchtagscmd
211
+ end
212
+
213
+ # Image Namespace
214
+ @@imageresizecmd = nil
215
+ def APICommand.ImageResize
216
+ @@imageresizecmd = new("Image/Resize.ashx", false) unless @@imageresizecmd
217
+ @@imageresizecmd
218
+ end
219
+
220
+ @@imagerotateflipcmd = nil
221
+ def APICommand.ImageRotateFlip
222
+ @@imagerotateflipcmd = new("Image/RotateFlip.ashx", false) unless @@imagerotateflipcmd
223
+ @@imagerotateflipcmd
224
+ end
172
225
 
173
226
  # Sharing Namespace
174
227
 
@@ -190,6 +243,27 @@ module NVX
190
243
  @@listhosteditemscmd
191
244
  end
192
245
 
246
+ # Audio Namespace
247
+
248
+ @@audiotranscodecmd = nil
249
+ def APICommand.AudioTranscode
250
+ @@audiotranscodecmd = new("Audio/Transcode.ashx", false) unless @@audiotranscodecmd
251
+ @@audiotranscodecmd
252
+ end
253
+
254
+ # Video Namespace
255
+
256
+ @@videotranscodecmd = nil
257
+ def APICommand.VideoTranscode
258
+ @@videotranscodecmd = new("Video/Transcode.ashx", false) unless @@videotranscodecmd
259
+ @@videotranscodecmd
260
+ end
261
+
262
+ @@extractvideoframescmd = nil
263
+ def APICommand.ExtractVideoFrames
264
+ @@extractvideoframescmd = new("Video/ExtractFrames.ashx", false) unless @@extractvideoframescmd
265
+ @@extractvideoframescmd
266
+ end
193
267
 
194
268
  # Accounting Namespace
195
269
 
@@ -228,6 +302,12 @@ module NVX
228
302
  @@getaccountusagecmd = new("Accounting/GetAccountUsage.ashx", false) unless @@getaccountusagecmd
229
303
  @@getaccountusagecmd
230
304
  end
305
+
306
+ @@listchildaccountscmd = nil
307
+ def APICommand.ListChildAccounts
308
+ @@listchildaccountscmd = new("Accounting/ListChildAccounts.ashx", false) unless @@listchildaccountscmd
309
+ @@listchildaccountscmd
310
+ end
231
311
 
232
312
  @@setaccountinfocmd = nil
233
313
  def APICommand.SetAccountInfo
@@ -1,6 +1,6 @@
1
- # = Overview
2
- # The APIParam object lets you pass parameters to the Transport.execute_command_get and
3
- # Transport.execute_command_post methods. This is an internal class.
1
+ #= Overview
2
+ # The APIParam object lets you pass parameters to the Transport.execute_command_post method.
3
+ # This is an internal class.
4
4
 
5
5
  module NVX
6
6
  module SDS
@@ -231,6 +231,16 @@ module NVX
231
231
  splitpath << new_name
232
232
  @path = splitpath.join("/")
233
233
  end
234
+
235
+ #Saves a URL to the current folder
236
+ def Sideload(url, file_name, callback_url = nil)
237
+ params = [APIParam.new("targetURL", url),
238
+ APIParam.new("destFilePath", @path.to_s + "/" + file_name)]
239
+ params << APIParam.new("callbackURL", callback_url) if !callback_url.nil?
240
+ print params
241
+ Transport.execute_command_post(APICommand.Sideload, params, @account_login)
242
+ end
243
+
234
244
  end
235
245
  end
236
246
  end
@@ -49,6 +49,34 @@ module NVX
49
49
  Transport.execute_command_post(APICommand.DeleteChildAccount, [APIParam.new("username", username)], @account_login)
50
50
  end
51
51
 
52
+ # Changes the child password. The master account needs to reauthenticate with the system to change a
53
+ # childs password.
54
+ def SetChildAccountPassword(master_password, child_username, new_password)
55
+ # The master account needs to reauthenticate with the system to change a childs password.
56
+ params = [APIParam.new("username", @account_login.username),
57
+ APIParam.new("password", master_password),
58
+ APIParam.new("appKey", @account_login.app_key),
59
+ APIParam.new("childAccountUsername", child_username),
60
+ APIParam.new("childAccountPassword", new_password)]
61
+ Transport.execute_command_post(APICommand.SetChildAccountPassword, params, @account_login)
62
+ end
63
+
64
+ def ListChildAccounts(page_number = 1, page_size = 500)
65
+ params = [APIParam.new("pageNumber", page_number),
66
+ APIParam.new("pageSize", page_size)]
67
+ doc = Transport.execute_command_post(APICommand.ListChildAccounts, params, @account_login)
68
+
69
+ child_accounts = Array.new
70
+
71
+ #if there is any metadata loop through
72
+ if doc.root.elements["//Response/Account"]
73
+ doc.root.elements.each("//Response/Account") do |account_name|
74
+ child_accounts << account_name.get_text.value
75
+ end
76
+ end
77
+ return child_accounts
78
+ end
79
+
52
80
  # Gets the account notes in xml.
53
81
  def GetAccountNotes(username)
54
82
  doc = Transport.execute_command_post(APICommand.GetAccountNotes, [APIParam.new("username", username)], @account_login)
@@ -15,7 +15,7 @@ module NVX
15
15
 
16
16
  $:.unshift File.dirname(__FILE__)
17
17
  require 'itembase'
18
-
18
+ require 'apicommand'
19
19
  # = Overview
20
20
  # The File object is used for all file operations. The object is initially retrieved
21
21
  # by calling Session.GetRootFolder and retrieving the .Files array. This is loaded with
@@ -29,7 +29,7 @@ module NVX
29
29
  # print file.name
30
30
  # end
31
31
  class NVXFile < ItemBase
32
-
32
+
33
33
  # initialize the file using the default file attributes from the listFolder
34
34
  # method.
35
35
  def initialize(account_login, fs_file_attributes)
@@ -142,7 +142,8 @@ module NVX
142
142
  # new file will be created. If a callbackURL is defined when the resize process is complete
143
143
  # the URL will be called.
144
144
  def ImageResize(width, height, new_filename = nil, destination_folder = nil, callback_url = nil)
145
- path = @path
145
+ path = @path
146
+ new_path = ""
146
147
  if !destination_folder.nil?
147
148
  new_path = destination_folder
148
149
  end
@@ -156,7 +157,52 @@ module NVX
156
157
  APIParam.new("height", height.to_s)]
157
158
  params << APIParam.new("callbackURL", callback_url) if !callback_url.nil?
158
159
 
159
- Transport.execute_command(APICommands.ImageResize, params, @account_login)
160
+ Transport.execute_command_post(APICommand.ImageResize, params, @account_login)
161
+ end
162
+
163
+ # Rotates and/or flips an image file. If a filename or destination folder is specified a
164
+ # new file will be created. If a callbackURL is defined when the operation is complete
165
+ # the URL will be called.
166
+ #
167
+ # Rotate Values:
168
+ #* RotateNone
169
+ #* Rotate90
170
+ #* Rotate180
171
+ #* Rotate270
172
+ #
173
+ # Flip Values:
174
+ #* FlipNone
175
+ #* FlipHorizontal
176
+ #* FlipVertical
177
+ #* FlipHorizontalVertical
178
+ #
179
+ def ImageRotateFlip(rotate = "RotateNone", flip = "FlipNone", new_filename = nil, destination_folder = nil, callback_url = nil)
180
+ path = @path
181
+ new_path = ""
182
+ if !destination_folder.nil?
183
+ new_path = destination_folder
184
+ end
185
+ if !new_filename.nil?
186
+ new_path += new_filename
187
+ end
188
+
189
+ params = [APIParam.new("srcFilePath", @path),
190
+ APIParam.new("destFilePath", new_path),
191
+ APIParam.new("rotate", rotate.to_s),
192
+ APIParam.new("flip", flip.to_s)]
193
+ params << APIParam.new("callbackURL", callback_url) if !callback_url.nil?
194
+
195
+ Transport.execute_command_post(APICommand.ImageRotateFlip, params, @account_login)
196
+ end
197
+
198
+ # Gets a public download link that will expire after expiration_seconds
199
+ def GetDownloadLink(expiration_seconds, restricted_ip = nil)
200
+ params = [APIParam.new("filePath", @path),
201
+ APIParam.new("expiration", expiration_seconds.to_s)]
202
+ params << APIParam.new("restricted_ip", restricted_ip) if !restricted_ip.nil?
203
+
204
+ doc = Transport.execute_command_post(APICommand.GetDownloadLinks, params, @account_login)
205
+ return doc.root.elements["//Response/Download/DownloadURL"].get_text.value
160
206
  end
161
207
 
162
208
  # Retrieves a Url to the current file.
@@ -0,0 +1,79 @@
1
+ # = Overview
2
+ # The SearchItem object is used for all search results. The object is returned from
3
+ # calls to either
4
+ # session.SearchFileSystem
5
+ # session.SearchMetadata
6
+ # session.SearchTags
7
+ #
8
+ # = Usage
9
+ # session = Session.new("APP-KEY", "USERNAME", "APP NAME", "PASSWORD")
10
+ # search_results_array = session.SearchFileSystem("Beatles*", "Image")
11
+ #
12
+ # search_results_array.each do |search_item|
13
+ # print search_item.name
14
+ # end
15
+ module NVX
16
+ module SDS
17
+
18
+ $:.unshift File.dirname(__FILE__)
19
+
20
+ # = Overview
21
+ # The SearchItem object is used for all search results. The object is returned from
22
+ # calls to either
23
+ # session.SearchFileSystem
24
+ # session.SearchMetadata
25
+ # session.SearchTags
26
+ #
27
+ # = Usage
28
+ # session = Session.new("APP-KEY", "USERNAME", "APP NAME", "PASSWORD")
29
+ # search_results_array = session.SearchFileSystem("Beatles*", "Image")
30
+ #
31
+ # search_results_array.each do |search_item|
32
+ # print search_item.name
33
+ # end
34
+ class SearchItem
35
+ # Takes a single search item in an xml string fragment and populates the object with the
36
+ # values.
37
+ def initialize(xml)
38
+ doc = REXML::Document.new(xml)
39
+
40
+ @name = (text = doc.root.elements["//Item/ItemName"].get_text and text.value)
41
+ @path = (text = doc.root.elements["//Item/ItemPath"].get_text and text.value)
42
+ @created_date = (text = doc.root.elements["//Item/CreatedDate"].get_text and text.value)
43
+ @size_bytes = (text = doc.root.elements["//Item/SizeBytes"].get_text and text.value)
44
+ @file_type = (text = doc.root.elements["//Item/FileType"].get_text and text.value)
45
+ @is_file = (text = doc.root.elements["//Item/IsFile"].get_text and text.value) == "true"
46
+ end
47
+
48
+ # The file / folder name.
49
+ def name
50
+ @name
51
+ end
52
+
53
+ # The full path.
54
+ def path
55
+ @path
56
+ end
57
+
58
+ # Date created or uploaded.
59
+ def created_date
60
+ @created_date
61
+ end
62
+
63
+ # The size
64
+ def size_bytes
65
+ @size_bytes
66
+ end
67
+
68
+ # The file type
69
+ def file_type
70
+ @file_type
71
+ end
72
+
73
+ # If the result is a file or a folder.
74
+ def is_file
75
+ @is_file
76
+ end
77
+ end
78
+ end
79
+ end
@@ -9,6 +9,7 @@ module NVX
9
9
  require 'folder'
10
10
  require 'apiclasses/utilities'
11
11
  require 'hosteditem'
12
+ require 'searchitem'
12
13
 
13
14
  # The session is the primary object for interaction with the Gem. You will use the session to get the root folder and subsiquent
14
15
  # IMFS objects and Accounting objects.
@@ -38,6 +39,16 @@ module NVX
38
39
  @account_login = nil
39
40
  end
40
41
 
42
+ # Changes the password of the current session account.
43
+ def ChangePassword(old_password, new_password)
44
+ params = [APIParam.new("appKey", @account_login.app_key ),
45
+ APIParam.new("username", @account_login.username),
46
+ APIParam.new("oldPassword", old_password),
47
+ APIParam.new("newPassword", new_password)]
48
+
49
+ Transport.execute_command_post(APICommand.ChangePassword, params, @account_login)
50
+ end
51
+
41
52
  # Gets the root folder. You can use this to access all of the files and folders.
42
53
  def GetRootFolder(page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true)
43
54
  folder = Folder.ListFolder(@account_login, @account_login.root_path, page_number, page_size, folder_sort_code, should_sort_descending)
@@ -53,6 +64,97 @@ module NVX
53
64
  return folder
54
65
  end
55
66
 
67
+ # Searches given the parameters through the entire file system.
68
+ # search_term - The search string to look for files and folders. The '*' character may be used at the beginning or end of the string to support wild card searches.
69
+ # Valid File Types:
70
+ #
71
+ #*Unassigned
72
+ #*Document
73
+ #*Executable
74
+ #*Audio
75
+ #*Video
76
+ #*Image
77
+ #
78
+ def SearchFileSystem(search_term, file_type = nil,
79
+ min_created_date = Time.now - (24 * 60 * 60 * (365 * 10)), # Ten years ago
80
+ max_created_date = Time.now + (24 * 60 * 60), # Tomorrow
81
+ max_results = 500, min_file_size = 0, max_file_size = 0, username=nil)
82
+
83
+ converted_min = min_created_date.month.to_s + "/" + min_created_date.day.to_s + "/" + min_created_date.year.to_s
84
+ converted_max = max_created_date.month.to_s + "/" + max_created_date.day.to_s + "/" + max_created_date.year.to_s
85
+
86
+ username = @account_login.username if username == nil
87
+
88
+ params = [APIParam.new("searchTerm", search_term),
89
+ APIParam.new("username", username),
90
+ APIParam.new("minCreatedDate", converted_min),
91
+ APIParam.new("maxCreatedDate", converted_max),
92
+ APIParam.new("maxResults", max_results),
93
+ APIParam.new("minFileSize", min_file_size),
94
+ APIParam.new("maxFileSize", max_file_size)]
95
+ params << APIParam.new("fileType", file_type) if !file_type.nil?
96
+
97
+ doc = Transport.execute_command_post(APICommand.SearchFileSystem, params, @account_login)
98
+
99
+ search_results = Array.new
100
+
101
+ if doc.root.elements["//Response/SearchResults/Item"]
102
+ doc.root.elements.each("//Response/SearchResults/Item") do |search_item|
103
+ search_results << SearchItem.new(search_item.to_s)
104
+ end
105
+ end
106
+
107
+ return search_results
108
+ end
109
+
110
+ # Searches Metadata for specific values.
111
+ # search_term - The metadata value you are looking for. The '*' character may be used at the beginning or end of the string to support wild card searches.
112
+ # search_key - The key that will be searched, examples of this would be height, width, duration or any custom metadata keys.
113
+ def SearchMetadata(search_term, search_key, max_results = 500, username=nil)
114
+
115
+ username = @account_login.username if username == nil
116
+
117
+ params = [APIParam.new("searchTerm", search_term),
118
+ APIParam.new("searchKey", search_key),
119
+ APIParam.new("username", username),
120
+ APIParam.new("maxResults", max_results)]
121
+
122
+ doc = Transport.execute_command_post(APICommand.SearchMetadata, params, @account_login)
123
+
124
+ search_results = Array.new
125
+
126
+ if doc.root.elements["//Response/SearchResults/Item"]
127
+ doc.root.elements.each("//Response/SearchResults/Item") do |search_item|
128
+ search_results << SearchItem.new(search_item.to_s)
129
+ end
130
+ end
131
+
132
+ return search_results
133
+ end
134
+
135
+ # Searches tags for specific values.
136
+ # search_term - The metadata value you are looking for. The '*' character may be used at the beginning or end of the string to support wild card searches.
137
+ def SearchTags(search_term, max_results = 500, username=nil)
138
+
139
+ username = @account_login.username if username == nil
140
+
141
+ params = [APIParam.new("searchTerm", search_term),
142
+ APIParam.new("username", username),
143
+ APIParam.new("maxResults", max_results)]
144
+
145
+ doc = Transport.execute_command_post(APICommand.SearchTags, params, @account_login)
146
+
147
+ search_results = Array.new
148
+
149
+ if doc.root.elements["//Response/SearchResults/Item"]
150
+ doc.root.elements.each("//Response/SearchResults/Item") do |search_item|
151
+ search_results << SearchItem.new(search_item.to_s)
152
+ end
153
+ end
154
+
155
+ return search_results
156
+ end
157
+
56
158
  # Gets the account information as an AccountInfo object from the current session user.
57
159
  def GetAccountInfo
58
160
  Utilities.GetAccountInfo(@account_login, @account_login.username)
@@ -78,6 +180,65 @@ module NVX
78
180
 
79
181
  end
80
182
 
183
+ # Converts an audio to another format
184
+ def AudioTranscode(number_of_frames, frame_rate, number_of_channels)
185
+ params = [APIParam.new("srcFilePath", src_file_path ),
186
+ APIParam.new("destFilePath", dest_file_path),
187
+ APIParam.new("callbackURL", callback_url),
188
+ APIParam.new("numberOfFrames", number_of_frames),
189
+ APIParam.new("frameRate", frame_rate),
190
+ APIParam.new("numberOfChannels", number_of_channels)]
191
+
192
+ Transport.execute_command_post(APICommand.AudioTranscode, params, @account_login)
193
+ end
194
+
195
+ # Converts a video to another format
196
+ def VideoTranscode(src_file_path, dest_file_path, callback_url,
197
+ number_of_frames, frame_rate, aspect_ratio, width, height)
198
+
199
+ params = [APIParam.new("srcFilePath", src_file_path),
200
+ APIParam.new("destFilePath", dest_file_path),
201
+ APIParam.new("callbackURL", callback_url),
202
+ APIParam.new("frameRate", frame_rate),
203
+ APIParam.new("aspectRatio", aspect_ratio),
204
+ APIParam.new("numberOfFrames", number_of_frames),
205
+ APIParam.new("width", width),
206
+ APIParam.new("height", height)]
207
+
208
+ Transport.execute_command_post(APICommand.VideoTranscode, params, @account_login)
209
+ end
210
+
211
+ # Gets a public download link that will expire after expiration_seconds
212
+ def GetDownloadLinks(file_paths, expiration_seconds, restricted_ip = nil)
213
+ params = [APIParam.new("expiration", expiration_seconds.to_s)]
214
+
215
+ file_paths.each do |path|
216
+ params << APIParam.new("filePath", path)
217
+ end
218
+ params << APIParam.new("restricted_ip", restricted_ip) if !restricted_ip.nil?
219
+
220
+ doc = Transport.execute_command_post(APICommand.GetDownloadLinks, params, @account_login)
221
+ download_links = Array.new
222
+
223
+ #if there is any metadata loop through
224
+ if doc.root.elements["//Response/Download/DownloadURL"]
225
+ doc.root.elements.each("//Response/Download/DownloadURL") do |link|
226
+ download_links << link.get_text.value
227
+ end
228
+ end
229
+ return download_links
230
+ end
231
+
232
+ #Saves a url to the file path specified and optionally calls back to a url.
233
+ def Sideload(url, destination_file_path, callback_url = nil)
234
+ params = [APIParam.new("targetUrl", url),
235
+ APIParam.new("destFilePath", destination_file_path)]
236
+ params << APIParam.new("callbackUrl", callback_url) if !callback_url.nil?
237
+
238
+ Transport.execute_command_post(APICommand.Sideload, params, @account_login)
239
+ end
240
+
241
+
81
242
  # Deletes all the files from an array of strings passed.
82
243
  def DeleteFiles(file_paths_to_delete)
83
244
  params = Array.new
@@ -22,40 +22,6 @@ module NVX
22
22
  # Requests can be made via HTTP GET or POST.
23
23
  class Transport
24
24
 
25
- # A method to execute a nirvanix command with the parameters passed via a GET HTTP call.
26
- # be aware that the parameters passed to this command will be limited in size due to the maximum
27
- # url length allowed by http. With calls that require many parameters such as array be sure to use
28
- # the post method.
29
- def Transport.execute_command_get(apicommand, apiparams, account_login)
30
- rest_api_url = "services.nirvanix.com"
31
- webservice_root = "/ws/"
32
-
33
- url = webservice_root + apicommand.command_path
34
-
35
- apiparams = Array.new if apiparams.nil?
36
- apiparams << APIParam.new("sessionToken", account_login.session_token) if !account_login.nil?
37
-
38
- first = true
39
- apiparams.each {|apiParam|
40
- url = first == true ? url + '?' + apiParam.to_s : url + '&' + apiParam.to_s
41
- first = false
42
- }
43
-
44
- #print "OUTPUT URL: " + url + "\r\n\r\n"
45
-
46
- port = apicommand.is_secure? ? 443 : 80
47
-
48
- http = Net::HTTP.new(rest_api_url, port)
49
- http.use_ssl = apicommand.is_secure?
50
- http.start do |http|
51
- request = Net::HTTP::Get.new(url)
52
- response = http.request(request)
53
- response.value
54
- #print "RESPONSE XML: " + response.body + "\r\n\r\n"
55
- return REXML::Document.new(response.body)
56
- end
57
- end
58
-
59
25
  # A method to execute a nirvanix command with the parameters passed via a POST HTTP call.
60
26
  def Transport.execute_command_post(apicommand, apiparams, account_login)
61
27
  rest_api_url = "services.nirvanix.com"
data/lib/nvx_sds.rb CHANGED
@@ -12,6 +12,7 @@ require File.join( dir, "apiparam" )
12
12
  require File.join( dir, "countries" )
13
13
  require File.join( dir, "folder" )
14
14
  require File.join( dir, "session" )
15
+ require File.join( dir, "searchitem" )
15
16
  require File.join( dir, "transport" )
16
17
  require File.join( dir, "masteraccount" )
17
18
  require File.join( dir, "apiclasses/soapupload" )
@@ -11,8 +11,8 @@ class AccountLoginTest < Test::Unit::TestCase
11
11
  def test_Login
12
12
  accountLogin = AccountLogin.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
13
13
  accountLogin.Login
14
- assert accountLogin.username == "uploadtest"
15
- assert accountLogin.app_name == "Upload Test"
14
+ assert accountLogin.username == "rubytest"
15
+ assert accountLogin.app_name == "Ruby Test"
16
16
  assert accountLogin.session_token != nil
17
17
  print "Session Token: " + accountLogin.session_token
18
18
  end
@@ -17,6 +17,16 @@ class APICommandTest < Test::Unit::TestCase
17
17
  assert APICommand.Logout.command_path == "Authentication/Logout.ashx"
18
18
  assert !APICommand.Logout.is_secure?
19
19
  end
20
+
21
+ def test_ChangePassword
22
+ assert APICommand.ChangePassword.command_path == "Authentication/ChangePassword.ashx"
23
+ assert !APICommand.ChangePassword.is_secure?
24
+ end
25
+
26
+ def test_SetChildAccountPassword
27
+ assert APICommand.SetChildAccountPassword.command_path == "Authentication/SetChildAccountPassword.ashx"
28
+ assert !APICommand.SetChildAccountPassword.is_secure?
29
+ end
20
30
 
21
31
  #IMFS Namespace tests
22
32
  def test_ListFolder
@@ -79,8 +89,18 @@ class APICommandTest < Test::Unit::TestCase
79
89
  assert !APICommand.GetUploadNode.is_secure?
80
90
  end
81
91
 
92
+ def test_GetDownloadLinks
93
+ assert APICommand.GetDownloadLinks.command_path == "IMFS/GetDownloadLinks.ashx"
94
+ assert !APICommand.GetDownloadLinks.is_secure?
95
+ end
96
+
97
+ def test_SearchFileSystem
98
+ assert APICommand.SearchFileSystem.command_path == "IMFS/SearchFileSystem.ashx"
99
+ assert !APICommand.SearchFileSystem.is_secure?
100
+ end
82
101
 
83
102
  # MetaData Namespace
103
+
84
104
  def test_DeleteAllMetadata
85
105
  assert APICommand.DeleteAllMetadata.command_path == "Metadata/DeleteAllMetadata.ashx"
86
106
  assert !APICommand.DeleteAllMetadata.is_secure?
@@ -121,7 +141,37 @@ class APICommandTest < Test::Unit::TestCase
121
141
  assert !APICommand.SetTags.is_secure?
122
142
  end
123
143
 
144
+ def test_SearchMetadata
145
+ assert APICommand.SearchMetadata.command_path == "Metadata/SearchMetadata.ashx"
146
+ assert !APICommand.SearchMetadata.is_secure?
147
+ end
148
+
149
+ def test_SearchTags
150
+ assert APICommand.SearchTags.command_path == "Metadata/SearchTags.ashx"
151
+ assert !APICommand.SearchTags.is_secure?
152
+ end
153
+
154
+ # Audio Namespace
155
+
156
+ def test_AudioTranscode
157
+ assert APICommand.AudioTranscode.command_path == "Audio/Transcode.ashx"
158
+ assert !APICommand.AudioTranscode.is_secure?
159
+ end
160
+
161
+ # Video Namespace
162
+
163
+ def test_ExtractVideoFrames
164
+ assert APICommand.ExtractVideoFrames.command_path == "Video/ExtractFrames.ashx"
165
+ assert !APICommand.ExtractVideoFrames.is_secure?
166
+ end
167
+
168
+ def test_VideoTranscode
169
+ assert APICommand.VideoTranscode.command_path == "Video/Transcode.ashx"
170
+ assert !APICommand.VideoTranscode.is_secure?
171
+ end
172
+
124
173
  # Sharing Namespace
174
+
125
175
  def test_CreateHostedItem
126
176
  assert APICommand.CreateHostedItem.command_path == "Sharing/CreateHostedItem.ashx"
127
177
  assert !APICommand.CreateHostedItem.is_secure?
@@ -137,6 +187,17 @@ class APICommandTest < Test::Unit::TestCase
137
187
  assert !APICommand.ListHostedItems.is_secure?
138
188
  end
139
189
 
190
+ #Image Namespace
191
+ def test_ImageResize
192
+ assert APICommand.ImageResize.command_path == "Image/Resize.ashx"
193
+ assert !APICommand.ImageResize.is_secure?
194
+ end
195
+
196
+ def test_ImageRotateFlip
197
+ assert APICommand.ImageRotateFlip.command_path == "Image/RotateFlip.ashx"
198
+ assert !APICommand.ImageRotateFlip.is_secure?
199
+ end
200
+
140
201
  # Accounting Namespace
141
202
  def test_CreateChildAccount
142
203
  assert APICommand.CreateChildAccount.command_path == "Accounting/CreateChildAccount.ashx"
@@ -168,6 +229,11 @@ class APICommandTest < Test::Unit::TestCase
168
229
  assert !APICommand.GetAccountUsage.is_secure?
169
230
  end
170
231
 
232
+ def test_ListChildAccounts
233
+ assert APICommand.ListChildAccounts.command_path == "Accounting/ListChildAccounts.ashx"
234
+ assert !APICommand.ListChildAccounts.is_secure?
235
+ end
236
+
171
237
  def test_SetAccountInfo
172
238
  assert APICommand.SetAccountInfo.command_path == "Accounting/SetAccountInfo.ashx"
173
239
  assert !APICommand.SetAccountInfo.is_secure?
data/tests/foldertest.rb CHANGED
@@ -19,7 +19,16 @@ class FolderTest < Test::Unit::TestCase
19
19
  #page_number, page_size, folder_sort_code, should_sort_descending)
20
20
  root_folder = session.GetRootFolder(1, 500, "Name", true)
21
21
  print "total_folder_count" + root_folder.total_folder_count.to_s
22
- assert root_folder.total_folder_count == 5
22
+ assert root_folder.total_folder_count > 0
23
+ end
24
+
25
+ def test_FolderSideload
26
+
27
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
28
+ #page_number, page_size, folder_sort_code, should_sort_descending)
29
+ root_folder = session.GetRootFolder(1, 500, "Name", true)
30
+ root_folder.Sideload("http://www.nirvanix.com/default.aspx", "default.aspx")
31
+ # since this is done as a background process we can't check the results just the initial call.
23
32
  end
24
33
 
25
34
 
@@ -35,6 +35,15 @@ class MasterAccountTest < Test::Unit::TestCase
35
35
  masteraccount.DeleteChildAccount("deletechildtest")
36
36
  end
37
37
 
38
+ def test_ListChildAccounts
39
+ session = Session.new(APP_KEY, MASTERUSERNAME, APP_NAME, MASTERPASSWORD)
40
+ masteraccount = session.GetMasterAccount
41
+ assert masteraccount.ListChildAccounts.length > 0
42
+ masteraccount.ListChildAccounts.each do |account_name|
43
+ print account_name
44
+ end
45
+ end
46
+
38
47
  def test_AccountNotesSetGet
39
48
  session = Session.new(APP_KEY, MASTERUSERNAME, APP_NAME, MASTERPASSWORD)
40
49
  masteraccount = session.GetMasterAccount
@@ -66,4 +75,28 @@ class MasterAccountTest < Test::Unit::TestCase
66
75
  account_info = child_session.GetAccountInfo
67
76
  assert account_info.username.to_s == "testchildcreate"
68
77
  end
78
+
79
+ def test_ChangeChildAccountPassword
80
+ session = Session.new(APP_KEY, MASTERUSERNAME, APP_NAME, MASTERPASSWORD)
81
+ masteraccount = session.GetMasterAccount
82
+
83
+ begin
84
+ masteraccount.DeleteChildAccount("testchildcreate")
85
+ masteraccount.CreateChildAccount("testchildcreate", "somepass")
86
+ rescue
87
+ # Just a temp account to test notes with. It may already exist from
88
+ # an earlier test.
89
+ end
90
+
91
+ # Try logging into the child account
92
+ session = Session.new(APP_KEY, "testchildcreate", APP_NAME, "somepass")
93
+ session.Logout
94
+
95
+
96
+ masteraccount.SetChildAccountPassword(MASTERPASSWORD, "testchildcreate", "newpass")
97
+
98
+ # Try logging into the child account with the new password
99
+ session = Session.new(APP_KEY, "testchildcreate", APP_NAME, "newpass")
100
+ session.Logout
101
+ end
69
102
  end
data/tests/sessiontest.rb CHANGED
@@ -26,6 +26,17 @@ class SessionTest < Test::Unit::TestCase
26
26
  session.Logout
27
27
  end
28
28
 
29
+ def test_ChangePassword
30
+ # validate the session is destroyed after a logout
31
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
32
+ session.ChangePassword(PASSWORD, "TESTPASS")
33
+ session.Logout
34
+
35
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, "TESTPASS")
36
+ session.ChangePassword("TESTPASS", PASSWORD)
37
+ session.Logout
38
+ end
39
+
29
40
  def test_GetRootFolder
30
41
  session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
31
42
  root_folder = session.GetRootFolder(1, 500, 0, true)
@@ -126,8 +137,107 @@ class SessionTest < Test::Unit::TestCase
126
137
 
127
138
  root_folder = session.GetRootFolder(1, 500, 0, true)
128
139
  root_folder.files[0].DownloadToLocalFile("c:\\test123.txt")
129
- download_url = root_folder.files[1].GetDownloadUrl
140
+ download_url = root_folder.files[0].GetDownloadUrl
130
141
  assert !download_url.nil?
142
+
143
+ end
144
+
145
+ def test_GetDownloadLink
146
+
147
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
148
+
149
+ root_folder = session.GetRootFolder(1, 500, 0, true)
150
+ # Get a link valid for 100 seconds
151
+ download_link = root_folder.files[0].GetDownloadLink(100)
152
+ print download_link
153
+ assert !download_link.nil?
154
+ end
155
+
156
+ def test_SearchFileSystem
157
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
158
+
159
+ search_results = session.SearchFileSystem("*", "Image")
160
+ assert search_results.length > 0
161
+ search_results.each do |item|
162
+ print item.name
163
+ end
164
+ end
165
+
166
+ def test_SearchMetadata
167
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
168
+
169
+ search_results = session.SearchMetadata("*", "Width")
170
+ assert search_results.length > 0
171
+ search_results.each do |item|
172
+ print item.name
173
+ end
174
+ end
175
+
176
+ def test_SearchTags
177
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
178
+
179
+ root_folder = session.GetRootFolder(1, 500, 0, true)
180
+ root_folder.files[0].SetTags(["TestTag"])
181
+
182
+ search_results = session.SearchTags("BadTag")
183
+ assert search_results.length == 0
184
+
185
+ search_results = session.SearchTags("TestTag")
186
+ assert search_results.length > 0
187
+
188
+ search_results.each do |item|
189
+ print item.name
190
+ end
191
+ end
192
+
193
+ def test_Sideload
194
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
195
+
196
+ begin
197
+ session.DeleteFiles(["/default.aspx"])
198
+ rescue
199
+
200
+ end
201
+
202
+ # No assert since this is an processing job that happens async to the call.
203
+ session.Sideload("http://www.nirvanix.com/default.aspx", "/default.aspx")
204
+ end
205
+
206
+ def test_GetDownloadLinks
207
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
208
+
209
+ root_folder = session.GetRootFolder(1, 500, 0, true)
210
+ # Get a link valid for 100 seconds
211
+ download_links = session.GetDownloadLinks([root_folder.files[0].path], 100)
212
+ assert download_links.length == 1
213
+ end
214
+
215
+ def test_ImageResize
216
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
217
+
218
+ begin
219
+ session.DeleteFiles(["/resizedimage.jpg"])
220
+ rescue
221
+ # allow delete to fail we can't delete directly after because processing does the
222
+ # work async to the call.
223
+ end
224
+
225
+ root_folder = session.GetRootFolder(1, 500, 0, true)
226
+ root_folder.files[1].ImageResize(100, 100, "resizedimage.jpg")
227
+ end
228
+
229
+ def test_ImageRotateFlip
230
+ session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
231
+
232
+ begin
233
+ session.DeleteFiles(["/rotateflipimage.jpg"])
234
+ rescue
235
+ # allow delete to fail we can't delete directly after because processing does the
236
+ # work async to the call.
237
+ end
238
+
239
+ root_folder = session.GetRootFolder(1, 500, 0, true)
240
+ root_folder.files[1].ImageRotateFlip("Rotate90", "FlipVertical", "rotateflipimage.jpg")
131
241
  end
132
242
 
133
243
  def test_AccountSetGet
@@ -138,7 +248,7 @@ class SessionTest < Test::Unit::TestCase
138
248
 
139
249
  account_info = session.GetAccountInfo
140
250
  assert account_info.contact.first_name.to_s == "First"
141
- assert account_info.username.to_s == "uploadtest"
251
+ assert account_info.username.to_s == "rubytest"
142
252
  end
143
253
 
144
254
  def test_AccountLimits
data/tests/testconfig.rb CHANGED
@@ -2,13 +2,13 @@
2
2
  # If you do not already have a Nirvanix account go to http://nmp.nirvanix.com/ and sign up.
3
3
 
4
4
  # Replace these values with your own to run unit tests.
5
- APP_KEY = "FB8EC93D-B266-49E8-9CC6-4381D1E2D69D"
6
- APP_NAME = "Upload Test"
5
+ APP_KEY = "E91A7EC7-6714-4BB7-B7A4-61644854C523"
6
+ APP_NAME = "test app"
7
7
 
8
8
  # Below is the information for testing a child or master account.
9
- USERNAME = "childtest"
9
+ USERNAME = "rubytest"
10
10
  PASSWORD = "testpass"
11
11
 
12
12
  # Below is the master account information for testing the master account calls.
13
- MASTERUSERNAME = "mastertest"
13
+ MASTERUSERNAME = "masterrubytest"
14
14
  MASTERPASSWORD = "testpass"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: nvx-sds
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2007-10-08 00:00:00 -07:00
6
+ version: 1.0.0
7
+ date: 2007-10-16 00:00:00 -07:00
8
8
  summary: A package for accessing the Nirvanix SDS allowing remote file storage, retrieval and account operations.
9
9
  require_paths:
10
10
  - lib
@@ -39,6 +39,7 @@ files:
39
39
  - lib/nvx/sds/itembase.rb
40
40
  - lib/nvx/sds/masteraccount.rb
41
41
  - lib/nvx/sds/nvxfile.rb
42
+ - lib/nvx/sds/searchitem.rb
42
43
  - lib/nvx/sds/session.rb
43
44
  - lib/nvx/sds/transport.rb
44
45
  - lib/nvx/sds/APIClasses/accountfeatureusage.rb