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.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 172

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

#contextApiKeyContext

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

Returns:



193
194
195
196
197
198
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 193

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

#date_createdTime

Returns The date and time in GMT that the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



214
215
216
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 214

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT that the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



220
221
222
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 220

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the ApiKeyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



233
234
235
236
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 233

def delete

    context.delete
end

#fetchApiKeyInstance

Fetch the ApiKeyInstance

Returns:



241
242
243
244
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 241

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource.



208
209
210
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 208

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



271
272
273
274
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 271

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

#policyHash

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](www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).

Returns:



226
227
228
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 226

def policy
    @properties['policy']
end

#sidString

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.



202
203
204
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 202

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



264
265
266
267
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 264

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](www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys).

Returns:



251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/iam/v1/api_key.rb', line 251

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

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