Class: Akamai::Netstorage

Inherits:
Object
  • Object
show all
Defined in:
lib/akamai/netstorage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, keyname, key) ⇒ Netstorage

Returns a new instance of Netstorage.



32
33
34
35
36
# File 'lib/akamai/netstorage.rb', line 32

def initialize(hostname, keyname, key)
    @hostname = hostname
    @keyname = keyname
    @key = key
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



30
31
32
# File 'lib/akamai/netstorage.rb', line 30

def hostname
  @hostname
end

#keyObject

Returns the value of attribute key.



30
31
32
# File 'lib/akamai/netstorage.rb', line 30

def key
  @key
end

#keynameObject

Returns the value of attribute keyname.



30
31
32
# File 'lib/akamai/netstorage.rb', line 30

def keyname
  @keyname
end

Instance Method Details

#delete(ns_path) ⇒ Object



149
150
151
152
153
# File 'lib/akamai/netstorage.rb', line 149

def delete(ns_path)
    return _request(action: "delete",
                    method: "POST",
                    path: ns_path)
end

#dir(ns_path) ⇒ Object



106
107
108
109
110
# File 'lib/akamai/netstorage.rb', line 106

def dir(ns_path)
    return _request(action: "dir&format=xml",
                    method: "GET",
                    path: ns_path)
end

#download(ns_source, local_destination = '') ⇒ Object



112
113
114
115
116
117
# File 'lib/akamai/netstorage.rb', line 112

def download(ns_source, local_destination='')
    return _request(action: "download",
                    method: "GET",
                    path: ns_source,
                    destination: local_destination)
end

#du(ns_path) ⇒ Object



119
120
121
122
123
# File 'lib/akamai/netstorage.rb', line 119

def du(ns_path)
    return _request(action: "du&format=xml",
                    method: "GET",
                    path: ns_path)
end

#mkdir(ns_path) ⇒ Object



131
132
133
134
135
# File 'lib/akamai/netstorage.rb', line 131

def mkdir(ns_path)
    return _request(action: "mkdir",
                    method: "POST",
                    path: ns_path)
end

#mtime(ns_path, mtime) ⇒ Object



143
144
145
146
147
# File 'lib/akamai/netstorage.rb', line 143

def mtime(ns_path, mtime)
    return _request(action: "mtime&format=xml&mtime=#{mtime}",
                    method: "POST",
                    path: ns_path)
end

#quick_delete(ns_path) ⇒ Object



155
156
157
158
159
# File 'lib/akamai/netstorage.rb', line 155

def quick_delete(ns_path)
    return _request(action: "quick-delete&quick-delete=imreallyreallysure",
                    method: "POST",
                    path: ns_path)
end

#rename(ns_target, ns_destination) ⇒ Object



161
162
163
164
165
# File 'lib/akamai/netstorage.rb', line 161

def rename(ns_target, ns_destination)
    return _request(action: "rename&destination=#{CGI::escape(ns_destination)}",
                    method: "POST",
                    path: ns_target)
end

#rmdir(ns_path) ⇒ Object



137
138
139
140
141
# File 'lib/akamai/netstorage.rb', line 137

def rmdir(ns_path)
    return _request(action: "rmdir",
                    method: "POST",
                    path: ns_path)
end

#stat(ns_path) ⇒ Object



125
126
127
128
129
# File 'lib/akamai/netstorage.rb', line 125

def stat(ns_path)
    return _request(action: "stat&format=xml",
                    method: "GET",
                    path: ns_path)
end


167
168
169
170
171
# File 'lib/akamai/netstorage.rb', line 167

def symlink(ns_target, ns_destination)
    return _request(action: "symlink&target=#{CGI::escape(ns_target)}",
                    method: "POST",
                    path: ns_destination)
end

#upload(local_source, ns_destination) ⇒ Object



173
174
175
176
177
178
179
180
181
# File 'lib/akamai/netstorage.rb', line 173

def upload(local_source, ns_destination)
    if File.file?(local_source) && ns_destination[-1] == "/" 
        ns_destination = "#{ns_destination}#{File.basename(local_source)}"
    end
    return _request(action: "upload",
                    method: "PUT",
                    source: local_source,
                    path: ns_destination) 
end