Class: Files::RemoteServer

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/remote_server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ RemoteServer

Returns a new instance of RemoteServer.



7
8
9
10
# File 'lib/files.com/models/remote_server.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/remote_server.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/remote_server.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



264
265
266
# File 'lib/files.com/models/remote_server.rb', line 264

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

aws_access_key - string - AWS Access Key.
aws_secret_key - string - AWS secret key.
password - string - Password if needed.
private_key - string - Private key if needed.
hostname - string - Hostname or IP address
name - string - Internal name for your reference
max_connections - integer - Max number of parallel connections.  Ignored for S3 connections (we will parallelize these as much as possible).
port - integer - Port for remote server.  Not needed for S3.
s3_bucket - string - S3 bucket name
s3_region - string - S3 region
server_certificate - string - Remote server certificate
server_type - string - Remote server type.
ssl - string - Should we require SSL?
username - string - Remote server username.  Not needed for S3 buckets.
google_cloud_storage_bucket - string - Google Cloud Storage bucket name
google_cloud_storage_project_id - string - Google Cloud Project ID
google_cloud_storage_credentials_json - string - A JSON file that contains the private key. To generate see https://cloud.google.com/storage/docs/json_api/v1/how-tos/authorizing#APIKey


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/files.com/models/remote_server.rb', line 302

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: aws_access_key must be an String") if params.dig(:aws_access_key) and !params.dig(:aws_access_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: aws_secret_key must be an String") if params.dig(:aws_secret_key) and !params.dig(:aws_secret_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params.dig(:private_key) and !params.dig(:private_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: hostname must be an String") if params.dig(:hostname) and !params.dig(:hostname).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: max_connections must be an Integer") if params.dig(:max_connections) and !params.dig(:max_connections).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: port must be an Integer") if params.dig(:port) and !params.dig(:port).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: s3_bucket must be an String") if params.dig(:s3_bucket) and !params.dig(:s3_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: s3_region must be an String") if params.dig(:s3_region) and !params.dig(:s3_region).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_certificate must be an String") if params.dig(:server_certificate) and !params.dig(:server_certificate).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_type must be an String") if params.dig(:server_type) and !params.dig(:server_type).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: ssl must be an String") if params.dig(:ssl) and !params.dig(:ssl).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_bucket must be an String") if params.dig(:google_cloud_storage_bucket) and !params.dig(:google_cloud_storage_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_project_id must be an String") if params.dig(:google_cloud_storage_project_id) and !params.dig(:google_cloud_storage_project_id).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_credentials_json must be an String") if params.dig(:google_cloud_storage_credentials_json) and !params.dig(:google_cloud_storage_credentials_json).is_a?(String)

  response, options = Api.send_request("/remote_servers", :post, params, options)
  RemoteServer.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



370
371
372
373
374
375
376
377
378
# File 'lib/files.com/models/remote_server.rb', line 370

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/remote_servers/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



380
381
382
# File 'lib/files.com/models/remote_server.rb', line 380

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - integer - Remote Server ID.


270
271
272
273
274
275
276
277
278
# File 'lib/files.com/models/remote_server.rb', line 270

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/remote_servers/#{params[:id]}", :get, params, options)
  RemoteServer.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



280
281
282
# File 'lib/files.com/models/remote_server.rb', line 280

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

page - integer - Current page number.
per_page - integer - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.


255
256
257
258
259
260
261
262
# File 'lib/files.com/models/remote_server.rb', line 255

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)

  response, options = Api.send_request("/remote_servers", :get, params, options)
  response.data.map { |object| RemoteServer.new(object, options) }
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

aws_access_key - string - AWS Access Key.
aws_secret_key - string - AWS secret key.
password - string - Password if needed.
private_key - string - Private key if needed.
hostname - string - Hostname or IP address
name - string - Internal name for your reference
max_connections - integer - Max number of parallel connections.  Ignored for S3 connections (we will parallelize these as much as possible).
port - integer - Port for remote server.  Not needed for S3.
s3_bucket - string - S3 bucket name
s3_region - string - S3 region
server_certificate - string - Remote server certificate
server_type - string - Remote server type.
ssl - string - Should we require SSL?
username - string - Remote server username.  Not needed for S3 buckets.
google_cloud_storage_bucket - string - Google Cloud Storage bucket name
google_cloud_storage_project_id - string - Google Cloud Project ID
google_cloud_storage_credentials_json - string - A JSON file that contains the private key. To generate see https://cloud.google.com/storage/docs/json_api/v1/how-tos/authorizing#APIKey


343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/files.com/models/remote_server.rb', line 343

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: aws_access_key must be an String") if params.dig(:aws_access_key) and !params.dig(:aws_access_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: aws_secret_key must be an String") if params.dig(:aws_secret_key) and !params.dig(:aws_secret_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params.dig(:private_key) and !params.dig(:private_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: hostname must be an String") if params.dig(:hostname) and !params.dig(:hostname).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: max_connections must be an Integer") if params.dig(:max_connections) and !params.dig(:max_connections).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: port must be an Integer") if params.dig(:port) and !params.dig(:port).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: s3_bucket must be an String") if params.dig(:s3_bucket) and !params.dig(:s3_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: s3_region must be an String") if params.dig(:s3_region) and !params.dig(:s3_region).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_certificate must be an String") if params.dig(:server_certificate) and !params.dig(:server_certificate).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_type must be an String") if params.dig(:server_type) and !params.dig(:server_type).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: ssl must be an String") if params.dig(:ssl) and !params.dig(:ssl).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_bucket must be an String") if params.dig(:google_cloud_storage_bucket) and !params.dig(:google_cloud_storage_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_project_id must be an String") if params.dig(:google_cloud_storage_project_id) and !params.dig(:google_cloud_storage_project_id).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_credentials_json must be an String") if params.dig(:google_cloud_storage_credentials_json) and !params.dig(:google_cloud_storage_credentials_json).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/remote_servers/#{params[:id]}", :patch, params, options)
  RemoteServer.new(response.data, options)
end

Instance Method Details

#authentication_methodObject

string - Type of authentication method



22
23
24
# File 'lib/files.com/models/remote_server.rb', line 22

def authentication_method
  @attributes[:authentication_method]
end

#authentication_method=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/remote_server.rb', line 26

def authentication_method=(value)
  @attributes[:authentication_method] = value
end

#aws_access_keyObject

string - AWS Access Key.



148
149
150
# File 'lib/files.com/models/remote_server.rb', line 148

def aws_access_key
  @attributes[:aws_access_key]
end

#aws_access_key=(value) ⇒ Object



152
153
154
# File 'lib/files.com/models/remote_server.rb', line 152

def aws_access_key=(value)
  @attributes[:aws_access_key] = value
end

#aws_secret_keyObject

string - AWS secret key.



157
158
159
# File 'lib/files.com/models/remote_server.rb', line 157

def aws_secret_key
  @attributes[:aws_secret_key]
end

#aws_secret_key=(value) ⇒ Object



161
162
163
# File 'lib/files.com/models/remote_server.rb', line 161

def aws_secret_key=(value)
  @attributes[:aws_secret_key] = value
end

#delete(params = {}) ⇒ Object



228
229
230
231
232
233
234
235
236
# File 'lib/files.com/models/remote_server.rb', line 228

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/remote_servers/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



238
239
240
# File 'lib/files.com/models/remote_server.rb', line 238

def destroy(params = {})
  delete(params)
end

#google_cloud_storage_bucketObject

string - Google Cloud Storage bucket name



121
122
123
# File 'lib/files.com/models/remote_server.rb', line 121

def google_cloud_storage_bucket
  @attributes[:google_cloud_storage_bucket]
end

#google_cloud_storage_bucket=(value) ⇒ Object



125
126
127
# File 'lib/files.com/models/remote_server.rb', line 125

def google_cloud_storage_bucket=(value)
  @attributes[:google_cloud_storage_bucket] = value
end

#google_cloud_storage_credentials_jsonObject

string - A JSON file that contains the private key. To generate see cloud.google.com/storage/docs/json_api/v1/how-tos/authorizing#APIKey



139
140
141
# File 'lib/files.com/models/remote_server.rb', line 139

def google_cloud_storage_credentials_json
  @attributes[:google_cloud_storage_credentials_json]
end

#google_cloud_storage_credentials_json=(value) ⇒ Object



143
144
145
# File 'lib/files.com/models/remote_server.rb', line 143

def google_cloud_storage_credentials_json=(value)
  @attributes[:google_cloud_storage_credentials_json] = value
end

#google_cloud_storage_project_idObject

string - Google Cloud Project ID



130
131
132
# File 'lib/files.com/models/remote_server.rb', line 130

def google_cloud_storage_project_id
  @attributes[:google_cloud_storage_project_id]
end

#google_cloud_storage_project_id=(value) ⇒ Object



134
135
136
# File 'lib/files.com/models/remote_server.rb', line 134

def google_cloud_storage_project_id=(value)
  @attributes[:google_cloud_storage_project_id] = value
end

#hostnameObject

string - Hostname or IP address



31
32
33
# File 'lib/files.com/models/remote_server.rb', line 31

def hostname
  @attributes[:hostname]
end

#hostname=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/remote_server.rb', line 35

def hostname=(value)
  @attributes[:hostname] = value
end

#idObject

int64 - Remote server ID



13
14
15
# File 'lib/files.com/models/remote_server.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/remote_server.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#max_connectionsObject

int64 - Max number of parallel connections. Ignored for S3 connections (we will parallelize these as much as possible).



58
59
60
# File 'lib/files.com/models/remote_server.rb', line 58

def max_connections
  @attributes[:max_connections]
end

#max_connections=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/remote_server.rb', line 62

def max_connections=(value)
  @attributes[:max_connections] = value
end

#nameObject

string - Internal name for your reference



40
41
42
# File 'lib/files.com/models/remote_server.rb', line 40

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/remote_server.rb', line 44

def name=(value)
  @attributes[:name] = value
end

#passwordObject

string - Password if needed.



166
167
168
# File 'lib/files.com/models/remote_server.rb', line 166

def password
  @attributes[:password]
end

#password=(value) ⇒ Object



170
171
172
# File 'lib/files.com/models/remote_server.rb', line 170

def password=(value)
  @attributes[:password] = value
end

#portObject

int64 - Port for remote server. Not needed for S3.



49
50
51
# File 'lib/files.com/models/remote_server.rb', line 49

def port
  @attributes[:port]
end

#port=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/remote_server.rb', line 53

def port=(value)
  @attributes[:port] = value
end

#private_keyObject

string - Private key if needed.



175
176
177
# File 'lib/files.com/models/remote_server.rb', line 175

def private_key
  @attributes[:private_key]
end

#private_key=(value) ⇒ Object



179
180
181
# File 'lib/files.com/models/remote_server.rb', line 179

def private_key=(value)
  @attributes[:private_key] = value
end

#s3_bucketObject

string - S3 bucket name



67
68
69
# File 'lib/files.com/models/remote_server.rb', line 67

def s3_bucket
  @attributes[:s3_bucket]
end

#s3_bucket=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/remote_server.rb', line 71

def s3_bucket=(value)
  @attributes[:s3_bucket] = value
end

#s3_regionObject

string - S3 region



76
77
78
# File 'lib/files.com/models/remote_server.rb', line 76

def s3_region
  @attributes[:s3_region]
end

#s3_region=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/remote_server.rb', line 80

def s3_region=(value)
  @attributes[:s3_region] = value
end

#saveObject



242
243
244
245
246
247
248
249
# File 'lib/files.com/models/remote_server.rb', line 242

def save
  if @attributes[:id]
    update(@attributes)
  else
    new_obj = RemoteServer.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#server_certificateObject

string - Remote server certificate



85
86
87
# File 'lib/files.com/models/remote_server.rb', line 85

def server_certificate
  @attributes[:server_certificate]
end

#server_certificate=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/remote_server.rb', line 89

def server_certificate=(value)
  @attributes[:server_certificate] = value
end

#server_typeObject

string - Remote server type.



94
95
96
# File 'lib/files.com/models/remote_server.rb', line 94

def server_type
  @attributes[:server_type]
end

#server_type=(value) ⇒ Object



98
99
100
# File 'lib/files.com/models/remote_server.rb', line 98

def server_type=(value)
  @attributes[:server_type] = value
end

#sslObject

string - Should we require SSL?



103
104
105
# File 'lib/files.com/models/remote_server.rb', line 103

def ssl
  @attributes[:ssl]
end

#ssl=(value) ⇒ Object



107
108
109
# File 'lib/files.com/models/remote_server.rb', line 107

def ssl=(value)
  @attributes[:ssl] = value
end

#update(params = {}) ⇒ Object

Parameters:

aws_access_key - string - AWS Access Key.
aws_secret_key - string - AWS secret key.
password - string - Password if needed.
private_key - string - Private key if needed.
hostname - string - Hostname or IP address
name - string - Internal name for your reference
max_connections - integer - Max number of parallel connections.  Ignored for S3 connections (we will parallelize these as much as possible).
port - integer - Port for remote server.  Not needed for S3.
s3_bucket - string - S3 bucket name
s3_region - string - S3 region
server_certificate - string - Remote server certificate
server_type - string - Remote server type.
ssl - string - Should we require SSL?
username - string - Remote server username.  Not needed for S3 buckets.
google_cloud_storage_bucket - string - Google Cloud Storage bucket name
google_cloud_storage_project_id - string - Google Cloud Project ID
google_cloud_storage_credentials_json - string - A JSON file that contains the private key. To generate see https://cloud.google.com/storage/docs/json_api/v1/how-tos/authorizing#APIKey


201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/files.com/models/remote_server.rb', line 201

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: aws_access_key must be an String") if params.dig(:aws_access_key) and !params.dig(:aws_access_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: aws_secret_key must be an String") if params.dig(:aws_secret_key) and !params.dig(:aws_secret_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params.dig(:private_key) and !params.dig(:private_key).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: hostname must be an String") if params.dig(:hostname) and !params.dig(:hostname).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: max_connections must be an Integer") if params.dig(:max_connections) and !params.dig(:max_connections).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: port must be an Integer") if params.dig(:port) and !params.dig(:port).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: s3_bucket must be an String") if params.dig(:s3_bucket) and !params.dig(:s3_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: s3_region must be an String") if params.dig(:s3_region) and !params.dig(:s3_region).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_certificate must be an String") if params.dig(:server_certificate) and !params.dig(:server_certificate).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: server_type must be an String") if params.dig(:server_type) and !params.dig(:server_type).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: ssl must be an String") if params.dig(:ssl) and !params.dig(:ssl).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_bucket must be an String") if params.dig(:google_cloud_storage_bucket) and !params.dig(:google_cloud_storage_bucket).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_project_id must be an String") if params.dig(:google_cloud_storage_project_id) and !params.dig(:google_cloud_storage_project_id).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: google_cloud_storage_credentials_json must be an String") if params.dig(:google_cloud_storage_credentials_json) and !params.dig(:google_cloud_storage_credentials_json).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/remote_servers/#{@attributes[:id]}", :patch, params, @options)
end

#usernameObject

string - Remote server username. Not needed for S3 buckets.



112
113
114
# File 'lib/files.com/models/remote_server.rb', line 112

def username
  @attributes[:username]
end

#username=(value) ⇒ Object



116
117
118
# File 'lib/files.com/models/remote_server.rb', line 116

def username=(value)
  @attributes[:username] = value
end