# The MIT License (MIT) # # Copyright (c) 2024 Losant IoT, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require "json" module PlatformRest # Class containing all the actions for the Application Resource class Application def initialize(client) @client = client end # 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 (https://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: # * 200 - Updated application information (https://api.losant.com/#/definitions/application) # * 202 - If a job was enqueued for the resources to be imported into the application (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 202 - Enqueued a job to archive this applications device data (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 202 - Enqueued a job to backfill device data to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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 (https://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: # * 200 - if dryRun is set and successful, then return success (https://api.losant.com/#/definitions/applicationCloneDryRunResult) # * 201 - If application was successfully cloned (https://api.losant.com/#/definitions/applicationCreationByTemplateResult) # * 202 - If application was enqueued to be cloned (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) # * 422 - Error if too many validation errors occurred on other resources (https://api.losant.com/#/definitions/validationErrors) 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 # 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: # * 200 - If application was successfully deleted (https://api.losant.com/#/definitions/success) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # Returns device counts by day 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.deviceCounts. # # Parameters: # * {string} applicationId - ID of the associated application # * {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: # * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) def device_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]}/deviceCounts" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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 (https://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: # * 200 - a url to download the zip of exported resources (https://api.losant.com/#/definitions/applicationExportResult) # * 202 - If application was enqueued to be exported (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 202 - Enqueued a job to archive all selected data tables of this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 202 - Enqueued a job to archive all events to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Application information (https://api.losant.com/#/definitions/application) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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 (https://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: # * 200 - Updated application information (https://api.losant.com/#/definitions/application) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # Retrieves information on application import logs # # 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.importLogs. # # Parameters: # * {string} applicationId - ID of the associated application # * {string} limit - Max log entries to return (ordered by time descending) # * {string} since - Look for log entries since this time (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: # * 200 - Application log objects (https://api.losant.com/#/definitions/applicationImportExecutions) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) def import_logs(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[:limit] = params[:limit] if params.has_key?(:limit) query_params[:since] = params[:since] if params.has_key?(:since) 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]}/importLogs" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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 (https://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: # * 200 - Message successfully published (https://api.losant.com/#/definitions/success) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # Returns notebook execution usage by day 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.notebookMinuteCounts. # # Parameters: # * {string} applicationId - ID of the associated application # * {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: # * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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("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]}/notebookMinuteCounts" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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 (https://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: # * 200 - Updated application information (https://api.losant.com/#/definitions/application) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # Returns payload counts per resolution in 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.payloadCountsBreakdown. # # 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} 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: # * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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("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) 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 = "/applications/#{params[:applicationId]}/payloadCountsBreakdown" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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: # * 200 - The application readme information (https://api.losant.com/#/definitions/applicationReadme) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # 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 (https://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: # * 200 - Updated readme information (https://api.losant.com/#/definitions/applicationReadme) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) 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 # Search across an application's resources by target identifier # # 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.search. # # Parameters: # * {string} applicationId - ID of the associated application # * {string} filter - The partial resource name being searched for # * {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: # * 200 - An array of resource ids, names, descriptions, and types matching the search query (https://api.losant.com/#/definitions/applicationSearchResult) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) def search(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("filter is required") unless params.has_key?(:filter) query_params[:filter] = params[:filter] if params.has_key?(:filter) 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]}/search" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end end end