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

#to_hash, #to_json

Constructor Details

#initialize(devices_to_add = SKIP, devices_to_remove = SKIP, new_group_description = SKIP, new_group_name = SKIP) ⇒ DeviceGroupUpdateRequest

Returns a new instance of DeviceGroupUpdateRequest.



59
60
61
62
63
64
65
# 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)
  @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
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.



68
69
70
71
72
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
# File 'lib/verizon/models/device_group_update_request.rb', line 68

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 object from extracted values.
  DeviceGroupUpdateRequest.new(devices_to_add,
                               devices_to_remove,
                               new_group_description,
                               new_group_name)
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