losant_rest 1.13.0 → 1.13.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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +2317 -650
  3. data/docs/application.md +5 -5
  4. data/docs/applicationApiTokens.md +1 -1
  5. data/docs/applications.md +1 -1
  6. data/docs/dataTable.md +1 -1
  7. data/docs/dataTableRows.md +1 -1
  8. data/docs/dataTables.md +1 -1
  9. data/docs/devices.md +2 -2
  10. data/docs/experience.md +1 -1
  11. data/docs/experienceDomains.md +1 -1
  12. data/docs/experienceGroup.md +2 -0
  13. data/docs/experienceSlugs.md +1 -1
  14. data/docs/experienceVersion.md +3 -3
  15. data/docs/experienceVersions.md +2 -2
  16. data/docs/experienceView.md +4 -4
  17. data/docs/experienceViews.md +2 -2
  18. data/docs/file.md +5 -5
  19. data/docs/files.md +2 -2
  20. data/docs/flowVersions.md +44 -0
  21. data/docs/instance.md +38 -0
  22. data/docs/instanceApiToken.md +133 -0
  23. data/docs/instanceApiTokens.md +91 -0
  24. data/docs/instanceMembers.md +1 -1
  25. data/docs/instanceOrgMembers.md +1 -1
  26. data/docs/userApiToken.md +125 -0
  27. data/docs/userApiTokens.md +87 -0
  28. data/lib/losant_rest.rb +4 -0
  29. data/lib/losant_rest/application.rb +5 -5
  30. data/lib/losant_rest/application_api_tokens.rb +1 -1
  31. data/lib/losant_rest/applications.rb +1 -1
  32. data/lib/losant_rest/client.rb +18 -2
  33. data/lib/losant_rest/data_table.rb +1 -1
  34. data/lib/losant_rest/data_table_rows.rb +1 -1
  35. data/lib/losant_rest/data_tables.rb +1 -1
  36. data/lib/losant_rest/devices.rb +2 -2
  37. data/lib/losant_rest/experience.rb +1 -1
  38. data/lib/losant_rest/experience_domains.rb +1 -1
  39. data/lib/losant_rest/experience_group.rb +4 -0
  40. data/lib/losant_rest/experience_slugs.rb +1 -1
  41. data/lib/losant_rest/experience_version.rb +3 -3
  42. data/lib/losant_rest/experience_versions.rb +2 -2
  43. data/lib/losant_rest/experience_view.rb +4 -4
  44. data/lib/losant_rest/experience_views.rb +2 -2
  45. data/lib/losant_rest/file.rb +4 -4
  46. data/lib/losant_rest/files.rb +2 -2
  47. data/lib/losant_rest/flow_versions.rb +50 -0
  48. data/lib/losant_rest/instance.rb +46 -1
  49. data/lib/losant_rest/instance_api_token.rb +176 -0
  50. data/lib/losant_rest/instance_api_tokens.rb +136 -0
  51. data/lib/losant_rest/instance_member.rb +1 -1
  52. data/lib/losant_rest/instance_members.rb +2 -2
  53. data/lib/losant_rest/instance_org.rb +1 -1
  54. data/lib/losant_rest/instance_org_member.rb +1 -1
  55. data/lib/losant_rest/instance_org_members.rb +2 -2
  56. data/lib/losant_rest/instance_orgs.rb +1 -1
  57. data/lib/losant_rest/instances.rb +1 -1
  58. data/lib/losant_rest/user_api_token.rb +170 -0
  59. data/lib/losant_rest/user_api_tokens.rb +132 -0
  60. data/lib/losant_rest/version.rb +1 -1
  61. data/schemas/apiToken.json +2 -1
  62. data/schemas/apiTokenPost.json +420 -0
  63. data/schemas/apiTokens.json +4 -2
  64. data/schemas/applicationDashboardPost.json +20 -16
  65. data/schemas/auditLog.json +4 -0
  66. data/schemas/auditLogFilter.json +4 -0
  67. data/schemas/auditLogs.json +4 -0
  68. data/schemas/bulkDeleteResponse.json +12 -0
  69. data/schemas/dashboard.json +20 -16
  70. data/schemas/dashboardPatch.json +20 -16
  71. data/schemas/dashboardPost.json +20 -16
  72. data/schemas/dashboardSendReport.json +4 -0
  73. data/schemas/dashboards.json +20 -16
  74. data/schemas/experienceGroup.json +6 -0
  75. data/schemas/experienceGroups.json +6 -0
  76. data/schemas/flowVersionsDeletePost.json +941 -0
  77. data/schemas/githubLogin.json +19 -1
  78. data/schemas/historicalSummary.json +3 -0
  79. data/schemas/instance.json +60 -0
  80. data/schemas/instanceOrgPost.json +166 -0
  81. data/schemas/instancePatch.json +67 -0
  82. data/schemas/instanceReportOptionsPost.json +1 -0
  83. data/schemas/notebook.json +15 -0
  84. data/schemas/notebooks.json +15 -0
  85. data/schemas/userCredentials.json +19 -1
  86. data/schemas/userPost.json +19 -1
  87. data/schemas/validateContextError.json +34 -0
  88. data/schemas/validateContextSuccess.json +34 -0
  89. metadata +15 -3
@@ -132,7 +132,7 @@ module LosantRest
132
132
  # The client must be configured with a valid api
133
133
  # access token to call this action. The token
134
134
  # must include at least one of the following scopes:
135
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTable.*, or dataTable.get.
135
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTable.*, or dataTable.get.
136
136
  #
137
137
  # Parameters:
138
138
  # * {string} applicationId - ID associated with the application
@@ -136,7 +136,7 @@ module LosantRest
136
136
  # The client must be configured with a valid api
137
137
  # access token to call this action. The token
138
138
  # must include at least one of the following scopes:
139
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.get.
139
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTableRows.*, or dataTableRows.get.
140
140
  #
141
141
  # Parameters:
142
142
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, dataTables.*, or dataTables.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTables.*, or dataTables.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -99,7 +99,7 @@ module LosantRest
99
99
  # * {boolean} _embedded - Return embedded resources in response
100
100
  #
101
101
  # Responses:
102
- # * 200 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/devicesDeleted)
102
+ # * 200 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/bulkDeleteResponse)
103
103
  # * 202 - If a job was enqueued for the devices to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult)
104
104
  #
105
105
  # Errors:
@@ -190,7 +190,7 @@ module LosantRest
190
190
  #
191
191
  # Parameters:
192
192
  # * {string} applicationId - ID associated with the application
193
- # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated
193
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus
194
194
  # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
195
195
  # * {string} page - Which page of results to return
196
196
  # * {string} perPage - How many items to return per page
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
39
  # must include at least one of the following scopes:
40
- # all.Application, all.Organization, all.User, experience.*, or experience.bootstrap.
40
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experience.*, or experience.bootstrap.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, experienceDomains.*, or experienceDomains.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceDomains.*, or experienceDomains.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -88,6 +88,8 @@ module LosantRest
88
88
  # Parameters:
89
89
  # * {string} applicationId - ID associated with the application
90
90
  # * {string} experienceGroupId - ID associated with the experience group
91
+ # * {string} includeDirectDeviceCount - Whether or not to return count of devices associated directly with this group
92
+ # * {string} includeTotalDeviceCount - Whether or not to return count of devices associated with this group or any of its descendents
91
93
  # * {string} losantdomain - Domain scope of request (rarely needed)
92
94
  # * {boolean} _actions - Return resource actions in response
93
95
  # * {boolean} _links - Return resource link in response
@@ -108,6 +110,8 @@ module LosantRest
108
110
  raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
109
111
  raise ArgumentError.new("experienceGroupId is required") unless params.has_key?(:experienceGroupId)
110
112
 
113
+ query_params[:includeDirectDeviceCount] = params[:includeDirectDeviceCount] if params.has_key?(:includeDirectDeviceCount)
114
+ query_params[:includeTotalDeviceCount] = params[:includeTotalDeviceCount] if params.has_key?(:includeTotalDeviceCount)
111
115
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
112
116
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
113
117
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, experienceSlugs.*, or experienceSlugs.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceSlugs.*, or experienceSlugs.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
39
  # must include at least one of the following scopes:
40
- # all.Application, all.Organization, all.User, experienceVersion.*, or experienceVersion.delete.
40
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceVersion.*, or experienceVersion.delete.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -83,7 +83,7 @@ module LosantRest
83
83
  # The client must be configured with a valid api
84
84
  # access token to call this action. The token
85
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, experienceVersion.*, or experienceVersion.get.
86
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceVersion.*, or experienceVersion.get.
87
87
  #
88
88
  # Parameters:
89
89
  # * {string} applicationId - ID associated with the application
@@ -129,7 +129,7 @@ module LosantRest
129
129
  # The client must be configured with a valid api
130
130
  # access token to call this action. The token
131
131
  # must include at least one of the following scopes:
132
- # all.Application, all.Organization, all.User, experienceVersion.*, or experienceVersion.patch.
132
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceVersion.*, or experienceVersion.patch.
133
133
  #
134
134
  # Parameters:
135
135
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, experienceVersions.*, or experienceVersions.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceVersions.*, or experienceVersions.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -93,7 +93,7 @@ module LosantRest
93
93
  # The client must be configured with a valid api
94
94
  # access token to call this action. The token
95
95
  # must include at least one of the following scopes:
96
- # all.Application, all.Organization, all.User, experienceVersions.*, or experienceVersions.post.
96
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceVersions.*, or experienceVersions.post.
97
97
  #
98
98
  # Parameters:
99
99
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
39
  # must include at least one of the following scopes:
40
- # all.Application, all.Organization, all.User, experienceView.*, or experienceView.delete.
40
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceView.*, or experienceView.delete.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -83,7 +83,7 @@ module LosantRest
83
83
  # The client must be configured with a valid api
84
84
  # access token to call this action. The token
85
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, experienceView.*, or experienceView.get.
86
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceView.*, or experienceView.get.
87
87
  #
88
88
  # Parameters:
89
89
  # * {string} applicationId - ID associated with the application
@@ -131,7 +131,7 @@ module LosantRest
131
131
  # The client must be configured with a valid api
132
132
  # access token to call this action. The token
133
133
  # must include at least one of the following scopes:
134
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, experienceView.*, or experienceView.linkedResources.
134
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceView.*, or experienceView.linkedResources.
135
135
  #
136
136
  # Parameters:
137
137
  # * {string} applicationId - ID associated with the application
@@ -181,7 +181,7 @@ module LosantRest
181
181
  # The client must be configured with a valid api
182
182
  # access token to call this action. The token
183
183
  # must include at least one of the following scopes:
184
- # all.Application, all.Organization, all.User, experienceView.*, or experienceView.patch.
184
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceView.*, or experienceView.patch.
185
185
  #
186
186
  # Parameters:
187
187
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, experienceViews.*, or experienceViews.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, experienceViews.*, or experienceViews.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -97,7 +97,7 @@ module LosantRest
97
97
  # The client must be configured with a valid api
98
98
  # access token to call this action. The token
99
99
  # must include at least one of the following scopes:
100
- # all.Application, all.Organization, all.User, experienceViews.*, or experienceViews.post.
100
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, experienceViews.*, or experienceViews.post.
101
101
  #
102
102
  # Parameters:
103
103
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
39
  # must include at least one of the following scopes:
40
- # all.Application, all.Organization, all.User, file.*, or file.delete.
40
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, file.*, or file.delete.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -83,7 +83,7 @@ module LosantRest
83
83
  # The client must be configured with a valid api
84
84
  # access token to call this action. The token
85
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, file.*, or file.get.
86
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, file.*, or file.get.
87
87
  #
88
88
  # Parameters:
89
89
  # * {string} applicationId - ID associated with the application
@@ -129,7 +129,7 @@ module LosantRest
129
129
  # The client must be configured with a valid api
130
130
  # access token to call this action. The token
131
131
  # must include at least one of the following scopes:
132
- # all.Application, all.Organization, all.User, file.*, or file.move.
132
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, file.*, or file.move.
133
133
  #
134
134
  # Parameters:
135
135
  # * {string} applicationId - ID associated with the application
@@ -179,7 +179,7 @@ module LosantRest
179
179
  # The client must be configured with a valid api
180
180
  # access token to call this action. The token
181
181
  # must include at least one of the following scopes:
182
- # all.Application, all.Organization, all.User, file.*, or file.patch.
182
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, file.*, or file.patch.
183
183
  #
184
184
  # Parameters:
185
185
  # * {string} applicationId - ID associated with the application
@@ -37,7 +37,7 @@ module LosantRest
37
37
  # The client must be configured with a valid api
38
38
  # access token to call this action. The token
39
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, files.*, or files.get.
40
+ # all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, files.*, or files.get.
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
@@ -99,7 +99,7 @@ module LosantRest
99
99
  # The client must be configured with a valid api
100
100
  # access token to call this action. The token
101
101
  # must include at least one of the following scopes:
102
- # all.Application, all.Organization, all.User, files.*, or files.post.
102
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, files.*, or files.post.
103
103
  #
104
104
  # Parameters:
105
105
  # * {string} applicationId - ID associated with the application
@@ -31,6 +31,56 @@ module LosantRest
31
31
  @client = client
32
32
  end
33
33
 
34
+ # Delete flow versions
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, flowVersions.*, or flowVersions.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} flowId - ID associated with the flow
45
+ # * {hash} options - Object containing flow version deletion options (https://api.losant.com/#/definitions/flowVersionsDeletePost)
46
+ # * {string} losantdomain - Domain scope of request (rarely needed)
47
+ # * {boolean} _actions - Return resource actions in response
48
+ # * {boolean} _links - Return resource link in response
49
+ # * {boolean} _embedded - Return embedded resources in response
50
+ #
51
+ # Responses:
52
+ # * 200 - Object indicating number of flow versions deleted or failed (https://api.losant.com/#/definitions/bulkDeleteResponse)
53
+ # * 202 - If a job was enqueued for the flow versions to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult)
54
+ #
55
+ # Errors:
56
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
57
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
58
+ def delete(params = {})
59
+ params = Utils.symbolize_hash_keys(params)
60
+ query_params = { _actions: false, _links: true, _embedded: true }
61
+ headers = {}
62
+ body = nil
63
+
64
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
65
+ raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
66
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
67
+
68
+ body = params[:options] if params.has_key?(:options)
69
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
70
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
71
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
72
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
73
+
74
+ path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/versions/delete"
75
+
76
+ @client.request(
77
+ method: :post,
78
+ path: path,
79
+ query: query_params,
80
+ headers: headers,
81
+ body: body)
82
+ end
83
+
34
84
  # Returns the flow versions for a flow
35
85
  #
36
86
  # Authentication:
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2020 Losant IoT, Inc.
3
+ # Copyright (c) 2021 Losant IoT, Inc.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -177,5 +177,50 @@ module LosantRest
177
177
  body: body)
178
178
  end
179
179
 
180
+ # Updates information about an instance
181
+ #
182
+ # Authentication:
183
+ # The client must be configured with a valid api
184
+ # access token to call this action. The token
185
+ # must include at least one of the following scopes:
186
+ # all.Instance, all.User, instance.*, or instance.patch.
187
+ #
188
+ # Parameters:
189
+ # * {string} instanceId - ID associated with the instance
190
+ # * {hash} instance - Updated instance information (https://api.losant.com/#/definitions/instancePatch)
191
+ # * {string} losantdomain - Domain scope of request (rarely needed)
192
+ # * {boolean} _actions - Return resource actions in response
193
+ # * {boolean} _links - Return resource link in response
194
+ # * {boolean} _embedded - Return embedded resources in response
195
+ #
196
+ # Responses:
197
+ # * 200 - The updated instance object (https://api.losant.com/#/definitions/instance)
198
+ #
199
+ # Errors:
200
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
201
+ def patch(params = {})
202
+ params = Utils.symbolize_hash_keys(params)
203
+ query_params = { _actions: false, _links: true, _embedded: true }
204
+ headers = {}
205
+ body = nil
206
+
207
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
208
+
209
+ body = params[:instance] if params.has_key?(:instance)
210
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
211
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
212
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
213
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
214
+
215
+ path = "/instances/#{params[:instanceId]}"
216
+
217
+ @client.request(
218
+ method: :patch,
219
+ path: path,
220
+ query: query_params,
221
+ headers: headers,
222
+ body: body)
223
+ end
224
+
180
225
  end
181
226
  end
@@ -0,0 +1,176 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2021 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 Instance Api Token Resource
28
+ class InstanceApiToken
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Deletes an API Token
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.Instance, all.User, instanceApiToken.*, or instanceApiToken.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} instanceId - ID associated with the instance
44
+ # * {string} apiTokenId - ID associated with the API token
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 API token 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 API token 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("instanceId is required") unless params.has_key?(:instanceId)
63
+ raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
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 = "/instances/#{params[:instanceId]}/tokens/#{params[:apiTokenId]}"
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 an API token
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.Instance, all.Instance.read, all.User, all.User.read, instanceApiToken.*, or instanceApiToken.get.
87
+ #
88
+ # Parameters:
89
+ # * {string} instanceId - ID associated with the instance
90
+ # * {string} apiTokenId - ID associated with the API token
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 - API token information (https://api.losant.com/#/definitions/apiToken)
98
+ #
99
+ # Errors:
100
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
101
+ # * 404 - Error if API token 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("instanceId is required") unless params.has_key?(:instanceId)
109
+ raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
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 = "/instances/#{params[:instanceId]}/tokens/#{params[:apiTokenId]}"
117
+
118
+ @client.request(
119
+ method: :get,
120
+ path: path,
121
+ query: query_params,
122
+ headers: headers,
123
+ body: body)
124
+ end
125
+
126
+ # Updates information about an API token
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.Instance, all.User, instanceApiToken.*, or instanceApiToken.patch.
133
+ #
134
+ # Parameters:
135
+ # * {string} instanceId - ID associated with the instance
136
+ # * {string} apiTokenId - ID associated with the API token
137
+ # * {hash} apiToken - Object containing new properties of the API token (https://api.losant.com/#/definitions/apiTokenPatch)
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 - Updated API token information (https://api.losant.com/#/definitions/apiToken)
145
+ #
146
+ # Errors:
147
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
148
+ # * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error)
149
+ def patch(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("instanceId is required") unless params.has_key?(:instanceId)
156
+ raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
157
+ raise ArgumentError.new("apiToken is required") unless params.has_key?(:apiToken)
158
+
159
+ body = params[:apiToken] if params.has_key?(:apiToken)
160
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
161
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
162
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
163
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
164
+
165
+ path = "/instances/#{params[:instanceId]}/tokens/#{params[:apiTokenId]}"
166
+
167
+ @client.request(
168
+ method: :patch,
169
+ path: path,
170
+ query: query_params,
171
+ headers: headers,
172
+ body: body)
173
+ end
174
+
175
+ end
176
+ end