Class: Files::SyncBandwidthSnapshot

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of SyncBandwidthSnapshot.



9
10
11
12
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 9

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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

Parameters:

remote_server_id (required) - int64 - ID for the remote server consuming sync bandwidth
sync_bytes_sent (required) - int64 - Sync bytes sent
sync_bytes_received (required) - int64 - Sync bytes received


85
86
87
88
89
90
91
92
93
94
95
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 85

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

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

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



97
98
99
100
101
102
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 97

def self.create_batch(params = {}, options = {})
  response, options = Api.send_request("/sync_bandwidth_snapshots/create_batch", :post, params, options)
  response.data.map do |entity_data|
    SyncBandwidthSnapshot.new(entity_data, options)
  end
end

Instance Method Details

#created_atObject

date-time - sync bandwidth snapshot created at date/time



57
58
59
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 57

def created_at
  @attributes[:created_at]
end

#idObject

int64 - sync bandwidth snapshot ID



15
16
17
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 15

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



19
20
21
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 19

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

#remote_server_idObject

int64 - ID for the remote server consuming sync bandwidth



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

def remote_server_id
  @attributes[:remote_server_id]
end

#remote_server_id=(value) ⇒ Object



66
67
68
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 66

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

#saveObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 70

def save
  if @attributes[:id]
    raise NotImplementedError.new("The SyncBandwidthSnapshot object doesn't support updates.")
  else
    new_obj = SyncBandwidthSnapshot.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#site_idObject

int64 - Site ID



24
25
26
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 24

def site_id
  @attributes[:site_id]
end

#site_id=(value) ⇒ Object



28
29
30
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 28

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

#sync_bytes_receivedObject

decimal - bytes received



33
34
35
36
37
38
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 33

def sync_bytes_received
  value = @attributes[:sync_bytes_received]
  return value if value.nil? || value.is_a?(BigDecimal)

  BigDecimal(value.to_s)
end

#sync_bytes_received=(value) ⇒ Object



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

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

#sync_bytes_sentObject

decimal - bytes sent



45
46
47
48
49
50
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 45

def sync_bytes_sent
  value = @attributes[:sync_bytes_sent]
  return value if value.nil? || value.is_a?(BigDecimal)

  BigDecimal(value.to_s)
end

#sync_bytes_sent=(value) ⇒ Object



52
53
54
# File 'lib/files.com/models/sync_bandwidth_snapshot.rb', line 52

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