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.
- checksums.yaml +4 -4
- data/docs/_schemas.md +2317 -650
- data/docs/application.md +5 -5
- data/docs/applicationApiTokens.md +1 -1
- data/docs/applications.md +1 -1
- data/docs/dataTable.md +1 -1
- data/docs/dataTableRows.md +1 -1
- data/docs/dataTables.md +1 -1
- data/docs/devices.md +2 -2
- data/docs/experience.md +1 -1
- data/docs/experienceDomains.md +1 -1
- data/docs/experienceGroup.md +2 -0
- data/docs/experienceSlugs.md +1 -1
- data/docs/experienceVersion.md +3 -3
- data/docs/experienceVersions.md +2 -2
- data/docs/experienceView.md +4 -4
- data/docs/experienceViews.md +2 -2
- data/docs/file.md +5 -5
- data/docs/files.md +2 -2
- data/docs/flowVersions.md +44 -0
- data/docs/instance.md +38 -0
- data/docs/instanceApiToken.md +133 -0
- data/docs/instanceApiTokens.md +91 -0
- data/docs/instanceMembers.md +1 -1
- data/docs/instanceOrgMembers.md +1 -1
- data/docs/userApiToken.md +125 -0
- data/docs/userApiTokens.md +87 -0
- data/lib/losant_rest.rb +4 -0
- data/lib/losant_rest/application.rb +5 -5
- data/lib/losant_rest/application_api_tokens.rb +1 -1
- data/lib/losant_rest/applications.rb +1 -1
- data/lib/losant_rest/client.rb +18 -2
- data/lib/losant_rest/data_table.rb +1 -1
- data/lib/losant_rest/data_table_rows.rb +1 -1
- data/lib/losant_rest/data_tables.rb +1 -1
- data/lib/losant_rest/devices.rb +2 -2
- data/lib/losant_rest/experience.rb +1 -1
- data/lib/losant_rest/experience_domains.rb +1 -1
- data/lib/losant_rest/experience_group.rb +4 -0
- data/lib/losant_rest/experience_slugs.rb +1 -1
- data/lib/losant_rest/experience_version.rb +3 -3
- data/lib/losant_rest/experience_versions.rb +2 -2
- data/lib/losant_rest/experience_view.rb +4 -4
- data/lib/losant_rest/experience_views.rb +2 -2
- data/lib/losant_rest/file.rb +4 -4
- data/lib/losant_rest/files.rb +2 -2
- data/lib/losant_rest/flow_versions.rb +50 -0
- data/lib/losant_rest/instance.rb +46 -1
- data/lib/losant_rest/instance_api_token.rb +176 -0
- data/lib/losant_rest/instance_api_tokens.rb +136 -0
- data/lib/losant_rest/instance_member.rb +1 -1
- data/lib/losant_rest/instance_members.rb +2 -2
- data/lib/losant_rest/instance_org.rb +1 -1
- data/lib/losant_rest/instance_org_member.rb +1 -1
- data/lib/losant_rest/instance_org_members.rb +2 -2
- data/lib/losant_rest/instance_orgs.rb +1 -1
- data/lib/losant_rest/instances.rb +1 -1
- data/lib/losant_rest/user_api_token.rb +170 -0
- data/lib/losant_rest/user_api_tokens.rb +132 -0
- data/lib/losant_rest/version.rb +1 -1
- data/schemas/apiToken.json +2 -1
- data/schemas/apiTokenPost.json +420 -0
- data/schemas/apiTokens.json +4 -2
- data/schemas/applicationDashboardPost.json +20 -16
- data/schemas/auditLog.json +4 -0
- data/schemas/auditLogFilter.json +4 -0
- data/schemas/auditLogs.json +4 -0
- data/schemas/bulkDeleteResponse.json +12 -0
- data/schemas/dashboard.json +20 -16
- data/schemas/dashboardPatch.json +20 -16
- data/schemas/dashboardPost.json +20 -16
- data/schemas/dashboardSendReport.json +4 -0
- data/schemas/dashboards.json +20 -16
- data/schemas/experienceGroup.json +6 -0
- data/schemas/experienceGroups.json +6 -0
- data/schemas/flowVersionsDeletePost.json +941 -0
- data/schemas/githubLogin.json +19 -1
- data/schemas/historicalSummary.json +3 -0
- data/schemas/instance.json +60 -0
- data/schemas/instanceOrgPost.json +166 -0
- data/schemas/instancePatch.json +67 -0
- data/schemas/instanceReportOptionsPost.json +1 -0
- data/schemas/notebook.json +15 -0
- data/schemas/notebooks.json +15 -0
- data/schemas/userCredentials.json +19 -1
- data/schemas/userPost.json +19 -1
- data/schemas/validateContextError.json +34 -0
- data/schemas/validateContextSuccess.json +34 -0
- metadata +15 -3
@@ -0,0 +1,136 @@
|
|
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 Tokens Resource
|
28
|
+
class InstanceApiTokens
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the API tokens for an instance
|
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.Instance.read, all.User, all.User.read, instanceApiTokens.*, or instanceApiTokens.get.
|
41
|
+
#
|
42
|
+
# Parameters:
|
43
|
+
# * {string} instanceId - ID associated with the instance
|
44
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated, expirationDate
|
45
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
46
|
+
# * {string} page - Which page of results to return
|
47
|
+
# * {string} perPage - How many items to return per page
|
48
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, status
|
49
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
50
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
51
|
+
# * {boolean} _actions - Return resource actions in response
|
52
|
+
# * {boolean} _links - Return resource link in response
|
53
|
+
# * {boolean} _embedded - Return embedded resources in response
|
54
|
+
#
|
55
|
+
# Responses:
|
56
|
+
# * 200 - Collection of API tokens (https://api.losant.com/#/definitions/apiToken)
|
57
|
+
#
|
58
|
+
# Errors:
|
59
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
60
|
+
def get(params = {})
|
61
|
+
params = Utils.symbolize_hash_keys(params)
|
62
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
63
|
+
headers = {}
|
64
|
+
body = nil
|
65
|
+
|
66
|
+
raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
|
67
|
+
|
68
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
69
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
70
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
71
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
72
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
73
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
74
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
75
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
76
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
77
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
78
|
+
|
79
|
+
path = "/instances/#{params[:instanceId]}/tokens"
|
80
|
+
|
81
|
+
@client.request(
|
82
|
+
method: :get,
|
83
|
+
path: path,
|
84
|
+
query: query_params,
|
85
|
+
headers: headers,
|
86
|
+
body: body)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Create a new API token for an instance
|
90
|
+
#
|
91
|
+
# Authentication:
|
92
|
+
# The client must be configured with a valid api
|
93
|
+
# access token to call this action. The token
|
94
|
+
# must include at least one of the following scopes:
|
95
|
+
# all.Instance, all.User, instanceApiTokens.*, or instanceApiTokens.post.
|
96
|
+
#
|
97
|
+
# Parameters:
|
98
|
+
# * {string} instanceId - ID associated with the instance
|
99
|
+
# * {hash} apiToken - API token information (https://api.losant.com/#/definitions/apiTokenPost)
|
100
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
101
|
+
# * {boolean} _actions - Return resource actions in response
|
102
|
+
# * {boolean} _links - Return resource link in response
|
103
|
+
# * {boolean} _embedded - Return embedded resources in response
|
104
|
+
#
|
105
|
+
# Responses:
|
106
|
+
# * 201 - The successfully created API token (https://api.losant.com/#/definitions/apiToken)
|
107
|
+
#
|
108
|
+
# Errors:
|
109
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
110
|
+
def post(params = {})
|
111
|
+
params = Utils.symbolize_hash_keys(params)
|
112
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
113
|
+
headers = {}
|
114
|
+
body = nil
|
115
|
+
|
116
|
+
raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
|
117
|
+
raise ArgumentError.new("apiToken is required") unless params.has_key?(:apiToken)
|
118
|
+
|
119
|
+
body = params[:apiToken] if params.has_key?(:apiToken)
|
120
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
121
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
122
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
123
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
124
|
+
|
125
|
+
path = "/instances/#{params[:instanceId]}/tokens"
|
126
|
+
|
127
|
+
@client.request(
|
128
|
+
method: :post,
|
129
|
+
path: path,
|
130
|
+
query: query_params,
|
131
|
+
headers: headers,
|
132
|
+
body: body)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -31,7 +31,7 @@ module LosantRest
|
|
31
31
|
@client = client
|
32
32
|
end
|
33
33
|
|
34
|
-
# Returns
|
34
|
+
# Returns a collection of instance members
|
35
35
|
#
|
36
36
|
# Authentication:
|
37
37
|
# The client must be configured with a valid api
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -31,7 +31,7 @@ module LosantRest
|
|
31
31
|
@client = client
|
32
32
|
end
|
33
33
|
|
34
|
-
# Returns
|
34
|
+
# Returns a collection of instance organization members
|
35
35
|
#
|
36
36
|
# Authentication:
|
37
37
|
# The client must be configured with a valid api
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c)
|
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
|
@@ -0,0 +1,170 @@
|
|
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 User Api Token Resource
|
28
|
+
class UserApiToken
|
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.User, userApiToken.*, or userApiToken.delete.
|
41
|
+
#
|
42
|
+
# Parameters:
|
43
|
+
# * {string} apiTokenId - ID associated with the API token
|
44
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
45
|
+
# * {boolean} _actions - Return resource actions in response
|
46
|
+
# * {boolean} _links - Return resource link in response
|
47
|
+
# * {boolean} _embedded - Return embedded resources in response
|
48
|
+
#
|
49
|
+
# Responses:
|
50
|
+
# * 200 - If API token was successfully deleted (https://api.losant.com/#/definitions/success)
|
51
|
+
#
|
52
|
+
# Errors:
|
53
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
54
|
+
# * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error)
|
55
|
+
def delete(params = {})
|
56
|
+
params = Utils.symbolize_hash_keys(params)
|
57
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
58
|
+
headers = {}
|
59
|
+
body = nil
|
60
|
+
|
61
|
+
raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
|
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 = "/me/tokens/#{params[:apiTokenId]}"
|
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 an API token
|
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.User, all.User.read, userApiToken.*, or userApiToken.get.
|
85
|
+
#
|
86
|
+
# Parameters:
|
87
|
+
# * {string} apiTokenId - ID associated with the API token
|
88
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
89
|
+
# * {boolean} _actions - Return resource actions in response
|
90
|
+
# * {boolean} _links - Return resource link in response
|
91
|
+
# * {boolean} _embedded - Return embedded resources in response
|
92
|
+
#
|
93
|
+
# Responses:
|
94
|
+
# * 200 - API token information (https://api.losant.com/#/definitions/apiToken)
|
95
|
+
#
|
96
|
+
# Errors:
|
97
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
98
|
+
# * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error)
|
99
|
+
def get(params = {})
|
100
|
+
params = Utils.symbolize_hash_keys(params)
|
101
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
102
|
+
headers = {}
|
103
|
+
body = nil
|
104
|
+
|
105
|
+
raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
|
106
|
+
|
107
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
108
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
109
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
110
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
111
|
+
|
112
|
+
path = "/me/tokens/#{params[:apiTokenId]}"
|
113
|
+
|
114
|
+
@client.request(
|
115
|
+
method: :get,
|
116
|
+
path: path,
|
117
|
+
query: query_params,
|
118
|
+
headers: headers,
|
119
|
+
body: body)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Updates information about an API token
|
123
|
+
#
|
124
|
+
# Authentication:
|
125
|
+
# The client must be configured with a valid api
|
126
|
+
# access token to call this action. The token
|
127
|
+
# must include at least one of the following scopes:
|
128
|
+
# all.User, userApiToken.*, or userApiToken.patch.
|
129
|
+
#
|
130
|
+
# Parameters:
|
131
|
+
# * {string} apiTokenId - ID associated with the API token
|
132
|
+
# * {hash} apiToken - Object containing new properties of the API token (https://api.losant.com/#/definitions/apiTokenPatch)
|
133
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
134
|
+
# * {boolean} _actions - Return resource actions in response
|
135
|
+
# * {boolean} _links - Return resource link in response
|
136
|
+
# * {boolean} _embedded - Return embedded resources in response
|
137
|
+
#
|
138
|
+
# Responses:
|
139
|
+
# * 200 - Updated API token information (https://api.losant.com/#/definitions/apiToken)
|
140
|
+
#
|
141
|
+
# Errors:
|
142
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
143
|
+
# * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error)
|
144
|
+
def patch(params = {})
|
145
|
+
params = Utils.symbolize_hash_keys(params)
|
146
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
147
|
+
headers = {}
|
148
|
+
body = nil
|
149
|
+
|
150
|
+
raise ArgumentError.new("apiTokenId is required") unless params.has_key?(:apiTokenId)
|
151
|
+
raise ArgumentError.new("apiToken is required") unless params.has_key?(:apiToken)
|
152
|
+
|
153
|
+
body = params[:apiToken] if params.has_key?(:apiToken)
|
154
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
155
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
156
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
157
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
158
|
+
|
159
|
+
path = "/me/tokens/#{params[:apiTokenId]}"
|
160
|
+
|
161
|
+
@client.request(
|
162
|
+
method: :patch,
|
163
|
+
path: path,
|
164
|
+
query: query_params,
|
165
|
+
headers: headers,
|
166
|
+
body: body)
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,132 @@
|
|
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 User Api Tokens Resource
|
28
|
+
class UserApiTokens
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the API tokens for a user
|
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.User, all.User.read, userApiTokens.*, or userApiTokens.get.
|
41
|
+
#
|
42
|
+
# Parameters:
|
43
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated, expirationDate
|
44
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
45
|
+
# * {string} page - Which page of results to return
|
46
|
+
# * {string} perPage - How many items to return per page
|
47
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, status
|
48
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
49
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
50
|
+
# * {boolean} _actions - Return resource actions in response
|
51
|
+
# * {boolean} _links - Return resource link in response
|
52
|
+
# * {boolean} _embedded - Return embedded resources in response
|
53
|
+
#
|
54
|
+
# Responses:
|
55
|
+
# * 200 - Collection of API tokens (https://api.losant.com/#/definitions/apiToken)
|
56
|
+
#
|
57
|
+
# Errors:
|
58
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
59
|
+
def get(params = {})
|
60
|
+
params = Utils.symbolize_hash_keys(params)
|
61
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
62
|
+
headers = {}
|
63
|
+
body = nil
|
64
|
+
|
65
|
+
|
66
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
67
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
68
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
69
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
70
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
71
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
72
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
73
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
74
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
75
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
76
|
+
|
77
|
+
path = "/me/tokens"
|
78
|
+
|
79
|
+
@client.request(
|
80
|
+
method: :get,
|
81
|
+
path: path,
|
82
|
+
query: query_params,
|
83
|
+
headers: headers,
|
84
|
+
body: body)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create a new API token for an user
|
88
|
+
#
|
89
|
+
# Authentication:
|
90
|
+
# The client must be configured with a valid api
|
91
|
+
# access token to call this action. The token
|
92
|
+
# must include at least one of the following scopes:
|
93
|
+
# all.User, userApiTokens.*, or userApiTokens.post.
|
94
|
+
#
|
95
|
+
# Parameters:
|
96
|
+
# * {hash} apiToken - API token information (https://api.losant.com/#/definitions/apiTokenPost)
|
97
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
98
|
+
# * {boolean} _actions - Return resource actions in response
|
99
|
+
# * {boolean} _links - Return resource link in response
|
100
|
+
# * {boolean} _embedded - Return embedded resources in response
|
101
|
+
#
|
102
|
+
# Responses:
|
103
|
+
# * 201 - The successfully created API token (https://api.losant.com/#/definitions/apiToken)
|
104
|
+
#
|
105
|
+
# Errors:
|
106
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
107
|
+
def post(params = {})
|
108
|
+
params = Utils.symbolize_hash_keys(params)
|
109
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
110
|
+
headers = {}
|
111
|
+
body = nil
|
112
|
+
|
113
|
+
raise ArgumentError.new("apiToken is required") unless params.has_key?(:apiToken)
|
114
|
+
|
115
|
+
body = params[:apiToken] if params.has_key?(:apiToken)
|
116
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
117
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
118
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
119
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
120
|
+
|
121
|
+
path = "/me/tokens"
|
122
|
+
|
123
|
+
@client.request(
|
124
|
+
method: :post,
|
125
|
+
path: path,
|
126
|
+
query: query_params,
|
127
|
+
headers: headers,
|
128
|
+
body: body)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|