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

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

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

  • account_sid (String)

    The SID of the Account that created this Device resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 279

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 The unique SID identifier of the Account.

Returns:

  • (String)

    The unique SID identifier of the Account.



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

def 
    @properties['account_sid']
end

#appHash

Returns Information about the target App and the App reported by this Device. Contains the properties ‘target_sid`, `date_targeted`, `update_status` (one of `up-to-date`, `pending` and `error`), `update_error_code`, `reported_sid` and `date_reported`.

Returns:

  • (Hash)

    Information about the target App and the App reported by this Device. Contains the properties ‘target_sid`, `date_targeted`, `update_status` (one of `up-to-date`, `pending` and `error`), `update_error_code`, `reported_sid` and `date_reported`.



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

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:



304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 304

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, given in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



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

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date that this Device was last updated, given in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



349
350
351
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 349

def date_updated
    @properties['date_updated']
end

#device_configsdevice_configs

Access the device_configs

Returns:



405
406
407
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 405

def device_configs
    context.device_configs
end

#device_secretsdevice_secrets

Access the device_secrets

Returns:



398
399
400
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 398

def device_secrets
    context.device_secrets
end

#fetchDeviceInstance

Fetch the DeviceInstance

Returns:



368
369
370
371
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 368

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



418
419
420
421
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 418

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

Returns The absolute URLs of related resources.

Returns:

  • (Hash)

    The absolute URLs of related resources.



361
362
363
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 361

def links
    @properties['links']
end

#loggingHash

Returns Object specifying whether application logging is enabled for this Device. Contains the properties ‘enabled` and `date_expires`.

Returns:

  • (Hash)

    Object specifying whether application logging is enabled for this Device. Contains the properties ‘enabled` and `date_expires`.



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

def logging
    @properties['logging']
end

#sidString

Returns A 34-character string that uniquely identifies this Device.

Returns:

  • (String)

    A 34-character string that uniquely identifies this Device.



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

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



411
412
413
414
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 411

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. This value must be unique for all Devices on this Account. The ‘unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource.

Returns:

  • (String)

    A developer-defined string that uniquely identifies the Device. This value must be unique for all Devices on this Account. The ‘unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource.



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

def unique_name
    @properties['unique_name']
end

#update(unique_name: :unset, target_app: :unset, logging_enabled: :unset, restart_app: :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.

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

    Set to true to restart the App running on the Device.

Returns:



380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 380

def update(
    unique_name: :unset, 
    target_app: :unset, 
    logging_enabled: :unset, 
    restart_app: :unset
)

    context.update(
        unique_name: unique_name, 
        target_app: target_app, 
        logging_enabled: logging_enabled, 
        restart_app: restart_app, 
    )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



355
356
357
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 355

def url
    @properties['url']
end