Class: Twilio::REST::Preview::DeployedDevices::FleetContext::KeyInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.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, fleet_sid: nil, sid: nil) ⇒ KeyInstance

Initialize the KeyInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • fleet_sid (String) (defaults to: nil)

    Specifies the unique string identifier of the Fleet that the given Key credential belongs to.

  • sid (String) (defaults to: nil)

    Provides a 34 character string that uniquely identifies the requested Key credential resource.



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 293

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'url' => payload['url'],
      'friendly_name' => payload['friendly_name'],
      'fleet_sid' => payload['fleet_sid'],
      'account_sid' => payload['account_sid'],
      'device_sid' => payload['device_sid'],
      'secret' => payload['secret'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
  }

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

Instance Method Details

#account_sidString

Returns The unique SID that identifies this Account.

Returns:

  • (String)

    The unique SID that identifies this Account.



358
359
360
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 358

def 
  @properties['account_sid']
end

#contextKeyContext

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

Returns:

  • (KeyContext)

    KeyContext for this KeyInstance



321
322
323
324
325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 321

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

#date_createdTime

Returns The date this Key credential was created.

Returns:

  • (Time)

    The date this Key credential was created.



376
377
378
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 376

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Key credential was updated.

Returns:

  • (Time)

    The date this Key credential was updated.



382
383
384
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 382

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the KeyInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



396
397
398
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 396

def delete
  context.delete
end

#device_sidString

Returns The unique identifier of a mapped Device.

Returns:

  • (String)

    The unique identifier of a mapped Device.



364
365
366
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 364

def device_sid
  @properties['device_sid']
end

#fetchKeyInstance

Fetch a KeyInstance

Returns:



389
390
391
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 389

def fetch
  context.fetch
end

#fleet_sidString

Returns The unique identifier of the Fleet.

Returns:

  • (String)

    The unique identifier of the Fleet.



352
353
354
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 352

def fleet_sid
  @properties['fleet_sid']
end

#friendly_nameString

Returns A human readable description for this Key.

Returns:

  • (String)

    A human readable description for this Key.



346
347
348
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 346

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



423
424
425
426
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 423

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

#secretString

Returns The key secret.

Returns:

  • (String)

    The key secret.



370
371
372
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 370

def secret
  @properties['secret']
end

#sidString

Returns A string that uniquely identifies this Key.

Returns:

  • (String)

    A string that uniquely identifies this Key.



334
335
336
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 334

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



416
417
418
419
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 416

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

#update(friendly_name: :unset, device_sid: :unset) ⇒ KeyInstance

Update the KeyInstance

Parameters:

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

    Provides a human readable descriptive text for this Key credential, up to 256 characters long.

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

    Provides the unique string identifier of an existing Device to become authenticated with this Key credential.

Returns:



407
408
409
410
411
412
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 407

def update(friendly_name: :unset, device_sid: :unset)
  context.update(
      friendly_name: friendly_name,
      device_sid: device_sid,
  )
end

#urlString

Returns URL of this Key.

Returns:

  • (String)

    URL of this Key.



340
341
342
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 340

def url
  @properties['url']
end