losant_rest 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rbenv-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +237 -0
- data/Rakefile +12 -0
- data/docs/_schemas.md +6348 -0
- data/docs/accessToken.md +107 -0
- data/docs/accessTokens.md +68 -0
- data/docs/application.md +107 -0
- data/docs/applicationKey.md +115 -0
- data/docs/applicationKeys.md +81 -0
- data/docs/applications.md +76 -0
- data/docs/auth.md +104 -0
- data/docs/dashboard.md +107 -0
- data/docs/dashboards.md +76 -0
- data/docs/data.md +78 -0
- data/docs/device.md +300 -0
- data/docs/deviceRecipe.md +152 -0
- data/docs/deviceRecipes.md +81 -0
- data/docs/devices.md +117 -0
- data/docs/event.md +115 -0
- data/docs/events.md +153 -0
- data/docs/flow.md +261 -0
- data/docs/flows.md +81 -0
- data/docs/me.md +312 -0
- data/docs/org.md +279 -0
- data/docs/orgs.md +75 -0
- data/docs/webhook.md +115 -0
- data/docs/webhooks.md +81 -0
- data/examples/auth.rb +32 -0
- data/examples/list_devices.rb +45 -0
- data/lib/losant_rest/access_token.rb +122 -0
- data/lib/losant_rest/access_tokens.rb +80 -0
- data/lib/losant_rest/application.rb +122 -0
- data/lib/losant_rest/application_key.rb +128 -0
- data/lib/losant_rest/application_keys.rb +98 -0
- data/lib/losant_rest/applications.rb +94 -0
- data/lib/losant_rest/auth.rb +122 -0
- data/lib/losant_rest/client.rb +132 -0
- data/lib/losant_rest/dashboard.rb +122 -0
- data/lib/losant_rest/dashboards.rb +94 -0
- data/lib/losant_rest/data.rb +89 -0
- data/lib/losant_rest/device.rb +336 -0
- data/lib/losant_rest/device_recipe.rb +169 -0
- data/lib/losant_rest/device_recipes.rb +98 -0
- data/lib/losant_rest/devices.rb +139 -0
- data/lib/losant_rest/error.rb +12 -0
- data/lib/losant_rest/event.rb +128 -0
- data/lib/losant_rest/events.rb +183 -0
- data/lib/losant_rest/flow.rb +290 -0
- data/lib/losant_rest/flows.rb +98 -0
- data/lib/losant_rest/me.rb +362 -0
- data/lib/losant_rest/org.rb +314 -0
- data/lib/losant_rest/orgs.rb +92 -0
- data/lib/losant_rest/utils.rb +22 -0
- data/lib/losant_rest/version.rb +3 -0
- data/lib/losant_rest/webhook.rb +128 -0
- data/lib/losant_rest/webhooks.rb +98 -0
- data/lib/losant_rest.rb +43 -0
- data/losant_rest.gemspec +25 -0
- data/schemas/accessToken.json +52 -0
- data/schemas/accessTokenPatch.json +19 -0
- data/schemas/accessTokenPost.json +32 -0
- data/schemas/accessTokens.json +65 -0
- data/schemas/application.json +65 -0
- data/schemas/applicationKey.json +68 -0
- data/schemas/applicationKeyPatch.json +18 -0
- data/schemas/applicationKeyPost.json +36 -0
- data/schemas/applicationKeys.json +110 -0
- data/schemas/applicationPatch.json +16 -0
- data/schemas/applicationPost.json +23 -0
- data/schemas/applications.json +103 -0
- data/schemas/authedDevice.json +34 -0
- data/schemas/authedUser.json +18 -0
- data/schemas/dashboard.json +95 -0
- data/schemas/dashboardPatch.json +69 -0
- data/schemas/dashboardPost.json +76 -0
- data/schemas/dashboards.json +133 -0
- data/schemas/device.json +113 -0
- data/schemas/deviceCommand.json +20 -0
- data/schemas/deviceCommands.json +25 -0
- data/schemas/deviceCredentials.json +22 -0
- data/schemas/deviceLog.json +28 -0
- data/schemas/devicePatch.json +78 -0
- data/schemas/devicePost.json +81 -0
- data/schemas/deviceRecipe.json +106 -0
- data/schemas/deviceRecipeBulkCreate.json +15 -0
- data/schemas/deviceRecipeBulkCreatePost.json +19 -0
- data/schemas/deviceRecipePatch.json +87 -0
- data/schemas/deviceRecipePost.json +90 -0
- data/schemas/deviceRecipes.json +148 -0
- data/schemas/deviceState.json +30 -0
- data/schemas/deviceStates.json +35 -0
- data/schemas/deviceTagFilter.json +19 -0
- data/schemas/devices.json +155 -0
- data/schemas/disableTwoFactorAuth.json +20 -0
- data/schemas/enableTwoFactorAuth.json +21 -0
- data/schemas/error.json +12 -0
- data/schemas/event.json +115 -0
- data/schemas/eventPatch.json +20 -0
- data/schemas/eventPost.json +39 -0
- data/schemas/events.json +165 -0
- data/schemas/flow.json +137 -0
- data/schemas/flowLog.json +46 -0
- data/schemas/flowPatch.json +107 -0
- data/schemas/flowPost.json +110 -0
- data/schemas/flowStorageEntries.json +7 -0
- data/schemas/flowStorageEntry.json +16 -0
- data/schemas/flows.json +179 -0
- data/schemas/githubLogin.json +14 -0
- data/schemas/lastValueData.json +34 -0
- data/schemas/lastValueQuery.json +36 -0
- data/schemas/me.json +173 -0
- data/schemas/mePatch.json +43 -0
- data/schemas/multiDeviceCommand.json +45 -0
- data/schemas/org.json +81 -0
- data/schemas/orgInvitePost.json +24 -0
- data/schemas/orgInvites.json +36 -0
- data/schemas/orgMemberPatch.json +23 -0
- data/schemas/orgPatch.json +16 -0
- data/schemas/orgPost.json +19 -0
- data/schemas/orgs.json +119 -0
- data/schemas/recentItem.json +27 -0
- data/schemas/recentItemList.json +36 -0
- data/schemas/success.json +12 -0
- data/schemas/timeSeriesData.json +89 -0
- data/schemas/timeSeriesQuery.json +64 -0
- data/schemas/userCredentials.json +25 -0
- data/schemas/virtualButtonPress.json +14 -0
- data/schemas/webhook.json +52 -0
- data/schemas/webhookPatch.json +29 -0
- data/schemas/webhookPost.json +32 -0
- data/schemas/webhooks.json +94 -0
- data/test/basic_test.rb +67 -0
- data/test/test_helper.rb +14 -0
- metadata +239 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Devices Resource
|
|
4
|
+
class Devices
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the devices for an application
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate
|
|
15
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
|
16
|
+
# * {string} page - Which page of results to return
|
|
17
|
+
# * {string} perPage - How many items to return per page
|
|
18
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
|
|
19
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
20
|
+
# * {hash} tagFilter - Array of tag pairs to filter by. (https://api.losant.com/#/definitions/deviceTagFilter)
|
|
21
|
+
# * {boolean} _actions - Return resource actions in response
|
|
22
|
+
# * {boolean} _links - Return resource link in response
|
|
23
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
24
|
+
#
|
|
25
|
+
# Responses:
|
|
26
|
+
# * 200 - Collection of devices (https://api.losant.com/#/definitions/devices)
|
|
27
|
+
#
|
|
28
|
+
# Errors:
|
|
29
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
30
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
31
|
+
def get(params = {})
|
|
32
|
+
params = Utils.symbolize_hash_keys(params)
|
|
33
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
34
|
+
headers = {}
|
|
35
|
+
body = nil
|
|
36
|
+
|
|
37
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
38
|
+
|
|
39
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
|
40
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
|
41
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
|
42
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
|
43
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
44
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
45
|
+
query_params[:tagFilter] = params[:tagFilter] if params.has_key?(:tagFilter)
|
|
46
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
47
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
48
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
49
|
+
|
|
50
|
+
path = "/applications/#{params[:applicationId]}/devices"
|
|
51
|
+
|
|
52
|
+
@client.request(
|
|
53
|
+
method: :get,
|
|
54
|
+
path: path,
|
|
55
|
+
query: query_params,
|
|
56
|
+
headers: headers,
|
|
57
|
+
body: body)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Create a new device for an application
|
|
61
|
+
#
|
|
62
|
+
# Parameters:
|
|
63
|
+
# * {string} applicationId - ID associated with the application
|
|
64
|
+
# * {hash} device - New device information (https://api.losant.com/#/definitions/devicePost)
|
|
65
|
+
# * {boolean} _actions - Return resource actions in response
|
|
66
|
+
# * {boolean} _links - Return resource link in response
|
|
67
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
68
|
+
#
|
|
69
|
+
# Responses:
|
|
70
|
+
# * 201 - Successfully created device (https://api.losant.com/#/definitions/device)
|
|
71
|
+
#
|
|
72
|
+
# Errors:
|
|
73
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
74
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
75
|
+
def post(params = {})
|
|
76
|
+
params = Utils.symbolize_hash_keys(params)
|
|
77
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
78
|
+
headers = {}
|
|
79
|
+
body = nil
|
|
80
|
+
|
|
81
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
82
|
+
raise ArgumentError.new("device is required") unless params.has_key?(:device)
|
|
83
|
+
|
|
84
|
+
body = params[:device] if params.has_key?(:device)
|
|
85
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
86
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
87
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
88
|
+
|
|
89
|
+
path = "/applications/#{params[:applicationId]}/devices"
|
|
90
|
+
|
|
91
|
+
@client.request(
|
|
92
|
+
method: :post,
|
|
93
|
+
path: path,
|
|
94
|
+
query: query_params,
|
|
95
|
+
headers: headers,
|
|
96
|
+
body: body)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Send a command to multiple devices
|
|
100
|
+
#
|
|
101
|
+
# Parameters:
|
|
102
|
+
# * {string} applicationId - ID associated with the application
|
|
103
|
+
# * {hash} multiDeviceCommand - Command to send to the device (https://api.losant.com/#/definitions/multiDeviceCommand)
|
|
104
|
+
# * {boolean} _actions - Return resource actions in response
|
|
105
|
+
# * {boolean} _links - Return resource link in response
|
|
106
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
107
|
+
#
|
|
108
|
+
# Responses:
|
|
109
|
+
# * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success)
|
|
110
|
+
#
|
|
111
|
+
# Errors:
|
|
112
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
113
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
114
|
+
def send_command(params = {})
|
|
115
|
+
params = Utils.symbolize_hash_keys(params)
|
|
116
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
117
|
+
headers = {}
|
|
118
|
+
body = nil
|
|
119
|
+
|
|
120
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
121
|
+
raise ArgumentError.new("multiDeviceCommand is required") unless params.has_key?(:multiDeviceCommand)
|
|
122
|
+
|
|
123
|
+
body = params[:multiDeviceCommand] if params.has_key?(:multiDeviceCommand)
|
|
124
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
125
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
126
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
127
|
+
|
|
128
|
+
path = "/applications/#{params[:applicationId]}/devices/command"
|
|
129
|
+
|
|
130
|
+
@client.request(
|
|
131
|
+
method: :post,
|
|
132
|
+
path: path,
|
|
133
|
+
query: query_params,
|
|
134
|
+
headers: headers,
|
|
135
|
+
body: body)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Event Resource
|
|
4
|
+
class Event
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Deletes an event
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} eventId - ID associated with the event
|
|
15
|
+
# * {boolean} _actions - Return resource actions in response
|
|
16
|
+
# * {boolean} _links - Return resource link in response
|
|
17
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
18
|
+
#
|
|
19
|
+
# Responses:
|
|
20
|
+
# * 200 - If event was successfully deleted (https://api.losant.com/#/definitions/success)
|
|
21
|
+
#
|
|
22
|
+
# Errors:
|
|
23
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
24
|
+
# * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
|
|
25
|
+
def delete(params = {})
|
|
26
|
+
params = Utils.symbolize_hash_keys(params)
|
|
27
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
28
|
+
headers = {}
|
|
29
|
+
body = nil
|
|
30
|
+
|
|
31
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
32
|
+
raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
|
|
33
|
+
|
|
34
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
35
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
36
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
37
|
+
|
|
38
|
+
path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
|
|
39
|
+
|
|
40
|
+
@client.request(
|
|
41
|
+
method: :delete,
|
|
42
|
+
path: path,
|
|
43
|
+
query: query_params,
|
|
44
|
+
headers: headers,
|
|
45
|
+
body: body)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Retrieves information on an event
|
|
49
|
+
#
|
|
50
|
+
# Parameters:
|
|
51
|
+
# * {string} applicationId - ID associated with the application
|
|
52
|
+
# * {string} eventId - ID associated with the event
|
|
53
|
+
# * {boolean} _actions - Return resource actions in response
|
|
54
|
+
# * {boolean} _links - Return resource link in response
|
|
55
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
56
|
+
#
|
|
57
|
+
# Responses:
|
|
58
|
+
# * 200 - Event information (https://api.losant.com/#/definitions/event)
|
|
59
|
+
#
|
|
60
|
+
# Errors:
|
|
61
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
62
|
+
# * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
|
|
63
|
+
def get(params = {})
|
|
64
|
+
params = Utils.symbolize_hash_keys(params)
|
|
65
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
66
|
+
headers = {}
|
|
67
|
+
body = nil
|
|
68
|
+
|
|
69
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
70
|
+
raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
|
|
71
|
+
|
|
72
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
73
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
74
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
75
|
+
|
|
76
|
+
path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
|
|
77
|
+
|
|
78
|
+
@client.request(
|
|
79
|
+
method: :get,
|
|
80
|
+
path: path,
|
|
81
|
+
query: query_params,
|
|
82
|
+
headers: headers,
|
|
83
|
+
body: body)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Updates information about an event
|
|
87
|
+
#
|
|
88
|
+
# Parameters:
|
|
89
|
+
# * {string} applicationId - ID associated with the application
|
|
90
|
+
# * {string} eventId - ID associated with the event
|
|
91
|
+
# * {hash} event - Object containing new properties of the event (https://api.losant.com/#/definitions/eventPatch)
|
|
92
|
+
# * {boolean} _actions - Return resource actions in response
|
|
93
|
+
# * {boolean} _links - Return resource link in response
|
|
94
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
95
|
+
#
|
|
96
|
+
# Responses:
|
|
97
|
+
# * 200 - Updated event information (https://api.losant.com/#/definitions/event)
|
|
98
|
+
#
|
|
99
|
+
# Errors:
|
|
100
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
101
|
+
# * 404 - Error if event is not found (https://api.losant.com/#/definitions/error)
|
|
102
|
+
def patch(params = {})
|
|
103
|
+
params = Utils.symbolize_hash_keys(params)
|
|
104
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
105
|
+
headers = {}
|
|
106
|
+
body = nil
|
|
107
|
+
|
|
108
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
109
|
+
raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
|
|
110
|
+
raise ArgumentError.new("event is required") unless params.has_key?(:event)
|
|
111
|
+
|
|
112
|
+
body = params[:event] if params.has_key?(:event)
|
|
113
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
114
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
115
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
116
|
+
|
|
117
|
+
path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
|
|
118
|
+
|
|
119
|
+
@client.request(
|
|
120
|
+
method: :patch,
|
|
121
|
+
path: path,
|
|
122
|
+
query: query_params,
|
|
123
|
+
headers: headers,
|
|
124
|
+
body: body)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Events Resource
|
|
4
|
+
class Events
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the events for an application
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: subject, id, creationDate
|
|
15
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
|
16
|
+
# * {string} page - Which page of results to return
|
|
17
|
+
# * {string} perPage - How many items to return per page
|
|
18
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: subject
|
|
19
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
20
|
+
# * {string} state - If provided, return events only in the given state. Accepted values are: new, acknowledged, resolved
|
|
21
|
+
# * {boolean} _actions - Return resource actions in response
|
|
22
|
+
# * {boolean} _links - Return resource link in response
|
|
23
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
24
|
+
#
|
|
25
|
+
# Responses:
|
|
26
|
+
# * 200 - Collection of events (https://api.losant.com/#/definitions/events)
|
|
27
|
+
#
|
|
28
|
+
# Errors:
|
|
29
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
30
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
31
|
+
def get(params = {})
|
|
32
|
+
params = Utils.symbolize_hash_keys(params)
|
|
33
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
34
|
+
headers = {}
|
|
35
|
+
body = nil
|
|
36
|
+
|
|
37
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
38
|
+
|
|
39
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
|
40
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
|
41
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
|
42
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
|
43
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
44
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
45
|
+
query_params[:state] = params[:state] if params.has_key?(:state)
|
|
46
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
47
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
48
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
49
|
+
|
|
50
|
+
path = "/applications/#{params[:applicationId]}/events"
|
|
51
|
+
|
|
52
|
+
@client.request(
|
|
53
|
+
method: :get,
|
|
54
|
+
path: path,
|
|
55
|
+
query: query_params,
|
|
56
|
+
headers: headers,
|
|
57
|
+
body: body)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Returns the first new event ordered by severity and then creation
|
|
61
|
+
#
|
|
62
|
+
# Parameters:
|
|
63
|
+
# * {string} applicationId - ID associated with the application
|
|
64
|
+
# * {string} filter - Filter to apply against event subjects. Supports globbing. Blank or not provided means no filtering.
|
|
65
|
+
# * {boolean} _actions - Return resource actions in response
|
|
66
|
+
# * {boolean} _links - Return resource link in response
|
|
67
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
68
|
+
#
|
|
69
|
+
# Responses:
|
|
70
|
+
# * 200 - The event, plus count of currently new events
|
|
71
|
+
#
|
|
72
|
+
# Errors:
|
|
73
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
74
|
+
def most_recent_by_severity(params = {})
|
|
75
|
+
params = Utils.symbolize_hash_keys(params)
|
|
76
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
77
|
+
headers = {}
|
|
78
|
+
body = nil
|
|
79
|
+
|
|
80
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
81
|
+
|
|
82
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
83
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
84
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
85
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
86
|
+
|
|
87
|
+
path = "/applications/#{params[:applicationId]}/events/mostRecentBySeverity"
|
|
88
|
+
|
|
89
|
+
@client.request(
|
|
90
|
+
method: :get,
|
|
91
|
+
path: path,
|
|
92
|
+
query: query_params,
|
|
93
|
+
headers: headers,
|
|
94
|
+
body: body)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Updates information for matching events by subject and/or current state
|
|
98
|
+
#
|
|
99
|
+
# Parameters:
|
|
100
|
+
# * {string} applicationId - ID associated with the application
|
|
101
|
+
# * {string} filterField - Field to filter the events to act on by. Blank or not provided means no filtering. Accepted values are: subject
|
|
102
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
103
|
+
# * {string} state - If provided, act on events only in the given state. Accepted values are: new, acknowledged, resolved
|
|
104
|
+
# * {hash} updates - Object containing updated information for the events (https://api.losant.com/#/definitions/eventPatch)
|
|
105
|
+
# * {boolean} _actions - Return resource actions in response
|
|
106
|
+
# * {boolean} _links - Return resource link in response
|
|
107
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
108
|
+
#
|
|
109
|
+
# Responses:
|
|
110
|
+
# * 200 - If updates were successfully applied (https://api.losant.com/#/definitions/success)
|
|
111
|
+
#
|
|
112
|
+
# Errors:
|
|
113
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
114
|
+
# * 404 - Error if application is not found (https://api.losant.com/#/definitions/error)
|
|
115
|
+
def patch(params = {})
|
|
116
|
+
params = Utils.symbolize_hash_keys(params)
|
|
117
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
118
|
+
headers = {}
|
|
119
|
+
body = nil
|
|
120
|
+
|
|
121
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
122
|
+
raise ArgumentError.new("updates is required") unless params.has_key?(:updates)
|
|
123
|
+
|
|
124
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
125
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
126
|
+
query_params[:state] = params[:state] if params.has_key?(:state)
|
|
127
|
+
body = params[:updates] if params.has_key?(:updates)
|
|
128
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
129
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
130
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
131
|
+
|
|
132
|
+
path = "/applications/#{params[:applicationId]}/events"
|
|
133
|
+
|
|
134
|
+
@client.request(
|
|
135
|
+
method: :patch,
|
|
136
|
+
path: path,
|
|
137
|
+
query: query_params,
|
|
138
|
+
headers: headers,
|
|
139
|
+
body: body)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Create a new event for an application
|
|
143
|
+
#
|
|
144
|
+
# Parameters:
|
|
145
|
+
# * {string} applicationId - ID associated with the application
|
|
146
|
+
# * {hash} event - New event information (https://api.losant.com/#/definitions/eventPost)
|
|
147
|
+
# * {boolean} _actions - Return resource actions in response
|
|
148
|
+
# * {boolean} _links - Return resource link in response
|
|
149
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
150
|
+
#
|
|
151
|
+
# Responses:
|
|
152
|
+
# * 201 - Successfully created event (https://api.losant.com/#/definitions/event)
|
|
153
|
+
#
|
|
154
|
+
# Errors:
|
|
155
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
156
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
157
|
+
# * 429 - Error if event creation rate limit exceeded (https://api.losant.com/#/definitions/error)
|
|
158
|
+
def post(params = {})
|
|
159
|
+
params = Utils.symbolize_hash_keys(params)
|
|
160
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
161
|
+
headers = {}
|
|
162
|
+
body = nil
|
|
163
|
+
|
|
164
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
165
|
+
raise ArgumentError.new("event is required") unless params.has_key?(:event)
|
|
166
|
+
|
|
167
|
+
body = params[:event] if params.has_key?(:event)
|
|
168
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
169
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
170
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
171
|
+
|
|
172
|
+
path = "/applications/#{params[:applicationId]}/events"
|
|
173
|
+
|
|
174
|
+
@client.request(
|
|
175
|
+
method: :post,
|
|
176
|
+
path: path,
|
|
177
|
+
query: query_params,
|
|
178
|
+
headers: headers,
|
|
179
|
+
body: body)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
end
|
|
183
|
+
end
|