Class: Verizon::DeviceGroupsApi
- Defined in:
- lib/verizon/apis/device_groups_api.rb
Overview
DeviceGroupsApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_device_group(body) ⇒ ApiResponse
Create a new device group and optionally add devices to the group.
-
#delete_device_group(aname, gname) ⇒ ApiResponse
Deletes a device group from the account.
-
#get_device_group_information(aname, gname, mnext: nil) ⇒ ApiResponse
When HTTP status is 202, a URL will be returned in the Location header of the form /groups/aname/name/gname/?next=token.
-
#list_device_groups(aname) ⇒ ApiResponse
Returns a list of all device groups in a specified account.
-
#update_device_group(aname, gname, body) ⇒ ApiResponse
Make changes to a device group, including changing the name and description, and adding or removing devices.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Verizon::BaseApi
Instance Method Details
#create_device_group(body) ⇒ ApiResponse
Create a new device group and optionally add devices to the group. Device groups can make it easier to manage similar devices and to get reports on their usage. create a new device group.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/verizon/apis/device_groups_api.rb', line 15 def create_device_group(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/m2m/v1/groups', Server::THINGSPACE) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'VZ-M2M-Token'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConnectivityManagementSuccessResult.method(:from_hash)) .is_api_response(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |
#delete_device_group(aname, gname) ⇒ ApiResponse
Deletes a device group from the account. Devices in the group are moved to the default device group and are not deleted from the account.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/verizon/apis/device_groups_api.rb', line 135 def delete_device_group(aname, gname) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/m2m/v1/groups/{aname}/name/{gname}', Server::THINGSPACE) .template_param(new_parameter(aname, key: 'aname') .is_required(true) .should_encode(true)) .template_param(new_parameter(gname, key: 'gname') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'VZ-M2M-Token'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConnectivityManagementSuccessResult.method(:from_hash)) .is_api_response(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |
#get_device_group_information(aname, gname, mnext: nil) ⇒ ApiResponse
When HTTP status is 202, a URL will be returned in the Location header of the form /groups/aname/name/gname/?next=token. This URL can be used to request the next set of groups. from the pageUrl pagetoken.
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 |
# File 'lib/verizon/apis/device_groups_api.rb', line 68 def get_device_group_information(aname, gname, mnext: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/m2m/v1/groups/{aname}/name/{gname}', Server::THINGSPACE) .template_param(new_parameter(aname, key: 'aname') .is_required(true) .should_encode(true)) .template_param(new_parameter(gname, key: 'gname') .is_required(true) .should_encode(true)) .query_param(new_parameter(mnext, key: 'next')) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'VZ-M2M-Token'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeviceGroupDevicesData.method(:from_hash)) .is_api_response(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |
#list_device_groups(aname) ⇒ ApiResponse
Returns a list of all device groups in a specified account.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/verizon/apis/device_groups_api.rb', line 39 def list_device_groups(aname) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/m2m/v1/groups/{aname}', Server::THINGSPACE) .template_param(new_parameter(aname, key: 'aname') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'VZ-M2M-Token'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeviceGroup.method(:from_hash)) .is_api_response(true) .is_response_array(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |
#update_device_group(aname, gname, body) ⇒ ApiResponse
Make changes to a device group, including changing the name and description, and adding or removing devices. update device group.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/verizon/apis/device_groups_api.rb', line 101 def update_device_group(aname, gname, body) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/m2m/v1/groups/{aname}/name/{gname}', Server::THINGSPACE) .template_param(new_parameter(aname, key: 'aname') .is_required(true) .should_encode(true)) .template_param(new_parameter(gname, key: 'gname') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'VZ-M2M-Token'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConnectivityManagementSuccessResult.method(:from_hash)) .is_api_response(true) .local_error('400', 'Error response.', ConnectivityManagementResultException)) .execute end |