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

  • account_sid (String)

    The SID of the Account that created this ConnectionPolicyTarget resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 586

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'] == nil ? payload['priority'] : payload['priority'].to_i,
        'weight' => payload['weight'] == nil ? payload['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  || @properties['connection_policy_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Target resource.

Returns:



623
624
625
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 623

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.



629
630
631
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 629

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:



614
615
616
617
618
619
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 614

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

#date_createdTime

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

Returns:



671
672
673
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 671

def date_created
    @properties['date_created']
end

#date_updatedTime

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

Returns:



677
678
679
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 677

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the ConnectionPolicyTargetInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



690
691
692
693
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 690

def delete

    context.delete
end

#enabledBoolean

Returns Whether the target is enabled. The default is ‘true`.

Returns:

  • (Boolean)

    Whether the target is enabled. The default is ‘true`.



665
666
667
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 665

def enabled
    @properties['enabled']
end

#fetchConnectionPolicyTargetInstance

Fetch the ConnectionPolicyTargetInstance

Returns:



698
699
700
701
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 698

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.



641
642
643
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 641

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



737
738
739
740
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 737

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

#priorityString

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

Returns:

  • (String)

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



653
654
655
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 653

def priority
    @properties['priority']
end

#sidString

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

Returns:

  • (String)

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



635
636
637
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 635

def sid
    @properties['sid']
end

#targetString

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

Returns:

  • (String)

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



647
648
649
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 647

def target
    @properties['target']
end

#to_sObject

Provide a user friendly representation



730
731
732
733
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 730

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:



711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 711

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.



683
684
685
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 683

def url
    @properties['url']
end

#weightString

Returns 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, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.

Returns:

  • (String)

    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, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.



659
660
661
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 659

def weight
    @properties['weight']
end