losant_rest 1.2.0 → 1.2.1

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.
@@ -0,0 +1,136 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2017 Losant IoT, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module LosantRest
24
+
25
+ # Class containing all the actions for the Integrations Resource
26
+ class Integrations
27
+
28
+ def initialize(client)
29
+ @client = client
30
+ end
31
+
32
+ # Returns the integrations for an application
33
+ #
34
+ # Authentication:
35
+ # The client must be configured with a valid api
36
+ # access token to call this action. The token
37
+ # must include at least one of the following scopes:
38
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, integrations.*, or integrations.get.
39
+ #
40
+ # Parameters:
41
+ # * {string} applicationId - ID associated with the application
42
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, integrationType
43
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
44
+ # * {string} page - Which page of results to return
45
+ # * {string} perPage - How many items to return per page
46
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, integrationType
47
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
48
+ # * {string} losantdomain - Domain scope of request (rarely needed)
49
+ # * {boolean} _actions - Return resource actions in response
50
+ # * {boolean} _links - Return resource link in response
51
+ # * {boolean} _embedded - Return embedded resources in response
52
+ #
53
+ # Responses:
54
+ # * 200 - Collection of integrations (https://api.losant.com/#/definitions/integrations)
55
+ #
56
+ # Errors:
57
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
58
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
59
+ def get(params = {})
60
+ params = Utils.symbolize_hash_keys(params)
61
+ query_params = { _actions: false, _links: true, _embedded: true }
62
+ headers = {}
63
+ body = nil
64
+
65
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
66
+
67
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
68
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
69
+ query_params[:page] = params[:page] if params.has_key?(:page)
70
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
71
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
72
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
73
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
74
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
75
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
76
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
77
+
78
+ path = "/applications/#{params[:applicationId]}/integrations"
79
+
80
+ @client.request(
81
+ method: :get,
82
+ path: path,
83
+ query: query_params,
84
+ headers: headers,
85
+ body: body)
86
+ end
87
+
88
+ # Create a new integration for an application
89
+ #
90
+ # Authentication:
91
+ # The client must be configured with a valid api
92
+ # access token to call this action. The token
93
+ # must include at least one of the following scopes:
94
+ # all.Application, all.Organization, all.User, integrations.*, or integrations.post.
95
+ #
96
+ # Parameters:
97
+ # * {string} applicationId - ID associated with the application
98
+ # * {hash} integration - New integration information (https://api.losant.com/#/definitions/integrationPost)
99
+ # * {string} losantdomain - Domain scope of request (rarely needed)
100
+ # * {boolean} _actions - Return resource actions in response
101
+ # * {boolean} _links - Return resource link in response
102
+ # * {boolean} _embedded - Return embedded resources in response
103
+ #
104
+ # Responses:
105
+ # * 201 - Successfully created integration (https://api.losant.com/#/definitions/integration)
106
+ #
107
+ # Errors:
108
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
109
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
110
+ def post(params = {})
111
+ params = Utils.symbolize_hash_keys(params)
112
+ query_params = { _actions: false, _links: true, _embedded: true }
113
+ headers = {}
114
+ body = nil
115
+
116
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
117
+ raise ArgumentError.new("integration is required") unless params.has_key?(:integration)
118
+
119
+ body = params[:integration] if params.has_key?(:integration)
120
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
121
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
122
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
123
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
124
+
125
+ path = "/applications/#{params[:applicationId]}/integrations"
126
+
127
+ @client.request(
128
+ method: :post,
129
+ path: path,
130
+ query: query_params,
131
+ headers: headers,
132
+ body: body)
133
+ end
134
+
135
+ end
136
+ end
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module LosantRest
24
- VERSION = "1.2.0"
24
+ VERSION = "1.2.1"
25
25
  end
@@ -81,6 +81,9 @@
81
81
  "flowCount": {
82
82
  "type": "number"
83
83
  },
84
+ "integrationCount": {
85
+ "type": "number"
86
+ },
84
87
  "webhookCount": {
85
88
  "type": "number"
86
89
  }
@@ -42,6 +42,8 @@
42
42
  "experienceGroups.*",
43
43
  "experienceUser.*",
44
44
  "experienceUsers.*",
45
+ "integration.*",
46
+ "integrations.*",
45
47
  "flow.*",
46
48
  "flows.*",
47
49
  "webhook.*",
@@ -113,8 +115,13 @@
113
115
  "flow.patch",
114
116
  "flow.pressVirtualButton",
115
117
  "flow.setStorageEntry",
116
- "flows.create",
117
118
  "flows.get",
119
+ "flows.post",
120
+ "integration.delete",
121
+ "integration.get",
122
+ "integration.patch",
123
+ "integrations.get",
124
+ "integrations.post",
118
125
  "webhook.delete",
119
126
  "webhook.get",
120
127
  "webhook.patch",
@@ -88,6 +88,9 @@
88
88
  "flowCount": {
89
89
  "type": "number"
90
90
  },
91
+ "integrationCount": {
92
+ "type": "number"
93
+ },
91
94
  "webhookCount": {
92
95
  "type": "number"
93
96
  }
@@ -52,6 +52,7 @@
52
52
  "ExperienceUser",
53
53
  "Flow",
54
54
  "SolutionUser",
55
+ "Integration",
55
56
  "Webhook"
56
57
  ]
57
58
  },
@@ -50,6 +50,7 @@
50
50
  "ExperienceUser",
51
51
  "Flow",
52
52
  "SolutionUser",
53
+ "Integration",
53
54
  "Webhook"
54
55
  ]
55
56
  },
@@ -59,6 +59,7 @@
59
59
  "ExperienceUser",
60
60
  "Flow",
61
61
  "SolutionUser",
62
+ "Integration",
62
63
  "Webhook"
63
64
  ]
64
65
  },
@@ -47,17 +47,18 @@
47
47
  "type": "string",
48
48
  "enum": [
49
49
  "deviceId",
50
+ "deviceIdConnect",
51
+ "deviceIdDisconnect",
50
52
  "deviceTag",
53
+ "deviceTagConnect",
54
+ "deviceTagDisconnect",
55
+ "endpoint",
56
+ "event",
51
57
  "mqttTopic",
52
- "webhook",
58
+ "integration",
53
59
  "timer",
54
- "event",
55
60
  "virtualButton",
56
- "endpoint",
57
- "deviceIdConnect",
58
- "deviceIdDisconnect",
59
- "deviceTagConnect",
60
- "deviceTagDisconnect"
61
+ "webhook"
61
62
  ]
62
63
  },
63
64
  "config": {
@@ -27,17 +27,18 @@
27
27
  "type": "string",
28
28
  "enum": [
29
29
  "deviceId",
30
+ "deviceIdConnect",
31
+ "deviceIdDisconnect",
30
32
  "deviceTag",
33
+ "deviceTagConnect",
34
+ "deviceTagDisconnect",
35
+ "endpoint",
36
+ "event",
31
37
  "mqttTopic",
32
- "webhook",
38
+ "integration",
33
39
  "timer",
34
- "event",
35
40
  "virtualButton",
36
- "endpoint",
37
- "deviceIdConnect",
38
- "deviceIdDisconnect",
39
- "deviceTagConnect",
40
- "deviceTagDisconnect"
41
+ "webhook"
41
42
  ]
42
43
  },
43
44
  "config": {
@@ -27,17 +27,18 @@
27
27
  "type": "string",
28
28
  "enum": [
29
29
  "deviceId",
30
+ "deviceIdConnect",
31
+ "deviceIdDisconnect",
30
32
  "deviceTag",
33
+ "deviceTagConnect",
34
+ "deviceTagDisconnect",
35
+ "endpoint",
36
+ "event",
31
37
  "mqttTopic",
32
- "webhook",
38
+ "integration",
33
39
  "timer",
34
- "event",
35
40
  "virtualButton",
36
- "endpoint",
37
- "deviceIdConnect",
38
- "deviceIdDisconnect",
39
- "deviceTagConnect",
40
- "deviceTagDisconnect"
41
+ "webhook"
41
42
  ]
42
43
  },
43
44
  "config": {
@@ -54,17 +54,18 @@
54
54
  "type": "string",
55
55
  "enum": [
56
56
  "deviceId",
57
+ "deviceIdConnect",
58
+ "deviceIdDisconnect",
57
59
  "deviceTag",
60
+ "deviceTagConnect",
61
+ "deviceTagDisconnect",
62
+ "endpoint",
63
+ "event",
58
64
  "mqttTopic",
59
- "webhook",
65
+ "integration",
60
66
  "timer",
61
- "event",
62
67
  "virtualButton",
63
- "endpoint",
64
- "deviceIdConnect",
65
- "deviceIdDisconnect",
66
- "deviceTagConnect",
67
- "deviceTagDisconnect"
68
+ "webhook"
68
69
  ]
69
70
  },
70
71
  "config": {
@@ -0,0 +1,169 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "id": {
6
+ "type": "string",
7
+ "pattern": "^[A-Fa-f\\d]{24}$"
8
+ },
9
+ "integrationId": {
10
+ "type": "string",
11
+ "pattern": "^[A-Fa-f\\d]{24}$"
12
+ },
13
+ "applicationId": {
14
+ "type": "string",
15
+ "pattern": "^[A-Fa-f\\d]{24}$"
16
+ },
17
+ "creationDate": {
18
+ "type": "string",
19
+ "format": "date-time"
20
+ },
21
+ "lastUpdated": {
22
+ "type": "string",
23
+ "format": "date-time"
24
+ },
25
+ "name": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "maxLength": 1024
29
+ },
30
+ "integrationType": {
31
+ "type": "string",
32
+ "enum": [
33
+ "mqtt",
34
+ "googlePubSub"
35
+ ]
36
+ },
37
+ "enabled": {
38
+ "type": "boolean"
39
+ },
40
+ "topics": {
41
+ "type": "array",
42
+ "items": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "maxLength": 1024
46
+ }
47
+ },
48
+ "googlePubSubConfig": {
49
+ "type": "object",
50
+ "properties": {
51
+ "projectId": {
52
+ "type": "string",
53
+ "minLength": 1,
54
+ "maxLength": 1024
55
+ },
56
+ "keyJson": {
57
+ "type": "string",
58
+ "maxLength": 32767,
59
+ "minLength": 50
60
+ }
61
+ },
62
+ "additionalProperties": false,
63
+ "required": [
64
+ "projectId",
65
+ "keyJson"
66
+ ]
67
+ },
68
+ "mqttConfig": {
69
+ "type": "object",
70
+ "properties": {
71
+ "clientId": {
72
+ "type": "string",
73
+ "maxLength": 1024,
74
+ "minLength": 1
75
+ },
76
+ "username": {
77
+ "type": "string",
78
+ "maxLength": 1024,
79
+ "minLength": 1
80
+ },
81
+ "password": {
82
+ "type": "string",
83
+ "maxLength": 1024,
84
+ "minLength": 1
85
+ },
86
+ "clean": {
87
+ "type": "boolean"
88
+ },
89
+ "port": {
90
+ "type": "number",
91
+ "minimum": 1,
92
+ "maximum": 65535
93
+ },
94
+ "protocol": {
95
+ "type": "string",
96
+ "enum": [
97
+ "mqtt",
98
+ "mqtts",
99
+ "ws",
100
+ "wss"
101
+ ]
102
+ },
103
+ "host": {
104
+ "type": "string",
105
+ "maxLength": 1024,
106
+ "minLength": 1
107
+ },
108
+ "privateKey": {
109
+ "type": "string",
110
+ "maxLength": 32767,
111
+ "minLength": 50
112
+ },
113
+ "certificate": {
114
+ "type": "string",
115
+ "maxLength": 32767,
116
+ "minLength": 50
117
+ },
118
+ "caCertificate": {
119
+ "type": "string",
120
+ "maxLength": 32767,
121
+ "minLength": 50
122
+ }
123
+ },
124
+ "additionalProperties": false,
125
+ "required": [
126
+ "port",
127
+ "protocol",
128
+ "host"
129
+ ]
130
+ },
131
+ "status": {
132
+ "lastKeepAlive": {
133
+ "type": [
134
+ "number"
135
+ ]
136
+ },
137
+ "nextAttempt": {
138
+ "type": [
139
+ "number"
140
+ ]
141
+ },
142
+ "connectInfo": {
143
+ "type": "object",
144
+ "properties": {
145
+ "ts": {
146
+ "type": [
147
+ "number",
148
+ "null"
149
+ ]
150
+ }
151
+ }
152
+ },
153
+ "disconnectInfo": {
154
+ "type": "object",
155
+ "properties": {
156
+ "ts": {
157
+ "type": [
158
+ "number",
159
+ "null"
160
+ ]
161
+ },
162
+ "error": {
163
+ "type": "string"
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }