losant_rest 1.18.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +10703 -1558
  3. data/docs/credential.md +175 -0
  4. data/docs/credentials.md +93 -0
  5. data/lib/losant_rest/client.rb +10 -2
  6. data/lib/losant_rest/credential.rb +224 -0
  7. data/lib/losant_rest/credentials.rb +138 -0
  8. data/lib/losant_rest/version.rb +1 -1
  9. data/lib/losant_rest.rb +2 -0
  10. data/schemas/apiTokenPost.json +8 -0
  11. data/schemas/application.json +9 -8
  12. data/schemas/applicationCreationByTemplateResult.json +9 -8
  13. data/schemas/applicationPatch.json +6 -8
  14. data/schemas/applicationPost.json +6 -8
  15. data/schemas/applications.json +9 -8
  16. data/schemas/credential.json +115 -0
  17. data/schemas/credentialLinkedResources.json +8254 -0
  18. data/schemas/credentialPatch.json +66 -0
  19. data/schemas/credentialPost.json +89 -0
  20. data/schemas/credentials.json +160 -0
  21. data/schemas/dashboardPatch.json +10 -3
  22. data/schemas/dashboardPost.json +10 -3
  23. data/schemas/device.json +8 -0
  24. data/schemas/devices.json +8 -0
  25. data/schemas/experienceGroup.json +8 -0
  26. data/schemas/experienceGroups.json +8 -0
  27. data/schemas/experienceLinkedResources.json +6 -3
  28. data/schemas/flow.json +2 -1
  29. data/schemas/flowPatch.json +2 -1
  30. data/schemas/flowPost.json +2 -1
  31. data/schemas/flowVersion.json +4 -2
  32. data/schemas/flowVersionPost.json +2 -1
  33. data/schemas/flowVersions.json +4 -2
  34. data/schemas/flows.json +2 -1
  35. data/schemas/flowsImportPost.json +4 -2
  36. data/schemas/flowsImportResult.json +6 -3
  37. data/schemas/githubLogin.json +8 -0
  38. data/schemas/historicalSummaries.json +4 -0
  39. data/schemas/historicalSummary.json +4 -0
  40. data/schemas/instance.json +7 -0
  41. data/schemas/instanceOrg.json +4 -0
  42. data/schemas/instanceOrgPatch.json +4 -0
  43. data/schemas/instanceOrgPost.json +4 -0
  44. data/schemas/instanceOrgs.json +4 -0
  45. data/schemas/instancePatch.json +4 -0
  46. data/schemas/instanceSandbox.json +6 -0
  47. data/schemas/instanceSandboxes.json +6 -0
  48. data/schemas/instances.json +7 -0
  49. data/schemas/integration.json +26 -12
  50. data/schemas/integrationPatch.json +33 -12
  51. data/schemas/integrationPost.json +26 -12
  52. data/schemas/integrations.json +26 -12
  53. data/schemas/me.json +6 -0
  54. data/schemas/org.json +7 -0
  55. data/schemas/orgs.json +7 -0
  56. data/schemas/samlResponse.json +8 -0
  57. data/schemas/userCredentials.json +8 -0
  58. data/schemas/userPost.json +8 -0
  59. metadata +11 -2
@@ -0,0 +1,175 @@
1
+ # Credential Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Credential resource, including the expected
5
+ parameters and the potential responses.
6
+
7
+ ##### Contents
8
+
9
+ * [Delete](#delete)
10
+ * [Get](#get)
11
+ * [Linked Resources](#linked-resources)
12
+ * [Patch](#patch)
13
+
14
+ <br/>
15
+
16
+ ## Delete
17
+
18
+ Deletes a credential
19
+
20
+ ```ruby
21
+ result = client.credential.delete(
22
+ applicationId: my_application_id,
23
+ credentialId: my_credential_id)
24
+
25
+ puts result
26
+ ```
27
+
28
+ #### Authentication
29
+ The client must be configured with a valid api access token to call this
30
+ action. The token must include at least one of the following scopes:
31
+ all.Application, all.Organization, all.User, credential.*, or credential.delete.
32
+
33
+ #### Available Parameters
34
+
35
+ | Name | Type | Required | Description | Default | Example |
36
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
37
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
38
+ | credentialId | string | Y | ID associated with the credential | | 575ec76c7ae143cd83dc4a96 |
39
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
40
+
41
+ #### Successful Responses
42
+
43
+ | Code | Type | Description |
44
+ | ---- | ---- | ----------- |
45
+ | 200 | [Success](_schemas.md#success) | If credential was successfully deleted |
46
+
47
+ #### Error Responses
48
+
49
+ | Code | Type | Description |
50
+ | ---- | ---- | ----------- |
51
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
52
+ | 404 | [Error](_schemas.md#error) | Error if credential was not found |
53
+
54
+ <br/>
55
+
56
+ ## Get
57
+
58
+ Retrieves information on a credential
59
+
60
+ ```ruby
61
+ result = client.credential.get(
62
+ applicationId: my_application_id,
63
+ credentialId: my_credential_id)
64
+
65
+ puts result
66
+ ```
67
+
68
+ #### Authentication
69
+ The client must be configured with a valid api access token to call this
70
+ action. The token must include at least one of the following scopes:
71
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credential.*, or credential.get.
72
+
73
+ #### Available Parameters
74
+
75
+ | Name | Type | Required | Description | Default | Example |
76
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
77
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
78
+ | credentialId | string | Y | ID associated with the credential | | 575ec76c7ae143cd83dc4a96 |
79
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
80
+
81
+ #### Successful Responses
82
+
83
+ | Code | Type | Description |
84
+ | ---- | ---- | ----------- |
85
+ | 200 | [Credential](_schemas.md#credential) | credential information |
86
+
87
+ #### Error Responses
88
+
89
+ | Code | Type | Description |
90
+ | ---- | ---- | ----------- |
91
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
92
+ | 404 | [Error](_schemas.md#error) | Error if credential was not found |
93
+
94
+ <br/>
95
+
96
+ ## Linked Resources
97
+
98
+ Retrieves information on resources linked to a credential
99
+
100
+ ```ruby
101
+ result = client.credential.linked_resources(
102
+ applicationId: my_application_id,
103
+ credentialId: my_credential_id)
104
+
105
+ puts result
106
+ ```
107
+
108
+ #### Authentication
109
+ The client must be configured with a valid api access token to call this
110
+ action. The token must include at least one of the following scopes:
111
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credential.*, or credential.linkedResources.
112
+
113
+ #### Available Parameters
114
+
115
+ | Name | Type | Required | Description | Default | Example |
116
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
117
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
118
+ | credentialId | string | Y | ID associated with the credential | | 575ec76c7ae143cd83dc4a96 |
119
+ | includeCustomNodes | string | N | If the result of the request should also include the details of any custom nodes referenced by returned workflows | false | true |
120
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
121
+
122
+ #### Successful Responses
123
+
124
+ | Code | Type | Description |
125
+ | ---- | ---- | ----------- |
126
+ | 200 | [Credential Linked Resources](_schemas.md#credential-linked-resources) | Linked resource information |
127
+
128
+ #### Error Responses
129
+
130
+ | Code | Type | Description |
131
+ | ---- | ---- | ----------- |
132
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
133
+ | 404 | [Error](_schemas.md#error) | Error if credential was not found |
134
+
135
+ <br/>
136
+
137
+ ## Patch
138
+
139
+ Updates information about a credential
140
+
141
+ ```ruby
142
+ result = client.credential.patch(
143
+ applicationId: my_application_id,
144
+ credentialId: my_credential_id,
145
+ credential: my_credential)
146
+
147
+ puts result
148
+ ```
149
+
150
+ #### Authentication
151
+ The client must be configured with a valid api access token to call this
152
+ action. The token must include at least one of the following scopes:
153
+ all.Application, all.Organization, all.User, credential.*, or credential.patch.
154
+
155
+ #### Available Parameters
156
+
157
+ | Name | Type | Required | Description | Default | Example |
158
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
159
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
160
+ | credentialId | string | Y | ID associated with the credential | | 575ec76c7ae143cd83dc4a96 |
161
+ | credential | [Credential Patch](_schemas.md#credential-patch) | Y | Object containing new properties of the credential | | [Credential Patch Example](_schemas.md#credential-patch-example) |
162
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
163
+
164
+ #### Successful Responses
165
+
166
+ | Code | Type | Description |
167
+ | ---- | ---- | ----------- |
168
+ | 200 | [Credential](_schemas.md#credential) | Updated credential information |
169
+
170
+ #### Error Responses
171
+
172
+ | Code | Type | Description |
173
+ | ---- | ---- | ----------- |
174
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
175
+ | 404 | [Error](_schemas.md#error) | Error if credential was not found |
@@ -0,0 +1,93 @@
1
+ # Credentials Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Credentials resource, including the expected
5
+ parameters and the potential responses.
6
+
7
+ ##### Contents
8
+
9
+ * [Get](#get)
10
+ * [Post](#post)
11
+
12
+ <br/>
13
+
14
+ ## Get
15
+
16
+ Returns a collection of credentials for an application
17
+
18
+ ```ruby
19
+ result = client.credentials.get(applicationId: my_application_id)
20
+
21
+ puts result
22
+ ```
23
+
24
+ #### Authentication
25
+ The client must be configured with a valid api access token to call this
26
+ action. The token must include at least one of the following scopes:
27
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credentials.*, or credentials.get.
28
+
29
+ #### Available Parameters
30
+
31
+ | Name | Type | Required | Description | Default | Example |
32
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
33
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
34
+ | sortField | string | N | Field to sort the results by. Accepted values are: name, type, creationDate, lastUpdated | creationDate | creationDate |
35
+ | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | desc | asc |
36
+ | page | string | N | Which page of results to return | 0 | 0 |
37
+ | perPage | string | N | How many items to return per page | 100 | 10 |
38
+ | filterField | string | N | Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, type | | type |
39
+ | filter | string | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | | aws |
40
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
41
+
42
+ #### Successful Responses
43
+
44
+ | Code | Type | Description |
45
+ | ---- | ---- | ----------- |
46
+ | 200 | [Credentials](_schemas.md#credentials) | Collection of credentials |
47
+
48
+ #### Error Responses
49
+
50
+ | Code | Type | Description |
51
+ | ---- | ---- | ----------- |
52
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
53
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
54
+
55
+ <br/>
56
+
57
+ ## Post
58
+
59
+ Create a new credential for an application
60
+
61
+ ```ruby
62
+ result = client.credentials.post(
63
+ applicationId: my_application_id,
64
+ credential: my_credential)
65
+
66
+ puts result
67
+ ```
68
+
69
+ #### Authentication
70
+ The client must be configured with a valid api access token to call this
71
+ action. The token must include at least one of the following scopes:
72
+ all.Application, all.Organization, all.User, credentials.*, or credentials.post.
73
+
74
+ #### Available Parameters
75
+
76
+ | Name | Type | Required | Description | Default | Example |
77
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
78
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
79
+ | credential | [Credential Post](_schemas.md#credential-post) | Y | Credential information | | [Credential Post Example](_schemas.md#credential-post-example) |
80
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
81
+
82
+ #### Successful Responses
83
+
84
+ | Code | Type | Description |
85
+ | ---- | ---- | ----------- |
86
+ | 201 | [Credential](_schemas.md#credential) | Successfully created credential |
87
+
88
+ #### Error Responses
89
+
90
+ | Code | Type | Description |
91
+ | ---- | ---- | ----------- |
92
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
93
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.25.0
30
+ # Built For Version 1.26.0
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -104,6 +104,14 @@ module LosantRest
104
104
  @auth ||= Auth.new(self)
105
105
  end
106
106
 
107
+ def credential
108
+ @credential ||= Credential.new(self)
109
+ end
110
+
111
+ def credentials
112
+ @credentials ||= Credentials.new(self)
113
+ end
114
+
107
115
  def dashboard
108
116
  @dashboard ||= Dashboard.new(self)
109
117
  end
@@ -382,7 +390,7 @@ module LosantRest
382
390
 
383
391
  headers["Accept"] = "application/json"
384
392
  headers["Content-Type"] = "application/json"
385
- headers["Accept-Version"] = "^1.25.0"
393
+ headers["Accept-Version"] = "^1.26.0"
386
394
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
387
395
  path = self.url + options.fetch(:path, "")
388
396
 
@@ -0,0 +1,224 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2023 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
+ require "json"
24
+
25
+ module LosantRest
26
+
27
+ # Class containing all the actions for the Credential Resource
28
+ class Credential
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Deletes a credential
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action. The token
39
+ # must include at least one of the following scopes:
40
+ # all.Application, all.Organization, all.User, credential.*, or credential.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} credentialId - ID associated with the credential
45
+ # * {string} losantdomain - Domain scope of request (rarely needed)
46
+ # * {boolean} _actions - Return resource actions in response
47
+ # * {boolean} _links - Return resource link in response
48
+ # * {boolean} _embedded - Return embedded resources in response
49
+ #
50
+ # Responses:
51
+ # * 200 - If credential was successfully deleted (https://api.losant.com/#/definitions/success)
52
+ #
53
+ # Errors:
54
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
+ # * 404 - Error if credential was not found (https://api.losant.com/#/definitions/error)
56
+ def delete(params = {})
57
+ params = Utils.symbolize_hash_keys(params)
58
+ query_params = { _actions: false, _links: true, _embedded: true }
59
+ headers = {}
60
+ body = nil
61
+
62
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
63
+ raise ArgumentError.new("credentialId is required") unless params.has_key?(:credentialId)
64
+
65
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
66
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
67
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
68
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
69
+
70
+ path = "/applications/#{params[:applicationId]}/credentials/#{params[:credentialId]}"
71
+
72
+ @client.request(
73
+ method: :delete,
74
+ path: path,
75
+ query: query_params,
76
+ headers: headers,
77
+ body: body)
78
+ end
79
+
80
+ # Retrieves information on a credential
81
+ #
82
+ # Authentication:
83
+ # The client must be configured with a valid api
84
+ # access token to call this action. The token
85
+ # must include at least one of the following scopes:
86
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credential.*, or credential.get.
87
+ #
88
+ # Parameters:
89
+ # * {string} applicationId - ID associated with the application
90
+ # * {string} credentialId - ID associated with the credential
91
+ # * {string} losantdomain - Domain scope of request (rarely needed)
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 - credential information (https://api.losant.com/#/definitions/credential)
98
+ #
99
+ # Errors:
100
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
101
+ # * 404 - Error if credential was not found (https://api.losant.com/#/definitions/error)
102
+ def get(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("credentialId is required") unless params.has_key?(:credentialId)
110
+
111
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
112
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
113
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
114
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
115
+
116
+ path = "/applications/#{params[:applicationId]}/credentials/#{params[:credentialId]}"
117
+
118
+ @client.request(
119
+ method: :get,
120
+ path: path,
121
+ query: query_params,
122
+ headers: headers,
123
+ body: body)
124
+ end
125
+
126
+ # Retrieves information on resources linked to a credential
127
+ #
128
+ # Authentication:
129
+ # The client must be configured with a valid api
130
+ # access token to call this action. The token
131
+ # must include at least one of the following scopes:
132
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credential.*, or credential.linkedResources.
133
+ #
134
+ # Parameters:
135
+ # * {string} applicationId - ID associated with the application
136
+ # * {string} credentialId - ID associated with the credential
137
+ # * {string} includeCustomNodes - If the result of the request should also include the details of any custom nodes referenced by returned workflows
138
+ # * {string} losantdomain - Domain scope of request (rarely needed)
139
+ # * {boolean} _actions - Return resource actions in response
140
+ # * {boolean} _links - Return resource link in response
141
+ # * {boolean} _embedded - Return embedded resources in response
142
+ #
143
+ # Responses:
144
+ # * 200 - Linked resource information (https://api.losant.com/#/definitions/credentialLinkedResources)
145
+ #
146
+ # Errors:
147
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
148
+ # * 404 - Error if credential was not found (https://api.losant.com/#/definitions/error)
149
+ def linked_resources(params = {})
150
+ params = Utils.symbolize_hash_keys(params)
151
+ query_params = { _actions: false, _links: true, _embedded: true }
152
+ headers = {}
153
+ body = nil
154
+
155
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
156
+ raise ArgumentError.new("credentialId is required") unless params.has_key?(:credentialId)
157
+
158
+ query_params[:includeCustomNodes] = params[:includeCustomNodes] if params.has_key?(:includeCustomNodes)
159
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
160
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
161
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
162
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
163
+
164
+ path = "/applications/#{params[:applicationId]}/credentials/#{params[:credentialId]}/linkedResources"
165
+
166
+ @client.request(
167
+ method: :get,
168
+ path: path,
169
+ query: query_params,
170
+ headers: headers,
171
+ body: body)
172
+ end
173
+
174
+ # Updates information about a credential
175
+ #
176
+ # Authentication:
177
+ # The client must be configured with a valid api
178
+ # access token to call this action. The token
179
+ # must include at least one of the following scopes:
180
+ # all.Application, all.Organization, all.User, credential.*, or credential.patch.
181
+ #
182
+ # Parameters:
183
+ # * {string} applicationId - ID associated with the application
184
+ # * {string} credentialId - ID associated with the credential
185
+ # * {hash} credential - Object containing new properties of the credential (https://api.losant.com/#/definitions/credentialPatch)
186
+ # * {string} losantdomain - Domain scope of request (rarely needed)
187
+ # * {boolean} _actions - Return resource actions in response
188
+ # * {boolean} _links - Return resource link in response
189
+ # * {boolean} _embedded - Return embedded resources in response
190
+ #
191
+ # Responses:
192
+ # * 200 - Updated credential information (https://api.losant.com/#/definitions/credential)
193
+ #
194
+ # Errors:
195
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
196
+ # * 404 - Error if credential was not found (https://api.losant.com/#/definitions/error)
197
+ def patch(params = {})
198
+ params = Utils.symbolize_hash_keys(params)
199
+ query_params = { _actions: false, _links: true, _embedded: true }
200
+ headers = {}
201
+ body = nil
202
+
203
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
204
+ raise ArgumentError.new("credentialId is required") unless params.has_key?(:credentialId)
205
+ raise ArgumentError.new("credential is required") unless params.has_key?(:credential)
206
+
207
+ body = params[:credential] if params.has_key?(:credential)
208
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
209
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
210
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
211
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
212
+
213
+ path = "/applications/#{params[:applicationId]}/credentials/#{params[:credentialId]}"
214
+
215
+ @client.request(
216
+ method: :patch,
217
+ path: path,
218
+ query: query_params,
219
+ headers: headers,
220
+ body: body)
221
+ end
222
+
223
+ end
224
+ end
@@ -0,0 +1,138 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2023 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
+ require "json"
24
+
25
+ module LosantRest
26
+
27
+ # Class containing all the actions for the Credentials Resource
28
+ class Credentials
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Returns a collection of credentials for an application
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action. The token
39
+ # must include at least one of the following scopes:
40
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, credentials.*, or credentials.get.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, type, creationDate, lastUpdated
45
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
46
+ # * {string} page - Which page of results to return
47
+ # * {string} perPage - How many items to return per page
48
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, type
49
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
50
+ # * {string} losantdomain - Domain scope of request (rarely needed)
51
+ # * {boolean} _actions - Return resource actions in response
52
+ # * {boolean} _links - Return resource link in response
53
+ # * {boolean} _embedded - Return embedded resources in response
54
+ #
55
+ # Responses:
56
+ # * 200 - Collection of credentials (https://api.losant.com/#/definitions/credentials)
57
+ #
58
+ # Errors:
59
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
60
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
61
+ def get(params = {})
62
+ params = Utils.symbolize_hash_keys(params)
63
+ query_params = { _actions: false, _links: true, _embedded: true }
64
+ headers = {}
65
+ body = nil
66
+
67
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
68
+
69
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
70
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
71
+ query_params[:page] = params[:page] if params.has_key?(:page)
72
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
73
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
74
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
75
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
76
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
77
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
78
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
79
+
80
+ path = "/applications/#{params[:applicationId]}/credentials"
81
+
82
+ @client.request(
83
+ method: :get,
84
+ path: path,
85
+ query: query_params,
86
+ headers: headers,
87
+ body: body)
88
+ end
89
+
90
+ # Create a new credential for an application
91
+ #
92
+ # Authentication:
93
+ # The client must be configured with a valid api
94
+ # access token to call this action. The token
95
+ # must include at least one of the following scopes:
96
+ # all.Application, all.Organization, all.User, credentials.*, or credentials.post.
97
+ #
98
+ # Parameters:
99
+ # * {string} applicationId - ID associated with the application
100
+ # * {hash} credential - Credential information (https://api.losant.com/#/definitions/credentialPost)
101
+ # * {string} losantdomain - Domain scope of request (rarely needed)
102
+ # * {boolean} _actions - Return resource actions in response
103
+ # * {boolean} _links - Return resource link in response
104
+ # * {boolean} _embedded - Return embedded resources in response
105
+ #
106
+ # Responses:
107
+ # * 201 - Successfully created credential (https://api.losant.com/#/definitions/credential)
108
+ #
109
+ # Errors:
110
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
111
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
112
+ def post(params = {})
113
+ params = Utils.symbolize_hash_keys(params)
114
+ query_params = { _actions: false, _links: true, _embedded: true }
115
+ headers = {}
116
+ body = nil
117
+
118
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
119
+ raise ArgumentError.new("credential is required") unless params.has_key?(:credential)
120
+
121
+ body = params[:credential] if params.has_key?(:credential)
122
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
123
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
124
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
125
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
126
+
127
+ path = "/applications/#{params[:applicationId]}/credentials"
128
+
129
+ @client.request(
130
+ method: :post,
131
+ path: path,
132
+ query: query_params,
133
+ headers: headers,
134
+ body: body)
135
+ end
136
+
137
+ end
138
+ end
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module LosantRest
24
- VERSION = "1.18.0"
24
+ VERSION = "1.19.0"
25
25
  end
data/lib/losant_rest.rb CHANGED
@@ -40,6 +40,8 @@ require_relative "losant_rest/applications"
40
40
  require_relative "losant_rest/audit_log"
41
41
  require_relative "losant_rest/audit_logs"
42
42
  require_relative "losant_rest/auth"
43
+ require_relative "losant_rest/credential"
44
+ require_relative "losant_rest/credentials"
43
45
  require_relative "losant_rest/dashboard"
44
46
  require_relative "losant_rest/dashboards"
45
47
  require_relative "losant_rest/data"