Class: VoiceML::SipIpAccessControlListsResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/voiceml/resources/sip.rb

Overview

/SIP/IpAccessControlLists + /IpAddresses sub-resource.

Constant Summary collapse

PAGE_FIELDS =
{ 'Page' => :page, 'PageSize' => :page_size, 'PageToken' => :page_token }.freeze
IP_FIELDS =
{ 'FriendlyName' => :friendly_name, 'IpAddress' => :ip_address, 'CidrPrefixLength' => :cidr_prefix_length }.freeze

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from VoiceML::BaseResource

Instance Method Details

#create(friendly_name:) ⇒ Object



177
178
179
# File 'lib/voiceml/resources/sip.rb', line 177

def create(friendly_name:)
  SipIpAccessControlList.from_hash(@transport.request(:post, path('SIP', 'IpAccessControlLists'), form: { 'FriendlyName' => friendly_name }))
end

#create_ip_address(acl_sid, friendly_name:, ip_address:, cidr_prefix_length: nil) ⇒ Object



195
196
197
198
199
# File 'lib/voiceml/resources/sip.rb', line 195

def create_ip_address(acl_sid, friendly_name:, ip_address:, cidr_prefix_length: nil)
  form = { 'FriendlyName' => friendly_name, 'IpAddress' => ip_address }
  form['CidrPrefixLength'] = cidr_prefix_length unless cidr_prefix_length.nil?
  SipIpAddress.from_hash(@transport.request(:post, path('SIP', 'IpAccessControlLists', acl_sid, 'IpAddresses'), form: form))
end

#delete(acl_sid) ⇒ Object



187
188
189
# File 'lib/voiceml/resources/sip.rb', line 187

def delete(acl_sid)
  @transport.request(:delete, path('SIP', 'IpAccessControlLists', acl_sid)); nil
end

#delete_ip_address(acl_sid, ip_address_sid) ⇒ Object



206
207
208
# File 'lib/voiceml/resources/sip.rb', line 206

def delete_ip_address(acl_sid, ip_address_sid)
  @transport.request(:delete, path('SIP', 'IpAccessControlLists', acl_sid, 'IpAddresses', ip_address_sid)); nil
end

#fetch(acl_sid) ⇒ Object



180
181
182
# File 'lib/voiceml/resources/sip.rb', line 180

def fetch(acl_sid)
  SipIpAccessControlList.from_hash(@transport.request(:get, path('SIP', 'IpAccessControlLists', acl_sid)))
end

#fetch_ip_address(acl_sid, ip_address_sid) ⇒ Object



200
201
202
# File 'lib/voiceml/resources/sip.rb', line 200

def fetch_ip_address(acl_sid, ip_address_sid)
  SipIpAddress.from_hash(@transport.request(:get, path('SIP', 'IpAccessControlLists', acl_sid, 'IpAddresses', ip_address_sid)))
end

#list(**kwargs) ⇒ Object



174
175
176
# File 'lib/voiceml/resources/sip.rb', line 174

def list(**kwargs)
  SipIpAccessControlListList.new(@transport.request(:get, path('SIP', 'IpAccessControlLists'), params: form_params(PAGE_FIELDS, kwargs)))
end

#list_ip_addresses(acl_sid, **kwargs) ⇒ Object

/IpAddresses sub-resource



192
193
194
# File 'lib/voiceml/resources/sip.rb', line 192

def list_ip_addresses(acl_sid, **kwargs)
  SipIpAddressList.new(@transport.request(:get, path('SIP', 'IpAccessControlLists', acl_sid, 'IpAddresses'), params: form_params(PAGE_FIELDS, kwargs)))
end

#update(acl_sid, friendly_name: nil) ⇒ Object



183
184
185
186
# File 'lib/voiceml/resources/sip.rb', line 183

def update(acl_sid, friendly_name: nil)
  form = friendly_name.nil? ? {} : { 'FriendlyName' => friendly_name }
  SipIpAccessControlList.from_hash(@transport.request(:post, path('SIP', 'IpAccessControlLists', acl_sid), form: form))
end

#update_ip_address(acl_sid, ip_address_sid, **kwargs) ⇒ Object



203
204
205
# File 'lib/voiceml/resources/sip.rb', line 203

def update_ip_address(acl_sid, ip_address_sid, **kwargs)
  SipIpAddress.from_hash(@transport.request(:post, path('SIP', 'IpAccessControlLists', acl_sid, 'IpAddresses', ip_address_sid), form: form_params(IP_FIELDS, kwargs)))
end