Class: Twilio::REST::Microvisor::V1::DeviceInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/microvisor/v1/device.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ DeviceInstance

Initialize the DeviceInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    A 34-character string that uniquely identifies this Device.



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 256

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'unique_name' => payload['unique_name'],
      'account_sid' => payload['account_sid'],
      'app' => payload['app'],
      'logging' => payload['logging'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns Account SID.

Returns:

  • (String)

    Account SID.



302
303
304
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 302

def 
  @properties['account_sid']
end

#appHash

Returns Information about the target App and the App reported by this Device.

Returns:

  • (Hash)

    Information about the target App and the App reported by this Device.



308
309
310
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 308

def app
  @properties['app']
end

#contextDeviceContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 281

def context
  unless @instance_context
    @instance_context = DeviceContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The date that this Device was created.

Returns:

  • (Time)

    The date that this Device was created.



320
321
322
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 320

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this Device was last updated.

Returns:

  • (Time)

    The date that this Device was last updated.



326
327
328
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 326

def date_updated
  @properties['date_updated']
end

#device_configsdevice_configs

Access the device_configs

Returns:



365
366
367
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 365

def device_configs
  context.device_configs
end

#device_secretsdevice_secrets

Access the device_secrets

Returns:



372
373
374
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 372

def device_secrets
  context.device_secrets
end

#fetchDeviceInstance

Fetch the DeviceInstance

Returns:



345
346
347
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 345

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



385
386
387
388
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 385

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Microvisor.V1.DeviceInstance #{values}>"
end

Returns The absolute URLs of related resources.

Returns:

  • (String)

    The absolute URLs of related resources



338
339
340
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 338

def links
  @properties['links']
end

#loggingHash

Returns Object specifying whether application logging is enabled for this Device.

Returns:

  • (Hash)

    Object specifying whether application logging is enabled for this Device.



314
315
316
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 314

def logging
  @properties['logging']
end

#sidString

Returns A string that uniquely identifies this Device.

Returns:

  • (String)

    A string that uniquely identifies this Device.



290
291
292
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 290

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



378
379
380
381
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 378

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Microvisor.V1.DeviceInstance #{values}>"
end

#unique_nameString

Returns A developer-defined string that uniquely identifies the Device.

Returns:

  • (String)

    A developer-defined string that uniquely identifies the Device.



296
297
298
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 296

def unique_name
  @properties['unique_name']
end

#update(unique_name: :unset, target_app: :unset, logging_enabled: :unset) ⇒ DeviceInstance

Update the DeviceInstance

Parameters:

  • unique_name (String) (defaults to: :unset)

    A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.

  • target_app (String) (defaults to: :unset)

    The SID or unique name of the App to be targeted to the Device.

  • logging_enabled (Boolean) (defaults to: :unset)

    A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.

Returns:



358
359
360
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 358

def update(unique_name: :unset, target_app: :unset, logging_enabled: :unset)
  context.update(unique_name: unique_name, target_app: target_app, logging_enabled: logging_enabled, )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



332
333
334
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 332

def url
  @properties['url']
end