Class: Twilio::REST::Api::V2010::AccountContext::KeyContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ KeyContext

Initialize the KeyContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Key resources to update.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Key resource to update.



162
163
164
165
166
167
168
169
170
171
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 162

def initialize(version, , sid)
    super(version)
    

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Keys/#{@solution[:sid]}.json"

    
end

Instance Method Details

#deleteBoolean

Delete the KeyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



175
176
177
178
179
180
181
182
183
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 175

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the KeyInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 188

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      key_instance = KeyInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      KeyInstanceMetadata.new(@version, key_instance, response.headers, response.status_code)
end

#fetchKeyInstance

Fetch the KeyInstance

Returns:



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 207

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    KeyInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataKeyInstance

Fetch the KeyInstanceMetadata

Returns:



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 227

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    key_instance = KeyInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    KeyInstanceMetadata.new(
        @version,
        key_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



320
321
322
323
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 320

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.KeyContext #{context}>"
end

#to_sObject

Provide a user friendly representation



313
314
315
316
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 313

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.KeyContext #{context}>"
end

#update(friendly_name: :unset) ⇒ KeyInstance

Update the KeyInstance

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.

Returns:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 254

def update(
    friendly_name: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    KeyInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#update_with_metadata(friendly_name: :unset) ⇒ KeyInstance

Update the KeyInstanceMetadata

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.

Returns:



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 281

def (
  friendly_name: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    key_instance = KeyInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    KeyInstanceMetadata.new(
        @version,
        key_instance,
        response.headers,
        response.status_code
    )
end