Class: Verizon::DeviceGroupUpdateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/device_group_update_request.rb

Overview

Make changes to a device group, including changing the name and description, and adding or removing devices.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(devices_to_add: SKIP, devices_to_remove: SKIP, new_group_description: SKIP, new_group_name: SKIP, additional_properties: nil) ⇒ DeviceGroupUpdateRequest

Returns a new instance of DeviceGroupUpdateRequest.



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/verizon/models/device_group_update_request.rb', line 59

def initialize(devices_to_add: SKIP, devices_to_remove: SKIP,
               new_group_description: SKIP, new_group_name: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @devices_to_add = devices_to_add unless devices_to_add == SKIP
  @devices_to_remove = devices_to_remove unless devices_to_remove == SKIP
  @new_group_description = new_group_description unless new_group_description == SKIP
  @new_group_name = new_group_name unless new_group_name == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#devices_to_addArray[DeviceId]

Zero or more devices to add to the device group, specified by device ID. The devices will be removed from their current device groups. You can use POST /devices/actions/list to get a list of all devices in the account.

Returns:



17
18
19
# File 'lib/verizon/models/device_group_update_request.rb', line 17

def devices_to_add
  @devices_to_add
end

#devices_to_removeArray[DeviceId]

Zero or more devices to remove from the device group, specified by device ID. The devices will be added to the default device group.

Returns:



22
23
24
# File 'lib/verizon/models/device_group_update_request.rb', line 22

def devices_to_remove
  @devices_to_remove
end

#new_group_descriptionString

A new description for the device group. Do not include this parameter to leave the group description unchanged.

Returns:

  • (String)


27
28
29
# File 'lib/verizon/models/device_group_update_request.rb', line 27

def new_group_description
  @new_group_description
end

#new_group_nameString

A new name for the device group. Do not include this parameter if you want to leave the group name unchanged.

Returns:

  • (String)


32
33
34
# File 'lib/verizon/models/device_group_update_request.rb', line 32

def new_group_name
  @new_group_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/verizon/models/device_group_update_request.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  devices_to_add = nil
  unless hash['devicesToAdd'].nil?
    devices_to_add = []
    hash['devicesToAdd'].each do |structure|
      devices_to_add << (DeviceId.from_hash(structure) if structure)
    end
  end

  devices_to_add = SKIP unless hash.key?('devicesToAdd')
  # Parameter is an array, so we need to iterate through it
  devices_to_remove = nil
  unless hash['devicesToRemove'].nil?
    devices_to_remove = []
    hash['devicesToRemove'].each do |structure|
      devices_to_remove << (DeviceId.from_hash(structure) if structure)
    end
  end

  devices_to_remove = SKIP unless hash.key?('devicesToRemove')
  new_group_description =
    hash.key?('newGroupDescription') ? hash['newGroupDescription'] : SKIP
  new_group_name = hash.key?('newGroupName') ? hash['newGroupName'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  DeviceGroupUpdateRequest.new(devices_to_add: devices_to_add,
                               devices_to_remove: devices_to_remove,
                               new_group_description: new_group_description,
                               new_group_name: new_group_name,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
# File 'lib/verizon/models/device_group_update_request.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['devices_to_add'] = 'devicesToAdd'
  @_hash['devices_to_remove'] = 'devicesToRemove'
  @_hash['new_group_description'] = 'newGroupDescription'
  @_hash['new_group_name'] = 'newGroupName'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/verizon/models/device_group_update_request.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
# File 'lib/verizon/models/device_group_update_request.rb', line 45

def self.optionals
  %w[
    devices_to_add
    devices_to_remove
    new_group_description
    new_group_name
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



125
126
127
128
129
130
131
# File 'lib/verizon/models/device_group_update_request.rb', line 125

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} devices_to_add: #{@devices_to_add.inspect}, devices_to_remove:"\
  " #{@devices_to_remove.inspect}, new_group_description: #{@new_group_description.inspect},"\
  " new_group_name: #{@new_group_name.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



117
118
119
120
121
122
# File 'lib/verizon/models/device_group_update_request.rb', line 117

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} devices_to_add: #{@devices_to_add}, devices_to_remove:"\
  " #{@devices_to_remove}, new_group_description: #{@new_group_description}, new_group_name:"\
  " #{@new_group_name}, additional_properties: #{@additional_properties}>"
end