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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb

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

  • account_sid (String)

    The SID of the Account that created this Key resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 275

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  || @properties['fleet_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns Specifies the unique string identifier of the Account responsible for this Key credential.

Returns:

  • (String)

    Specifies the unique string identifier of the Account responsible for this Key credential.



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

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)

    CallContext for this CallInstance



300
301
302
303
304
305
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 300

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

#date_createdTime

Returns Specifies the date this Key credential was created, given in UTC ISO 8601 format.

Returns:

  • (Time)

    Specifies the date this Key credential was created, given in UTC ISO 8601 format.



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

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns Specifies the date this Key credential was last updated, given in UTC ISO 8601 format.

Returns:

  • (Time)

    Specifies the date this Key credential was last updated, given in UTC ISO 8601 format.



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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the KeyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#device_sidString

Returns Specifies the unique string identifier of a Device authenticated with this Key credential.

Returns:

  • (String)

    Specifies the unique string identifier of a Device authenticated with this Key credential.



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

def device_sid
    @properties['device_sid']
end

#fetchKeyInstance

Fetch the KeyInstance

Returns:



372
373
374
375
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 372

def fetch

    context.fetch
end

#fleet_sidString

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

Returns:

  • (String)

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



327
328
329
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 327

def fleet_sid
    @properties['fleet_sid']
end

#friendly_nameString

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

Returns:

  • (String)

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



321
322
323
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 321

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



402
403
404
405
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 402

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

#secretString

Returns Contains the automatically generated secret belonging to this Key credential, used to authenticate the Device.

Returns:

  • (String)

    Contains the automatically generated secret belonging to this Key credential, used to authenticate the Device.



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

def secret
    @properties['secret']
end

#sidString

Returns Contains a 34 character string that uniquely identifies this Key credential resource.

Returns:

  • (String)

    Contains a 34 character string that uniquely identifies this Key credential resource.



309
310
311
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 309

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



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

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:



382
383
384
385
386
387
388
389
390
391
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 382

def update(
    friendly_name: :unset, 
    device_sid: :unset
)

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

#urlString

Returns Contains an absolute URL for this Key credential resource.

Returns:

  • (String)

    Contains an absolute URL for this Key credential resource.



315
316
317
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 315

def url
    @properties['url']
end