class LosantRest::Application

Class containing all the actions for the Application Resource

Public Class Methods

new(client) click to toggle source
# File lib/losant_rest/application.rb, line 30
def initialize(client)
  @client = client
end

Public Instance Methods

apply_template(params = {}) click to toggle source

Add resources to an application via an application template

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.Application, all.Organization, all.User, application.*, or application.applyTemplate.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} options - Object containing template import options (api.losant.com/#/definitions/applicationApplyTemplatePatch)

  • {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:

# File lib/losant_rest/application.rb, line 57
def apply_template(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:options] if params.has_key?(:options)
  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 = "/applications/#{params[:applicationId]}/applyTemplate"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
archive_data(params = {}) click to toggle source

Returns success when a job has been enqueued to archive this application's device data for a given day

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.Application, all.Organization, all.User, application.*, or application.archiveData.

Parameters:

  • {string} applicationId - ID of the associated application

  • {string} date - The date to archive data (ms since epoch), it must be within the archive time range older than 31 days and newer than the organizations dataTTL

  • {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:

# File lib/losant_rest/application.rb, line 104
def archive_data(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  query_params[:date] = params[:date] if params.has_key?(:date)
  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 = "/applications/#{params[:applicationId]}/archiveData"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
backfill_archive_data(params = {}) click to toggle source

Returns success when a job has been enqueued to backfill all current data to its archive

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.Application, all.Organization, all.User, application.*, or application.backfillArchiveData.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 150
def backfill_archive_data(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}/backfillArchiveData"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
clone(params = {}) click to toggle source

Copy an application into a new application

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.Application, all.Organization, all.User, application.*, or application.clone.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} options - Object containing optional clone fields (api.losant.com/#/definitions/applicationClonePost)

  • {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:

# File lib/losant_rest/application.rb, line 198
def clone(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:options] if params.has_key?(:options)
  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 = "/applications/#{params[:applicationId]}/clone"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
delete(params = {}) click to toggle source

Deletes an application

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.Application, all.Organization, all.User, application.*, or application.delete.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 243
def delete(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
export(params = {}) click to toggle source

Export an application and all of its resources

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.Application, all.Organization, all.User, application.*, or application.export.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} options - Object containing export application options (api.losant.com/#/definitions/applicationExportPost)

  • {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:

# File lib/losant_rest/application.rb, line 289
def export(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:options] if params.has_key?(:options)
  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 = "/applications/#{params[:applicationId]}/export"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
full_data_tables_archive(params = {}) click to toggle source

Returns success when a job has been enqueued to archive all selected data tables

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.Application, all.Organization, all.User, application.*, or application.fullDataTablesArchive.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 335
def full_data_tables_archive(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}/fullDataTablesArchive"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
full_events_archive(params = {}) click to toggle source

Returns success when a job has been enqueued to archive all current events

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.Application, all.Organization, all.User, application.*, or application.fullEventsArchive.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 379
def full_events_archive(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}/fullEventsArchive"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
get(params = {}) click to toggle source

Retrieves information on an application

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.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get.

Parameters:

  • {string} applicationId - ID of the associated application

  • {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary

  • {string} summaryInclude - Comma-separated list of summary fields to include in application 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:

# File lib/losant_rest/application.rb, line 425
def get(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
globals(params = {}) click to toggle source

Updates an application global at the given key

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.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} globals - Array of objects containing new application global information (api.losant.com/#/definitions/applicationGlobalPatch)

  • {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:

# File lib/losant_rest/application.rb, line 472
def globals(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:globals] if params.has_key?(:globals)
  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 = "/applications/#{params[:applicationId]}/globals"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
mqtt_publish_message(params = {}) click to toggle source

Publishes the given message to the given MQTT topic

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.Application, all.Organization, all.User, application.*, or application.mqttPublishMessage.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} payload - Object containing topic and message (api.losant.com/#/definitions/mqttPublishBody)

  • {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:

# File lib/losant_rest/application.rb, line 519
def mqtt_publish_message(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:payload] if params.has_key?(:payload)
  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 = "/applications/#{params[:applicationId]}/mqttPublishMessage"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
patch(params = {}) click to toggle source

Updates information about an application

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.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} application - Object containing new application properties (api.losant.com/#/definitions/applicationPatch)

  • {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary

  • {string} summaryInclude - Comma-separated list of summary fields to include in application 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:

# File lib/losant_rest/application.rb, line 568
def patch(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:application] if params.has_key?(:application)
  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 = "/applications/#{params[:applicationId]}"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
payload_counts(params = {}) click to toggle source

Returns payload counts for the time range specified for this application

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.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.payloadCounts.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 618
def payload_counts(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}/payloadCounts"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
readme(params = {}) click to toggle source

Get the current application readme information

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.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get.

Parameters:

  • {string} applicationId - ID of the associated application

  • {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:

# File lib/losant_rest/application.rb, line 664
def readme(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  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 = "/applications/#{params[:applicationId]}/readme"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end
readme_patch(params = {}) click to toggle source

Update the current application readme information

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.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch.

Parameters:

  • {string} applicationId - ID of the associated application

  • {hash} readme - Object containing new readme information (api.losant.com/#/definitions/applicationReadmePatch)

  • {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:

# File lib/losant_rest/application.rb, line 709
def readme_patch(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

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

  body = params[:readme] if params.has_key?(:readme)
  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 = "/applications/#{params[:applicationId]}/readme"

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