losant_rest 1.22.4 → 1.23.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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +1290 -142
  3. data/docs/file.md +3 -3
  4. data/docs/files.md +2 -2
  5. data/docs/privateFile.md +222 -0
  6. data/docs/privateFiles.md +97 -0
  7. data/lib/platform_rest/client.rb +10 -2
  8. data/lib/platform_rest/file.rb +3 -3
  9. data/lib/platform_rest/files.rb +1 -1
  10. data/lib/platform_rest/private_file.rb +230 -0
  11. data/lib/platform_rest/private_files.rb +146 -0
  12. data/lib/platform_rest/version.rb +1 -1
  13. data/lib/platform_rest.rb +2 -0
  14. data/schemas/apiTokenPost.json +12 -2
  15. data/schemas/application.json +7 -0
  16. data/schemas/applicationClonePost.json +4 -0
  17. data/schemas/applicationCreationByTemplateResult.json +7 -0
  18. data/schemas/applicationDashboardPost.json +3 -1
  19. data/schemas/applicationExportPost.json +4 -0
  20. data/schemas/applicationImportExecutions.json +2 -0
  21. data/schemas/applicationPatch.json +4 -0
  22. data/schemas/applicationPost.json +4 -0
  23. data/schemas/applicationTemplate.json +3 -0
  24. data/schemas/applicationTemplates.json +3 -0
  25. data/schemas/applications.json +7 -0
  26. data/schemas/auditLog.json +1 -0
  27. data/schemas/auditLogFilter.json +1 -0
  28. data/schemas/auditLogs.json +1 -0
  29. data/schemas/credentialLinkedResources.json +18 -0
  30. data/schemas/dashboard.json +3 -1
  31. data/schemas/dashboardBlockSuggestCodePost.json +620 -0
  32. data/schemas/dashboardBlockSuggestCodeResponse.json +49 -0
  33. data/schemas/dashboardPatch.json +3 -1
  34. data/schemas/dashboardPost.json +3 -1
  35. data/schemas/dashboards.json +3 -1
  36. data/schemas/experienceLinkedResources.json +18 -0
  37. data/schemas/fileUploadPostResponse.json +103 -82
  38. data/schemas/files.json +1 -1
  39. data/schemas/flow.json +6 -0
  40. data/schemas/flowPatch.json +6 -0
  41. data/schemas/flowPost.json +6 -0
  42. data/schemas/flowVersion.json +12 -0
  43. data/schemas/flowVersionPost.json +6 -0
  44. data/schemas/flowVersions.json +12 -0
  45. data/schemas/flows.json +6 -0
  46. data/schemas/flowsImportPost.json +12 -0
  47. data/schemas/flowsImportResult.json +18 -0
  48. data/schemas/githubLogin.json +12 -2
  49. data/schemas/historicalSummaries.json +10 -0
  50. data/schemas/historicalSummary.json +10 -0
  51. data/schemas/importIntoApplicationOptions.json +1 -0
  52. data/schemas/importNewApplicationOptions.json +1 -0
  53. data/schemas/instance.json +7 -0
  54. data/schemas/instanceOrg.json +7 -0
  55. data/schemas/instanceOrgPatch.json +4 -0
  56. data/schemas/instanceOrgPost.json +4 -0
  57. data/schemas/instanceOrgs.json +7 -0
  58. data/schemas/instancePatch.json +4 -0
  59. data/schemas/instanceSandbox.json +6 -0
  60. data/schemas/instanceSandboxes.json +6 -0
  61. data/schemas/instances.json +7 -0
  62. data/schemas/me.json +6 -0
  63. data/schemas/notebook.json +9 -0
  64. data/schemas/notebookPatch.json +9 -0
  65. data/schemas/notebookPost.json +9 -0
  66. data/schemas/notebooks.json +9 -0
  67. data/schemas/org.json +7 -0
  68. data/schemas/orgs.json +7 -0
  69. data/schemas/samlResponse.json +12 -2
  70. data/schemas/suggestFunctionResponse.json +13 -1
  71. data/schemas/userCredentials.json +12 -2
  72. data/schemas/userPost.json +12 -2
  73. metadata +8 -2
data/docs/file.md CHANGED
@@ -83,7 +83,7 @@ all.Application, all.Application.cli, all.Application.read, all.Organization, al
83
83
 
84
84
  | Code | Type | Description |
85
85
  | ---- | ---- | ----------- |
86
- | 200 | [File Schema](_schemas.md#file-schema) | file information |
86
+ | 200 | [File Schema](_schemas.md#file-schema) | File information |
87
87
 
88
88
  #### Error Responses
89
89
 
@@ -160,14 +160,14 @@ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli,
160
160
  | ---- | ---- | -------- | ----------- | ------- | ------- |
161
161
  | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
162
162
  | fileId | string | Y | ID associated with the file | | 575ec76c7ae143cd83dc4a96 |
163
- | updates | [File Patch](_schemas.md#file-patch) | Y | Reupload a file | | [File Patch Example](_schemas.md#file-patch-example) |
163
+ | updates | [File Patch](_schemas.md#file-patch) | Y | Updated information about the file | | [File Patch Example](_schemas.md#file-patch-example) |
164
164
  | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
165
165
 
166
166
  #### Successful Responses
167
167
 
168
168
  | Code | Type | Description |
169
169
  | ---- | ---- | ----------- |
170
- | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully updated file and returned a post url to respond with |
170
+ | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully updated file and the information needed to upload the file content |
171
171
 
172
172
  #### Error Responses
173
173
 
data/docs/files.md CHANGED
@@ -31,7 +31,7 @@ all.Application, all.Application.cli, all.Application.read, all.Organization, al
31
31
  | Name | Type | Required | Description | Default | Example |
32
32
  | ---- | ---- | -------- | ----------- | ------- | ------- |
33
33
  | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
34
- | sortField | string | N | Field to sort the results by. Accepted values are: lastUpdated, type, name, creationDate | lastUpdated | subject |
34
+ | sortField | string | N | Field to sort the results by. Accepted values are: lastUpdated, type, name, creationDate | lastUpdated | name |
35
35
  | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | asc | asc |
36
36
  | page | string | N | Which page of results to return | 0 | 0 |
37
37
  | perPage | string | N | How many items to return per page | 100 | 10 |
@@ -86,7 +86,7 @@ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli,
86
86
 
87
87
  | Code | Type | Description |
88
88
  | ---- | ---- | ----------- |
89
- | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully created file and returned a post url to respond with |
89
+ | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully created file and the information needed to upload the file content |
90
90
 
91
91
  #### Error Responses
92
92
 
@@ -0,0 +1,222 @@
1
+ # Private File Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Private File resource, including the expected
5
+ parameters and the potential responses.
6
+
7
+ ##### Contents
8
+
9
+ * [Delete](#delete)
10
+ * [Get](#get)
11
+ * [Move](#move)
12
+ * [Patch](#patch)
13
+ * [Upload](#upload)
14
+
15
+ <br/>
16
+
17
+ ## Delete
18
+
19
+ Deletes a private file or directory, if a directory all the contents that directory will also be removed.
20
+
21
+ ```ruby
22
+ result = client.private_file.delete(
23
+ applicationId: my_application_id,
24
+ privateFileId: my_private_file_id)
25
+
26
+ puts result
27
+ ```
28
+
29
+ #### Authentication
30
+ The client must be configured with a valid api access token to call this
31
+ action. The token must include at least one of the following scopes:
32
+ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.delete.
33
+
34
+ #### Available Parameters
35
+
36
+ | Name | Type | Required | Description | Default | Example |
37
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
38
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
39
+ | privateFileId | string | Y | ID associated with the private file | | 575ec76c7ae143cd83dc4a96 |
40
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
41
+
42
+ #### Successful Responses
43
+
44
+ | Code | Type | Description |
45
+ | ---- | ---- | ----------- |
46
+ | 200 | [Success](_schemas.md#success) | If private file was successfully deleted |
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 private file was not found |
54
+
55
+ <br/>
56
+
57
+ ## Get
58
+
59
+ Retrieves information on a private file
60
+
61
+ ```ruby
62
+ result = client.private_file.get(
63
+ applicationId: my_application_id,
64
+ privateFileId: my_private_file_id)
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.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, privateFile.*, or privateFile.get.
73
+
74
+ #### Available Parameters
75
+
76
+ | Name | Type | Required | Description | Default | Example |
77
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
78
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
79
+ | privateFileId | string | Y | ID associated with the private file | | 575ec76c7ae143cd83dc4a96 |
80
+ | urlTTL | string | N | Time in seconds that the private file url will be valid for. Only applies to private files of type &#x27;file&#x27;. If 0, no url will be returned. | 900 | 900 |
81
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
82
+
83
+ #### Successful Responses
84
+
85
+ | Code | Type | Description |
86
+ | ---- | ---- | ----------- |
87
+ | 200 | [File Schema](_schemas.md#file-schema) | Private file information |
88
+
89
+ #### Error Responses
90
+
91
+ | Code | Type | Description |
92
+ | ---- | ---- | ----------- |
93
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
94
+ | 404 | [Error](_schemas.md#error) | Error if private file was not found |
95
+
96
+ <br/>
97
+
98
+ ## Move
99
+
100
+ Move a private file or the entire contents of a directory
101
+
102
+ ```ruby
103
+ result = client.private_file.move(
104
+ applicationId: my_application_id,
105
+ privateFileId: my_private_file_id)
106
+
107
+ puts result
108
+ ```
109
+
110
+ #### Authentication
111
+ The client must be configured with a valid api access token to call this
112
+ action. The token must include at least one of the following scopes:
113
+ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.move.
114
+
115
+ #### Available Parameters
116
+
117
+ | Name | Type | Required | Description | Default | Example |
118
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
119
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
120
+ | privateFileId | string | Y | ID associated with the private file | | 575ec76c7ae143cd83dc4a96 |
121
+ | name | undefined | N | The new name of the private file or directory | | fileA |
122
+ | parentDirectory | undefined | N | The new parent directory for the private file or directory to move into. | | /new/location/here |
123
+ | urlTTL | string | N | Time in seconds that the private file url will be valid for. Only applies to private files of type &#x27;file&#x27;. If 0, no url will be returned. | 900 | 900 |
124
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
125
+
126
+ #### Successful Responses
127
+
128
+ | Code | Type | Description |
129
+ | ---- | ---- | ----------- |
130
+ | 201 | [File Schema](_schemas.md#file-schema) | Returns a new private file or directory that was created by the move, if a directory a job will kick off to move all the directories children. |
131
+
132
+ #### Error Responses
133
+
134
+ | Code | Type | Description |
135
+ | ---- | ---- | ----------- |
136
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
137
+ | 404 | [Error](_schemas.md#error) | Error if private file was not found |
138
+
139
+ <br/>
140
+
141
+ ## Patch
142
+
143
+ Reupload a private file
144
+
145
+ ```ruby
146
+ result = client.private_file.patch(
147
+ applicationId: my_application_id,
148
+ privateFileId: my_private_file_id,
149
+ updates: my_updates)
150
+
151
+ puts result
152
+ ```
153
+
154
+ #### Authentication
155
+ The client must be configured with a valid api access token to call this
156
+ action. The token must include at least one of the following scopes:
157
+ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.patch.
158
+
159
+ #### Available Parameters
160
+
161
+ | Name | Type | Required | Description | Default | Example |
162
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
163
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
164
+ | privateFileId | string | Y | ID associated with the private file | | 575ec76c7ae143cd83dc4a96 |
165
+ | updates | [File Patch](_schemas.md#file-patch) | Y | Updated information about the private file | | [File Patch Example](_schemas.md#file-patch-example) |
166
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
167
+
168
+ #### Successful Responses
169
+
170
+ | Code | Type | Description |
171
+ | ---- | ---- | ----------- |
172
+ | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully updated private file and the information needed to upload the file content |
173
+
174
+ #### Error Responses
175
+
176
+ | Code | Type | Description |
177
+ | ---- | ---- | ----------- |
178
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
179
+ | 404 | [Error](_schemas.md#error) | Error if private file was not found |
180
+
181
+ <br/>
182
+
183
+ ## Upload
184
+
185
+ Uploads the private file
186
+
187
+ ```ruby
188
+ result = client.private_file.upload(
189
+ applicationId: my_application_id,
190
+ privateFileId: my_private_file_id,
191
+ privateFile: my_private_file)
192
+
193
+ puts result
194
+ ```
195
+
196
+ #### Authentication
197
+ The client must be configured with a valid api access token to call this
198
+ action. The token must include at least one of the following scopes:
199
+ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.upload.
200
+
201
+ #### Available Parameters
202
+
203
+ | Name | Type | Required | Description | Default | Example |
204
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
205
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
206
+ | privateFileId | string | Y | ID associated with the private file | | 575ec76c7ae143cd83dc4a96 |
207
+ | privateFile | file | Y | The content of the private file to upload | | undefined |
208
+ | urlTTL | string | N | Time in seconds that the private file url will be valid for. Only applies to private files of type &#x27;file&#x27;. If 0, no url will be returned. | 900 | 900 |
209
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
210
+
211
+ #### Successful Responses
212
+
213
+ | Code | Type | Description |
214
+ | ---- | ---- | ----------- |
215
+ | 200 | [File Schema](_schemas.md#file-schema) | Updated private file content |
216
+
217
+ #### Error Responses
218
+
219
+ | Code | Type | Description |
220
+ | ---- | ---- | ----------- |
221
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
222
+ | 404 | [Error](_schemas.md#error) | Error if file was not found |
@@ -0,0 +1,97 @@
1
+ # Private Files Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Private Files 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 the private files for an application
17
+
18
+ ```ruby
19
+ result = client.private_files.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.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, privateFiles.*, or privateFiles.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: lastUpdated, type, name, creationDate | lastUpdated | name |
35
+ | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | asc | 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 | | name |
39
+ | filter | string | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | | myFile |
40
+ | type | string | N | Limit by the type (file or directory) of the file | | file |
41
+ | status | string | N | Limit the result to only files of this status. Accepted values are: completed, pending | | completed |
42
+ | directory | string | N | Get private files that are inside of this directory | | /a/path/ |
43
+ | urlTTL | string | N | Time in seconds that the private file url will be valid for. Only applies to private files of type &#x27;file&#x27;. If 0, no url will be returned. | 900 | 900 |
44
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
45
+
46
+ #### Successful Responses
47
+
48
+ | Code | Type | Description |
49
+ | ---- | ---- | ----------- |
50
+ | 200 | [Files Schema](_schemas.md#files-schema) | Collection of private files |
51
+
52
+ #### Error Responses
53
+
54
+ | Code | Type | Description |
55
+ | ---- | ---- | ----------- |
56
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
57
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
58
+
59
+ <br/>
60
+
61
+ ## Post
62
+
63
+ Create a new private file for an application
64
+
65
+ ```ruby
66
+ result = client.private_files.post(
67
+ applicationId: my_application_id,
68
+ privateFile: my_private_file)
69
+
70
+ puts result
71
+ ```
72
+
73
+ #### Authentication
74
+ The client must be configured with a valid api access token to call this
75
+ action. The token must include at least one of the following scopes:
76
+ all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFiles.*, or privateFiles.post.
77
+
78
+ #### Available Parameters
79
+
80
+ | Name | Type | Required | Description | Default | Example |
81
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
82
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
83
+ | privateFile | [File Post](_schemas.md#file-post) | Y | New private file information | | [File Post Example](_schemas.md#file-post-example) |
84
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
85
+
86
+ #### Successful Responses
87
+
88
+ | Code | Type | Description |
89
+ | ---- | ---- | ----------- |
90
+ | 201 | [File Upload Post Response](_schemas.md#file-upload-post-response) | Successfully created private file and the information needed to upload the file content |
91
+
92
+ #### Error Responses
93
+
94
+ | Code | Type | Description |
95
+ | ---- | ---- | ----------- |
96
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
97
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
@@ -27,7 +27,7 @@ module PlatformRest
27
27
  #
28
28
  # User API for accessing platform data
29
29
  #
30
- # Built For Version 1.28.4
30
+ # Built For Version 1.29.0
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -392,6 +392,14 @@ module PlatformRest
392
392
  @orgs ||= Orgs.new(self)
393
393
  end
394
394
 
395
+ def private_file
396
+ @private_file ||= PrivateFile.new(self)
397
+ end
398
+
399
+ def private_files
400
+ @private_files ||= PrivateFiles.new(self)
401
+ end
402
+
395
403
  def resource_job
396
404
  @resource_job ||= ResourceJob.new(self)
397
405
  end
@@ -422,7 +430,7 @@ module PlatformRest
422
430
 
423
431
  headers["Accept"] = "application/json"
424
432
  headers["Content-Type"] = "application/json"
425
- headers["Accept-Version"] = "^1.28.4"
433
+ headers["Accept-Version"] = "^1.29.0"
426
434
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
427
435
  path = self.url + options.fetch(:path, "")
428
436
 
@@ -94,7 +94,7 @@ module PlatformRest
94
94
  # * {boolean} _embedded - Return embedded resources in response
95
95
  #
96
96
  # Responses:
97
- # * 200 - file information (https://api.losant.com/#/definitions/file)
97
+ # * 200 - File information (https://api.losant.com/#/definitions/file)
98
98
  #
99
99
  # Errors:
100
100
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -184,14 +184,14 @@ module PlatformRest
184
184
  # Parameters:
185
185
  # * {string} applicationId - ID associated with the application
186
186
  # * {string} fileId - ID associated with the file
187
- # * {hash} updates - Reupload a file (https://api.losant.com/#/definitions/filePatch)
187
+ # * {hash} updates - Updated information about the file (https://api.losant.com/#/definitions/filePatch)
188
188
  # * {string} losantdomain - Domain scope of request (rarely needed)
189
189
  # * {boolean} _actions - Return resource actions in response
190
190
  # * {boolean} _links - Return resource link in response
191
191
  # * {boolean} _embedded - Return embedded resources in response
192
192
  #
193
193
  # Responses:
194
- # * 201 - Successfully updated file and returned a post url to respond with (https://api.losant.com/#/definitions/fileUploadPostResponse)
194
+ # * 201 - Successfully updated file and the information needed to upload the file content (https://api.losant.com/#/definitions/fileUploadPostResponse)
195
195
  #
196
196
  # Errors:
197
197
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -110,7 +110,7 @@ module PlatformRest
110
110
  # * {boolean} _embedded - Return embedded resources in response
111
111
  #
112
112
  # Responses:
113
- # * 201 - Successfully created file and returned a post url to respond with (https://api.losant.com/#/definitions/fileUploadPostResponse)
113
+ # * 201 - Successfully created file and the information needed to upload the file content (https://api.losant.com/#/definitions/fileUploadPostResponse)
114
114
  #
115
115
  # Errors:
116
116
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -0,0 +1,230 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2024 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 PlatformRest
26
+
27
+ # Class containing all the actions for the Private File Resource
28
+ class PrivateFile
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Deletes a private file or directory, if a directory all the contents that directory will also be removed.
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.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} privateFileId - ID associated with the private file
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 private file 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 private file 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("privateFileId is required") unless params.has_key?(:privateFileId)
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]}/privateFiles/#{params[:privateFileId]}"
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 private file
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.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, privateFile.*, or privateFile.get.
87
+ #
88
+ # Parameters:
89
+ # * {string} applicationId - ID associated with the application
90
+ # * {string} privateFileId - ID associated with the private file
91
+ # * {string} urlTTL - Time in seconds that the private file url will be valid for. Only applies to private files of type 'file'. If 0, no url will be returned.
92
+ # * {string} losantdomain - Domain scope of request (rarely needed)
93
+ # * {boolean} _actions - Return resource actions in response
94
+ # * {boolean} _links - Return resource link in response
95
+ # * {boolean} _embedded - Return embedded resources in response
96
+ #
97
+ # Responses:
98
+ # * 200 - Private file information (https://api.losant.com/#/definitions/file)
99
+ #
100
+ # Errors:
101
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
102
+ # * 404 - Error if private file was not found (https://api.losant.com/#/definitions/error)
103
+ def get(params = {})
104
+ params = Utils.symbolize_hash_keys(params)
105
+ query_params = { _actions: false, _links: true, _embedded: true }
106
+ headers = {}
107
+ body = nil
108
+
109
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
110
+ raise ArgumentError.new("privateFileId is required") unless params.has_key?(:privateFileId)
111
+
112
+ query_params[:urlTTL] = params[:urlTTL] if params.has_key?(:urlTTL)
113
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
114
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
115
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
116
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
117
+
118
+ path = "/applications/#{params[:applicationId]}/privateFiles/#{params[:privateFileId]}"
119
+
120
+ @client.request(
121
+ method: :get,
122
+ path: path,
123
+ query: query_params,
124
+ headers: headers,
125
+ body: body)
126
+ end
127
+
128
+ # Move a private file or the entire contents of a directory
129
+ #
130
+ # Authentication:
131
+ # The client must be configured with a valid api
132
+ # access token to call this action. The token
133
+ # must include at least one of the following scopes:
134
+ # all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.move.
135
+ #
136
+ # Parameters:
137
+ # * {string} applicationId - ID associated with the application
138
+ # * {string} privateFileId - ID associated with the private file
139
+ # * {undefined} name - The new name of the private file or directory
140
+ # * {undefined} parentDirectory - The new parent directory for the private file or directory to move into.
141
+ # * {string} urlTTL - Time in seconds that the private file url will be valid for. Only applies to private files of type 'file'. If 0, no url will be returned.
142
+ # * {string} losantdomain - Domain scope of request (rarely needed)
143
+ # * {boolean} _actions - Return resource actions in response
144
+ # * {boolean} _links - Return resource link in response
145
+ # * {boolean} _embedded - Return embedded resources in response
146
+ #
147
+ # Responses:
148
+ # * 201 - Returns a new private file or directory that was created by the move, if a directory a job will kick off to move all the directories children. (https://api.losant.com/#/definitions/file)
149
+ #
150
+ # Errors:
151
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
152
+ # * 404 - Error if private file was not found (https://api.losant.com/#/definitions/error)
153
+ def move(params = {})
154
+ params = Utils.symbolize_hash_keys(params)
155
+ query_params = { _actions: false, _links: true, _embedded: true }
156
+ headers = {}
157
+ body = nil
158
+
159
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
160
+ raise ArgumentError.new("privateFileId is required") unless params.has_key?(:privateFileId)
161
+
162
+ query_params[:name] = params[:name] if params.has_key?(:name)
163
+ query_params[:parentDirectory] = params[:parentDirectory] if params.has_key?(:parentDirectory)
164
+ query_params[:urlTTL] = params[:urlTTL] if params.has_key?(:urlTTL)
165
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
166
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
167
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
168
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
169
+
170
+ path = "/applications/#{params[:applicationId]}/privateFiles/#{params[:privateFileId]}/move"
171
+
172
+ @client.request(
173
+ method: :post,
174
+ path: path,
175
+ query: query_params,
176
+ headers: headers,
177
+ body: body)
178
+ end
179
+
180
+ # Reupload a private file
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.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.patch.
187
+ #
188
+ # Parameters:
189
+ # * {string} applicationId - ID associated with the application
190
+ # * {string} privateFileId - ID associated with the private file
191
+ # * {hash} updates - Updated information about the private file (https://api.losant.com/#/definitions/filePatch)
192
+ # * {string} losantdomain - Domain scope of request (rarely needed)
193
+ # * {boolean} _actions - Return resource actions in response
194
+ # * {boolean} _links - Return resource link in response
195
+ # * {boolean} _embedded - Return embedded resources in response
196
+ #
197
+ # Responses:
198
+ # * 201 - Successfully updated private file and the information needed to upload the file content (https://api.losant.com/#/definitions/fileUploadPostResponse)
199
+ #
200
+ # Errors:
201
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
202
+ # * 404 - Error if private file was not found (https://api.losant.com/#/definitions/error)
203
+ def patch(params = {})
204
+ params = Utils.symbolize_hash_keys(params)
205
+ query_params = { _actions: false, _links: true, _embedded: true }
206
+ headers = {}
207
+ body = nil
208
+
209
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
210
+ raise ArgumentError.new("privateFileId is required") unless params.has_key?(:privateFileId)
211
+ raise ArgumentError.new("updates is required") unless params.has_key?(:updates)
212
+
213
+ body = params[:updates] if params.has_key?(:updates)
214
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
215
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
216
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
217
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
218
+
219
+ path = "/applications/#{params[:applicationId]}/privateFiles/#{params[:privateFileId]}"
220
+
221
+ @client.request(
222
+ method: :patch,
223
+ path: path,
224
+ query: query_params,
225
+ headers: headers,
226
+ body: body)
227
+ end
228
+
229
+ end
230
+ end