Class: Twilio::REST::Iam::V1::ApiKeyInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/iam/v1/api_key.rb

Instance Method Summary collapse

Constructor Details

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

Initialize the ApiKeyInstance

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 ApiKey resource.

  • sid (String) (defaults to: nil) —

    The SID of the Call resource to fetch.



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 303

def initialize(version, payload , sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'friendly_name' => payload['friendly_name'],
        'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
        'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
        'policy' => payload['policy'],
    }

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

Instance Method Details

#context ⇒ ApiKeyContext

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

Returns:



325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 325

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

#date_created ⇒ Time

Returns The date and time in GMT that the resource was created specified in RFC 2822 format.

Returns:

  • (Time) —

    The date and time in GMT that the resource was created specified in RFC 2822 format.



346
347
348
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 346

def date_created
    @properties['date_created']
end

#date_updated ⇒ Time

Returns The date and time in GMT that the resource was last updated specified in RFC 2822 format.

Returns:

  • (Time) —

    The date and time in GMT that the resource was last updated specified in RFC 2822 format.



352
353
354
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 352

def date_updated
    @properties['date_updated']
end

#delete ⇒ Boolean

Delete the ApiKeyInstance

Returns:

  • (Boolean) —

    True if delete succeeds, false otherwise



365
366
367
368
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 365

def delete

    context.delete
end

#fetch ⇒ ApiKeyInstance

Fetch the ApiKeyInstance

Returns:



373
374
375
376
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 373

def fetch

    context.fetch
end

#friendly_name ⇒ String

Returns The string that you assigned to describe the resource.

Returns:

  • (String) —

    The string that you assigned to describe the resource.



340
341
342
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 340

def friendly_name
    @properties['friendly_name']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



403
404
405
406
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 403

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

#policy ⇒ Hash

Returns The \`Policy\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the Twilio documentation.

Returns:

  • (Hash) —

    The \`Policy\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the Twilio documentation.



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

def policy
    @properties['policy']
end

#sid ⇒ String

Returns The unique string that we created to identify the Key resource.

Returns:

  • (String) —

    The unique string that we created to identify the Key resource.



334
335
336
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 334

def sid
    @properties['sid']
end

#to_s ⇒ Object

Provide a user friendly representation



396
397
398
399
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 396

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

#update(friendly_name: :unset, policy: :unset) ⇒ ApiKeyInstance

Update the ApiKeyInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

  • policy (Object) (defaults to: :unset) —

    The \\`Policy\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the Twilio documentation.

Returns:



383
384
385
386
387
388
389
390
391
392
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 383

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

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