Class: Twilio::REST::Voice::V1::ConnectionPolicyContext::ConnectionPolicyTargetInstance

Inherits:
InstanceResource
  • 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, payload, connection_policy_sid: nil, sid: nil) ⇒ ConnectionPolicyTargetInstance

Initialize the ConnectionPolicyTargetInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • connection_policy_sid (String) (defaults to: nil)

    The SID of the Connection Policy that owns the Target.

  • sid (String) (defaults to: nil)

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


280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 280

def initialize(version, payload, connection_policy_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'connection_policy_sid' => payload['connection_policy_sid'],
      'sid' => payload['sid'],
      'friendly_name' => payload['friendly_name'],
      'target' => payload['target'],
      'priority' => payload['priority'].to_i,
      'weight' => payload['weight'].to_i,
      'enabled' => payload['enabled'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource


320
321
322
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 320

def 
  @properties['account_sid']
end

#connection_policy_sidString

Returns The SID of the Connection Policy that owns the Target.

Returns:

  • (String)

    The SID of the Connection Policy that owns the Target


326
327
328
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 326

def connection_policy_sid
  @properties['connection_policy_sid']
end

#contextConnectionPolicyTargetContext

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

Returns:


307
308
309
310
311
312
313
314
315
316
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 307

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

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created


368
369
370
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 368

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated


374
375
376
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 374

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the ConnectionPolicyTargetInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


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

def delete
  context.delete
end

#enabledBoolean

Returns Whether the target is enabled.

Returns:

  • (Boolean)

    Whether the target is enabled


362
363
364
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 362

def enabled
  @properties['enabled']
end

#fetchConnectionPolicyTargetInstance

Fetch the ConnectionPolicyTargetInstance

Returns:


387
388
389
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 387

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


338
339
340
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 338

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation


432
433
434
435
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 432

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

#priorityString

Returns The relative importance of the target.

Returns:

  • (String)

    The relative importance of the target


350
351
352
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 350

def priority
  @properties['priority']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource


332
333
334
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 332

def sid
  @properties['sid']
end

#targetString

Returns The SIP address you want Twilio to route your calls to.

Returns:

  • (String)

    The SIP address you want Twilio to route your calls to


344
345
346
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 344

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation


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

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Voice.V1.ConnectionPolicyTargetInstance #{values}>"
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:


406
407
408
409
410
411
412
413
414
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 406

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

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource


380
381
382
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 380

def url
  @properties['url']
end

#weightString

Returns The value that determines the relative load the Target should receive compared to others with the same priority.

Returns:

  • (String)

    The value that determines the relative load the Target should receive compared to others with the same priority


356
357
358
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 356

def weight
  @properties['weight']
end