Class: LosantRest::Org

Inherits:
Object
  • Object
show all
Defined in:
lib/losant_rest/org.rb

Overview

Class containing all the actions for the Org Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Org

Returns a new instance of Org.



30
31
32
# File 'lib/losant_rest/org.rb', line 30

def initialize(client)
  @client = client
end

Instance Method Details

#delete(params = {}) ⇒ Object

Deletes an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.delete.

Parameters:

  • string orgId - ID associated with the organization

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/losant_rest/org.rb', line 55

def delete(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#device_counts(params = {}) ⇒ Object

Returns device counts by day for the time range specified for this organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.deviceCounts.

Parameters:

  • string orgId - ID associated with the organization

  • string start - Start of range for device count query (ms since epoch)

  • string end - End of range for device count query (ms since epoch)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/losant_rest/org.rb', line 101

def device_counts(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:start] = params[:start] if params.has_key?(:start)
  query_params[:end] = params[:end] if params.has_key?(:end)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/deviceCounts"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#get(params = {}) ⇒ Object

Retrieves information on an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.get.

Parameters:

  • string orgId - ID associated with the organization

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/losant_rest/org.rb', line 149

def get(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#invite_member(params = {}) ⇒ Object

Invites a person to an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.inviteMember.

Parameters:

  • string orgId - ID associated with the organization

  • hash invite - Object containing new invite info (api.losant.com/#/definitions/orgInvitePost)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/losant_rest/org.rb', line 196

def invite_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("invite is required") unless params.has_key?(:invite)

  body = params[:invite] if params.has_key?(:invite)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#modify_member(params = {}) ⇒ Object

Modifies a current org member’s role

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.modifyMember.

Parameters:

  • string orgId - ID associated with the organization

  • hash member - Object containing new member pair (api.losant.com/#/definitions/orgMemberPatch)

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/losant_rest/org.rb', line 245

def modify_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("member is required") unless params.has_key?(:member)

  body = params[:member] if params.has_key?(:member)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/member"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#notebook_minute_counts(params = {}) ⇒ Object

Returns notebook execution usage by day for the time range specified for this organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.notebookMinuteCounts.

Parameters:

  • string orgId - ID associated with the organization

  • string start - Start of range for notebook execution query (ms since epoch)

  • string end - End of range for notebook execution query (ms since epoch)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/losant_rest/org.rb', line 295

def notebook_minute_counts(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:start] = params[:start] if params.has_key?(:start)
  query_params[:end] = params[:end] if params.has_key?(:end)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/notebookMinuteCounts"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#patch(params = {}) ⇒ Object

Updates information about an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.patch.

Parameters:

  • string orgId - ID associated with the organization

  • hash organization - Object containing new organization properties (api.losant.com/#/definitions/orgPatch)

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/losant_rest/org.rb', line 344

def patch(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("organization is required") unless params.has_key?(:organization)

  body = params[:organization] if params.has_key?(:organization)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#payload_counts(params = {}) ⇒ Object

Returns payload counts for the time range specified for all applications this organization owns

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.payloadCounts.

Parameters:

  • string orgId - ID associated with the organization

  • string start - Start of range for payload count query (ms since epoch)

  • string end - End of range for payload count query (ms since epoch)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/losant_rest/org.rb', line 394

def payload_counts(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:start] = params[:start] if params.has_key?(:start)
  query_params[:end] = params[:end] if params.has_key?(:end)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/payloadCounts"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#payload_counts_breakdown(params = {}) ⇒ Object

Returns payload counts per resolution in the time range specified for all application this organization owns

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.payloadCountsBreakdown.

Parameters:

  • string orgId - ID associated with the organization

  • string start - Start of range for payload count query (ms since epoch)

  • string end - End of range for payload count query (ms since epoch)

  • string resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000

  • string asBytes - If the resulting stats should be returned as bytes

  • string includeNonBillable - If non-billable payloads should be included in the result

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'lib/losant_rest/org.rb', line 445

def payload_counts_breakdown(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:start] = params[:start] if params.has_key?(:start)
  query_params[:end] = params[:end] if params.has_key?(:end)
  query_params[:resolution] = params[:resolution] if params.has_key?(:resolution)
  query_params[:asBytes] = params[:asBytes] if params.has_key?(:asBytes)
  query_params[:includeNonBillable] = params[:includeNonBillable] if params.has_key?(:includeNonBillable)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/payloadCountsBreakdown"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#pending_invites(params = {}) ⇒ Object

Gets the current pending invites

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.pendingInvites.

Parameters:

  • string orgId - ID associated with the organization

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/losant_rest/org.rb', line 494

def pending_invites(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#remove_member(params = {}) ⇒ Object

Removes a member from the org

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.removeMember.

Parameters:

  • string orgId - ID associated with the organization

  • string userId - Id of user to remove

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/losant_rest/org.rb', line 541

def remove_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("userId is required") unless params.has_key?(:userId)

  query_params[:userId] = params[:userId] if params.has_key?(:userId)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/member"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#revoke_invite(params = {}) ⇒ Object

Revokes an existing invite

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.revokeInvite.

Parameters:

  • string orgId - ID associated with the organization

  • string inviteId - Id of invite to revoke

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/losant_rest/org.rb', line 590

def revoke_invite(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("inviteId is required") unless params.has_key?(:inviteId)

  query_params[:inviteId] = params[:inviteId] if params.has_key?(:inviteId)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#transfer_resources(params = {}) ⇒ Object

Moves resources to a new owner

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.transferResources.

Parameters:

  • string orgId - ID associated with the organization

  • hash transfer - Object containing properties of the transfer (api.losant.com/#/definitions/resourceTransfer)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/losant_rest/org.rb', line 637

def transfer_resources(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("transfer is required") unless params.has_key?(:transfer)

  body = params[:transfer] if params.has_key?(:transfer)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/transferResources"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end