Class: Verizon::CloudConnectorDevicesApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/verizon/apis/cloud_connector_devices_api.rb

Overview

CloudConnectorDevicesApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

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

#delete_device_from_account(body) ⇒ ApiResponse

Remove a device from a ThingSpace account. identifies the device to delete.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 135

def (body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/delete',
                                 Server::CLOUD_CONNECTOR)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('thingspace_oauth', 'VZ-M2M-Token')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true))
    .execute
end

#find_device_by_property_values(body) ⇒ ApiResponse

Find devices by property values. Returns an array of all matching device resources. body specifies fields and values to match.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 37

def find_device_by_property_values(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/query',
                                 Server::CLOUD_CONNECTOR)
               .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(FindDeviceByPropertyResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_device_event_history(body) ⇒ ApiResponse

Search device event history to find events that match criteria.Sensor readings, configuration changes, and other device data are all stored as events. device identifier and fields to match in the search.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 84

def search_device_event_history(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/fields/actions/history/search',
                                 Server::CLOUD_CONNECTOR)
               .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(SearchDeviceEventHistoryResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_devices_resources_by_property_values(body) ⇒ ApiResponse

Search for devices by property values. Returns an array of all matching device resources. body specifies fields and values to match.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 60

def search_devices_resources_by_property_values(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/actions/search',
                                 Server::CLOUD_CONNECTOR)
               .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(SearchDeviceByPropertyResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#search_sensor_readings(fieldname, body) ⇒ ApiResponse

Returns the readings of a specified sensor, with the most recent reading first. Sensor readings are stored as events; this request an array of events. identifier and fields to match in the search.

Parameters:

  • fieldname (String)

    Required parameter: The name of the sensor.

  • body (SearchSensorHistoryRequest)

    Required parameter: The device

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 109

def search_sensor_readings(fieldname,
                           body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/fields/{fieldname}/actions/history',
                                 Server::CLOUD_CONNECTOR)
               .template_param(new_parameter(fieldname, key: 'fieldname')
                                .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(SearchSensorHistoryResponseList.method(:from_hash))
                .is_api_response(true))
    .execute
end

#update_devices_configuration_value(body) ⇒ ApiResponse

Change configuration values on a device, such as setting how often a device records and reports sensor readings. body changes configuration values on a device.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/verizon/apis/cloud_connector_devices_api.rb', line 14

def update_devices_configuration_value(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/devices/configuration/actions/set',
                                 Server::CLOUD_CONNECTOR)
               .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(ChangeConfigurationResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end