Class: Twilio::REST::Voice::V1::ConnectionPolicyContext::ConnectionPolicyTargetContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, connection_policy_sid, sid) ⇒ ConnectionPolicyTargetContext

Initialize the ConnectionPolicyTargetContext

Parameters:

  • version (Version)

    Version that contains the resource

  • connection_policy_sid (String)

    The SID of the Connection Policy that owns the Target.

  • sid (String)

    The unique string that we created to identify the Target resource to update.



244
245
246
247
248
249
250
251
252
253
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 244

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

    # Path Solution
    @solution = { connection_policy_sid: connection_policy_sid, sid: sid,  }
    @uri = "/ConnectionPolicies/#{@solution[:connection_policy_sid]}/Targets/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the ConnectionPolicyTargetInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



257
258
259
260
261
262
263
264
265
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 257

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 ConnectionPolicyTargetInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 270

def 

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

#fetchConnectionPolicyTargetInstance

Fetch the ConnectionPolicyTargetInstance

Returns:



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 289

def fetch

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

#fetch_with_metadataConnectionPolicyTargetInstance

Fetch the ConnectionPolicyTargetInstanceMetadata

Returns:



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 309

def 

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

#inspectObject

Provide a detailed, user friendly representation



426
427
428
429
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 426

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

#to_sObject

Provide a user friendly representation



419
420
421
422
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 419

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

#update(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset) ⇒ ConnectionPolicyTargetInstance

Update the ConnectionPolicyTargetInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    The SIP address you want Twilio to route your calls to. This must be a sip: schema. sips is NOT supported.

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

    The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.

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

    The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.

  • enabled (Boolean) (defaults to: :unset)

    Whether the Target is enabled.

Returns:



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 340

def update(
    friendly_name: :unset, 
    target: :unset, 
    priority: :unset, 
    weight: :unset, 
    enabled: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Target' => target,
        'Priority' => priority,
        'Weight' => weight,
        'Enabled' => enabled,
    })

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

#update_with_metadata(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset) ⇒ ConnectionPolicyTargetInstance

Update the ConnectionPolicyTargetInstanceMetadata

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    The SIP address you want Twilio to route your calls to. This must be a sip: schema. sips is NOT supported.

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

    The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.

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

    The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.

  • enabled (Boolean) (defaults to: :unset)

    Whether the Target is enabled.

Returns:



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 379

def (
  friendly_name: :unset, 
  target: :unset, 
  priority: :unset, 
  weight: :unset, 
  enabled: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Target' => target,
        'Priority' => priority,
        'Weight' => weight,
        'Enabled' => enabled,
    })

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