losant_rest 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/_schemas.md +640 -7
- data/docs/file.md +172 -0
- data/docs/files.md +94 -0
- data/lib/losant_rest.rb +2 -0
- data/lib/losant_rest/client.rb +10 -2
- data/lib/losant_rest/file.rb +224 -0
- data/lib/losant_rest/files.rb +142 -0
- data/lib/losant_rest/version.rb +1 -1
- data/schemas/applicationApiTokenPost.json +8 -0
- data/schemas/changePassword.json +2 -1
- data/schemas/dataTableRowsExport.json +85 -1
- data/schemas/file.json +78 -0
- data/schemas/filePatch.json +24 -0
- data/schemas/filePost.json +40 -0
- data/schemas/fileUploadPostResp.json +109 -0
- data/schemas/files.json +116 -0
- data/schemas/mePatch.json +2 -1
- data/schemas/solutionUserPatch.json +2 -1
- data/schemas/solutionUserPost.json +2 -1
- data/schemas/timeSeriesData.json +2 -1
- data/schemas/timeSeriesQuery.json +2 -1
- metadata +11 -2
data/docs/file.md
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# File Actions
|
2
|
+
|
3
|
+
Details on the various actions that can be performed on the
|
4
|
+
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
|
+
|
14
|
+
<br/>
|
15
|
+
|
16
|
+
## Delete
|
17
|
+
|
18
|
+
Deletes a file or directory, if directory all the contents that directory will also be removed.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
result = client.file.delete(
|
22
|
+
applicationId: my_application_id,
|
23
|
+
fileId: my_file_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, file.*, or file.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
|
+
| fileId | string | Y | ID associated with the file | | 575ec76c7ae143cd83dc4a96 |
|
39
|
+
|
40
|
+
#### Successful Responses
|
41
|
+
|
42
|
+
| Code | Type | Description |
|
43
|
+
| ---- | ---- | ----------- |
|
44
|
+
| 200 | [Success](_schemas.md#success) | If file was successfully deleted |
|
45
|
+
|
46
|
+
#### Error Responses
|
47
|
+
|
48
|
+
| Code | Type | Description |
|
49
|
+
| ---- | ---- | ----------- |
|
50
|
+
| 400 | [Error](_schemas.md#error) | Error if malformed request |
|
51
|
+
| 404 | [Error](_schemas.md#error) | Error if event was not found |
|
52
|
+
|
53
|
+
<br/>
|
54
|
+
|
55
|
+
## Get
|
56
|
+
|
57
|
+
Retrieves information on a file
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
result = client.file.get(
|
61
|
+
applicationId: my_application_id,
|
62
|
+
fileId: my_file_id)
|
63
|
+
|
64
|
+
puts result
|
65
|
+
```
|
66
|
+
|
67
|
+
#### Authentication
|
68
|
+
The client must be configured with a valid api access token to call this
|
69
|
+
action. The token must include at least one of the following scopes:
|
70
|
+
all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, file.*, or file.get.
|
71
|
+
|
72
|
+
#### Available Parameters
|
73
|
+
|
74
|
+
| Name | Type | Required | Description | Default | Example |
|
75
|
+
| ---- | ---- | -------- | ----------- | ------- | ------- |
|
76
|
+
| applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
|
77
|
+
| fileId | string | Y | ID associated with the file | | 575ec76c7ae143cd83dc4a96 |
|
78
|
+
|
79
|
+
#### Successful Responses
|
80
|
+
|
81
|
+
| Code | Type | Description |
|
82
|
+
| ---- | ---- | ----------- |
|
83
|
+
| 200 | [File Schema](_schemas.md#file-schema) | file information |
|
84
|
+
|
85
|
+
#### Error Responses
|
86
|
+
|
87
|
+
| Code | Type | Description |
|
88
|
+
| ---- | ---- | ----------- |
|
89
|
+
| 400 | [Error](_schemas.md#error) | Error if malformed request |
|
90
|
+
| 404 | [Error](_schemas.md#error) | Error if file was not found |
|
91
|
+
|
92
|
+
<br/>
|
93
|
+
|
94
|
+
## Move
|
95
|
+
|
96
|
+
Move a file or the entire contents of a directory
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
result = client.file.move(
|
100
|
+
applicationId: my_application_id,
|
101
|
+
fileId: my_file_id)
|
102
|
+
|
103
|
+
puts result
|
104
|
+
```
|
105
|
+
|
106
|
+
#### Authentication
|
107
|
+
The client must be configured with a valid api access token to call this
|
108
|
+
action. The token must include at least one of the following scopes:
|
109
|
+
all.Application, all.Organization, all.User, file.*, or file.move.
|
110
|
+
|
111
|
+
#### Available Parameters
|
112
|
+
|
113
|
+
| Name | Type | Required | Description | Default | Example |
|
114
|
+
| ---- | ---- | -------- | ----------- | ------- | ------- |
|
115
|
+
| applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
|
116
|
+
| fileId | string | Y | ID associated with the file | | 575ec76c7ae143cd83dc4a96 |
|
117
|
+
| name | undefined | N | The new name of the file or directory | | fileA |
|
118
|
+
| parentDirectory | undefined | N | The new parent directory for the file or directory to move into. | | /new/location/here |
|
119
|
+
|
120
|
+
#### Successful Responses
|
121
|
+
|
122
|
+
| Code | Type | Description |
|
123
|
+
| ---- | ---- | ----------- |
|
124
|
+
| 201 | [File Schema](_schemas.md#file-schema) | Returns a new file or directory that was created by the move, if a directory a job will kick off to move all the directories children. |
|
125
|
+
|
126
|
+
#### Error Responses
|
127
|
+
|
128
|
+
| Code | Type | Description |
|
129
|
+
| ---- | ---- | ----------- |
|
130
|
+
| 400 | [Error](_schemas.md#error) | Error if malformed request |
|
131
|
+
| 404 | [Error](_schemas.md#error) | Error if application was not found |
|
132
|
+
|
133
|
+
<br/>
|
134
|
+
|
135
|
+
## Patch
|
136
|
+
|
137
|
+
Reupload a file
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
result = client.file.patch(
|
141
|
+
applicationId: my_application_id,
|
142
|
+
fileId: my_file_id,
|
143
|
+
updates: my_updates)
|
144
|
+
|
145
|
+
puts result
|
146
|
+
```
|
147
|
+
|
148
|
+
#### Authentication
|
149
|
+
The client must be configured with a valid api access token to call this
|
150
|
+
action. The token must include at least one of the following scopes:
|
151
|
+
all.Application, all.Organization, all.User, file.*, or file.patch.
|
152
|
+
|
153
|
+
#### Available Parameters
|
154
|
+
|
155
|
+
| Name | Type | Required | Description | Default | Example |
|
156
|
+
| ---- | ---- | -------- | ----------- | ------- | ------- |
|
157
|
+
| applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
|
158
|
+
| fileId | string | Y | ID associated with the file | | 575ec76c7ae143cd83dc4a96 |
|
159
|
+
| updates | [File Patch](_schemas.md#file-patch) | Y | Reupload a file | | [File Patch Example](_schemas.md#file-patch-example) |
|
160
|
+
|
161
|
+
#### Successful Responses
|
162
|
+
|
163
|
+
| Code | Type | Description |
|
164
|
+
| ---- | ---- | ----------- |
|
165
|
+
| 201 | [File Post Response](_schemas.md#file-post-response) | Successfully updated file and returned a post url to respond with |
|
166
|
+
|
167
|
+
#### Error Responses
|
168
|
+
|
169
|
+
| Code | Type | Description |
|
170
|
+
| ---- | ---- | ----------- |
|
171
|
+
| 400 | [Error](_schemas.md#error) | Error if malformed request |
|
172
|
+
| 404 | [Error](_schemas.md#error) | Error if application was not found |
|
data/docs/files.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Files Actions
|
2
|
+
|
3
|
+
Details on the various actions that can be performed on the
|
4
|
+
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 files for an application
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
result = client.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.read, all.Organization, all.Organization.read, all.User, all.User.read, files.*, or files.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 | subject |
|
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 | 1000 | 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 files that are inside of this directory | / | /a/path/ |
|
43
|
+
|
44
|
+
#### Successful Responses
|
45
|
+
|
46
|
+
| Code | Type | Description |
|
47
|
+
| ---- | ---- | ----------- |
|
48
|
+
| 200 | [Files Schema](_schemas.md#files-schema) | Collection of files |
|
49
|
+
|
50
|
+
#### Error Responses
|
51
|
+
|
52
|
+
| Code | Type | Description |
|
53
|
+
| ---- | ---- | ----------- |
|
54
|
+
| 400 | [Error](_schemas.md#error) | Error if malformed request |
|
55
|
+
| 404 | [Error](_schemas.md#error) | Error if application was not found |
|
56
|
+
|
57
|
+
<br/>
|
58
|
+
|
59
|
+
## Post
|
60
|
+
|
61
|
+
Create a new file for an application
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
result = client.files.post(
|
65
|
+
applicationId: my_application_id,
|
66
|
+
file: my_file)
|
67
|
+
|
68
|
+
puts result
|
69
|
+
```
|
70
|
+
|
71
|
+
#### Authentication
|
72
|
+
The client must be configured with a valid api access token to call this
|
73
|
+
action. The token must include at least one of the following scopes:
|
74
|
+
all.Application, all.Organization, all.User, files.*, or files.post.
|
75
|
+
|
76
|
+
#### Available Parameters
|
77
|
+
|
78
|
+
| Name | Type | Required | Description | Default | Example |
|
79
|
+
| ---- | ---- | -------- | ----------- | ------- | ------- |
|
80
|
+
| applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
|
81
|
+
| file | [File Post](_schemas.md#file-post) | Y | New file information | | [File Post Example](_schemas.md#file-post-example) |
|
82
|
+
|
83
|
+
#### Successful Responses
|
84
|
+
|
85
|
+
| Code | Type | Description |
|
86
|
+
| ---- | ---- | ----------- |
|
87
|
+
| 201 | [File Post Response](_schemas.md#file-post-response) | Successfully created file and returned a post url to respond with |
|
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 application was not found |
|
data/lib/losant_rest.rb
CHANGED
@@ -56,6 +56,8 @@ require_relative "losant_rest/experience_user"
|
|
56
56
|
require_relative "losant_rest/experience_users"
|
57
57
|
require_relative "losant_rest/experience_view"
|
58
58
|
require_relative "losant_rest/experience_views"
|
59
|
+
require_relative "losant_rest/file"
|
60
|
+
require_relative "losant_rest/files"
|
59
61
|
require_relative "losant_rest/flow"
|
60
62
|
require_relative "losant_rest/flow_version"
|
61
63
|
require_relative "losant_rest/flow_versions"
|
data/lib/losant_rest/client.rb
CHANGED
@@ -27,7 +27,7 @@ module LosantRest
|
|
27
27
|
#
|
28
28
|
# User API for accessing Losant data
|
29
29
|
#
|
30
|
-
# Built For Version 1.10.
|
30
|
+
# Built For Version 1.10.2
|
31
31
|
class Client
|
32
32
|
attr_accessor :auth_token, :url
|
33
33
|
|
@@ -168,6 +168,14 @@ module LosantRest
|
|
168
168
|
@experience_views ||= ExperienceViews.new(self)
|
169
169
|
end
|
170
170
|
|
171
|
+
def file
|
172
|
+
@file ||= File.new(self)
|
173
|
+
end
|
174
|
+
|
175
|
+
def files
|
176
|
+
@files ||= Files.new(self)
|
177
|
+
end
|
178
|
+
|
171
179
|
def flow
|
172
180
|
@flow ||= Flow.new(self)
|
173
181
|
end
|
@@ -238,7 +246,7 @@ module LosantRest
|
|
238
246
|
|
239
247
|
headers["Accept"] = "application/json"
|
240
248
|
headers["Content-Type"] = "application/json"
|
241
|
-
headers["Accept-Version"] = "^1.10.
|
249
|
+
headers["Accept-Version"] = "^1.10.2"
|
242
250
|
headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
|
243
251
|
path = self.url + options.fetch(:path, "")
|
244
252
|
|
@@ -0,0 +1,224 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2018 Losant IoT, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
module LosantRest
|
24
|
+
|
25
|
+
# Class containing all the actions for the File Resource
|
26
|
+
class File
|
27
|
+
|
28
|
+
def initialize(client)
|
29
|
+
@client = client
|
30
|
+
end
|
31
|
+
|
32
|
+
# Deletes a file or directory, if directory all the contents that directory will also be removed.
|
33
|
+
#
|
34
|
+
# Authentication:
|
35
|
+
# The client must be configured with a valid api
|
36
|
+
# access token to call this action. The token
|
37
|
+
# must include at least one of the following scopes:
|
38
|
+
# all.Application, all.Organization, all.User, file.*, or file.delete.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} applicationId - ID associated with the application
|
42
|
+
# * {string} fileId - ID associated with the file
|
43
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
44
|
+
# * {boolean} _actions - Return resource actions in response
|
45
|
+
# * {boolean} _links - Return resource link in response
|
46
|
+
# * {boolean} _embedded - Return embedded resources in response
|
47
|
+
#
|
48
|
+
# Responses:
|
49
|
+
# * 200 - If file was successfully deleted (https://api.losant.com/#/definitions/success)
|
50
|
+
#
|
51
|
+
# Errors:
|
52
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
53
|
+
# * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
|
54
|
+
def delete(params = {})
|
55
|
+
params = Utils.symbolize_hash_keys(params)
|
56
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
57
|
+
headers = {}
|
58
|
+
body = nil
|
59
|
+
|
60
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
61
|
+
raise ArgumentError.new("fileId is required") unless params.has_key?(:fileId)
|
62
|
+
|
63
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
64
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
65
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
66
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
67
|
+
|
68
|
+
path = "/applications/#{params[:applicationId]}/file/#{params[:fileId]}"
|
69
|
+
|
70
|
+
@client.request(
|
71
|
+
method: :delete,
|
72
|
+
path: path,
|
73
|
+
query: query_params,
|
74
|
+
headers: headers,
|
75
|
+
body: body)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Retrieves information on a file
|
79
|
+
#
|
80
|
+
# Authentication:
|
81
|
+
# The client must be configured with a valid api
|
82
|
+
# access token to call this action. The token
|
83
|
+
# must include at least one of the following scopes:
|
84
|
+
# all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, file.*, or file.get.
|
85
|
+
#
|
86
|
+
# Parameters:
|
87
|
+
# * {string} applicationId - ID associated with the application
|
88
|
+
# * {string} fileId - ID associated with the file
|
89
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
90
|
+
# * {boolean} _actions - Return resource actions in response
|
91
|
+
# * {boolean} _links - Return resource link in response
|
92
|
+
# * {boolean} _embedded - Return embedded resources in response
|
93
|
+
#
|
94
|
+
# Responses:
|
95
|
+
# * 200 - file information (https://api.losant.com/#/definitions/file)
|
96
|
+
#
|
97
|
+
# Errors:
|
98
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
99
|
+
# * 404 - Error if file was not found (https://api.losant.com/#/definitions/error)
|
100
|
+
def get(params = {})
|
101
|
+
params = Utils.symbolize_hash_keys(params)
|
102
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
103
|
+
headers = {}
|
104
|
+
body = nil
|
105
|
+
|
106
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
107
|
+
raise ArgumentError.new("fileId is required") unless params.has_key?(:fileId)
|
108
|
+
|
109
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
110
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
111
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
112
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
113
|
+
|
114
|
+
path = "/applications/#{params[:applicationId]}/file/#{params[:fileId]}"
|
115
|
+
|
116
|
+
@client.request(
|
117
|
+
method: :get,
|
118
|
+
path: path,
|
119
|
+
query: query_params,
|
120
|
+
headers: headers,
|
121
|
+
body: body)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Move a file or the entire contents of a directory
|
125
|
+
#
|
126
|
+
# Authentication:
|
127
|
+
# The client must be configured with a valid api
|
128
|
+
# access token to call this action. The token
|
129
|
+
# must include at least one of the following scopes:
|
130
|
+
# all.Application, all.Organization, all.User, file.*, or file.move.
|
131
|
+
#
|
132
|
+
# Parameters:
|
133
|
+
# * {string} applicationId - ID associated with the application
|
134
|
+
# * {string} fileId - ID associated with the file
|
135
|
+
# * {undefined} name - The new name of the file or directory
|
136
|
+
# * {undefined} parentDirectory - The new parent directory for the file or directory to move into.
|
137
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
138
|
+
# * {boolean} _actions - Return resource actions in response
|
139
|
+
# * {boolean} _links - Return resource link in response
|
140
|
+
# * {boolean} _embedded - Return embedded resources in response
|
141
|
+
#
|
142
|
+
# Responses:
|
143
|
+
# * 201 - Returns a new 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)
|
144
|
+
#
|
145
|
+
# Errors:
|
146
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
147
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
148
|
+
def move(params = {})
|
149
|
+
params = Utils.symbolize_hash_keys(params)
|
150
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
151
|
+
headers = {}
|
152
|
+
body = nil
|
153
|
+
|
154
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
155
|
+
raise ArgumentError.new("fileId is required") unless params.has_key?(:fileId)
|
156
|
+
|
157
|
+
query_params[:name] = params[:name] if params.has_key?(:name)
|
158
|
+
query_params[:parentDirectory] = params[:parentDirectory] if params.has_key?(:parentDirectory)
|
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]}/file/#{params[:fileId]}/move"
|
165
|
+
|
166
|
+
@client.request(
|
167
|
+
method: :post,
|
168
|
+
path: path,
|
169
|
+
query: query_params,
|
170
|
+
headers: headers,
|
171
|
+
body: body)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Reupload a file
|
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, file.*, or file.patch.
|
181
|
+
#
|
182
|
+
# Parameters:
|
183
|
+
# * {string} applicationId - ID associated with the application
|
184
|
+
# * {string} fileId - ID associated with the file
|
185
|
+
# * {hash} updates - Reupload a file (https://api.losant.com/#/definitions/filePatch)
|
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
|
+
# * 201 - Successfully updated file and returned a post url to respond with (https://api.losant.com/#/definitions/fileUploadPostResp)
|
193
|
+
#
|
194
|
+
# Errors:
|
195
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
196
|
+
# * 404 - Error if application 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("fileId is required") unless params.has_key?(:fileId)
|
205
|
+
raise ArgumentError.new("updates is required") unless params.has_key?(:updates)
|
206
|
+
|
207
|
+
body = params[:updates] if params.has_key?(:updates)
|
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]}/file/#{params[:fileId]}"
|
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
|