1# coding=utf-8 2r""" 3This code was generated by 4\ / _ _ _| _ _ 5 | (_)\/(_)(_|\/| |(/_ v1.0.0 6 / / 7""" 8 9from twilio.base import deserialize 10from twilio.base import values 11from twilio.base.instance_context import InstanceContext 12from twilio.base.instance_resource import InstanceResource 13from twilio.base.list_resource import ListResource 14from twilio.base.page import Page 15from twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on import AssignedAddOnList 16from twilio.rest.api.v2010.account.incoming_phone_number.local import LocalList 17from twilio.rest.api.v2010.account.incoming_phone_number.mobile import MobileList 18from twilio.rest.api.v2010.account.incoming_phone_number.toll_free import TollFreeList 19 20 21class IncomingPhoneNumberList(ListResource): 22 23 def __init__(self, version, account_sid): 24 """ 25 Initialize the IncomingPhoneNumberList 26 27 :param Version version: Version that contains the resource 28 :param account_sid: The SID of the Account that created the resource 29 30 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList 31 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList 32 """ 33 super(IncomingPhoneNumberList, self).__init__(version) 34 35 # Path Solution 36 self._solution = {'account_sid': account_sid, } 37 self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers.json'.format(**self._solution) 38 39 # Components 40 self._local = None 41 self._mobile = None 42 self._toll_free = None 43 44 def stream(self, beta=values.unset, friendly_name=values.unset, 45 phone_number=values.unset, origin=values.unset, limit=None, 46 page_size=None): 47 """ 48 Streams IncomingPhoneNumberInstance records from the API as a generator stream. 49 This operation lazily loads records as efficiently as possible until the limit 50 is reached. 51 The results are returned as a generator, so this operation is memory efficient. 52 53 :param bool beta: Whether to include new phone numbers 54 :param unicode friendly_name: A string that identifies the IncomingPhoneNumber resources to read 55 :param unicode phone_number: The phone numbers of the IncomingPhoneNumber resources to read 56 :param unicode origin: Include phone numbers based on their origin. By default, phone numbers of all origin are included. 57 :param int limit: Upper limit for the number of records to return. stream() 58 guarantees to never return more than limit. Default is no limit 59 :param int page_size: Number of records to fetch per request, when not set will use 60 the default value of 50 records. If no page_size is defined 61 but a limit is defined, stream() will attempt to read the 62 limit with the most efficient page size, i.e. min(limit, 1000) 63 64 :returns: Generator that will yield up to limit results 65 :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance] 66 """ 67 limits = self._version.read_limits(limit, page_size) 68 69 page = self.page( 70 beta=beta, 71 friendly_name=friendly_name, 72 phone_number=phone_number, 73 origin=origin, 74 page_size=limits['page_size'], 75 ) 76 77 return self._version.stream(page, limits['limit']) 78 79 def list(self, beta=values.unset, friendly_name=values.unset, 80 phone_number=values.unset, origin=values.unset, limit=None, 81 page_size=None): 82 """ 83 Lists IncomingPhoneNumberInstance records from the API as a list. 84 Unlike stream(), this operation is eager and will load `limit` records into 85 memory before returning. 86 87 :param bool beta: Whether to include new phone numbers 88 :param unicode friendly_name: A string that identifies the IncomingPhoneNumber resources to read 89 :param unicode phone_number: The phone numbers of the IncomingPhoneNumber resources to read 90 :param unicode origin: Include phone numbers based on their origin. By default, phone numbers of all origin are included. 91 :param int limit: Upper limit for the number of records to return. list() guarantees 92 never to return more than limit. Default is no limit 93 :param int page_size: Number of records to fetch per request, when not set will use 94 the default value of 50 records. If no page_size is defined 95 but a limit is defined, list() will attempt to read the limit 96 with the most efficient page size, i.e. min(limit, 1000) 97 98 :returns: Generator that will yield up to limit results 99 :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance] 100 """ 101 return list(self.stream( 102 beta=beta, 103 friendly_name=friendly_name, 104 phone_number=phone_number, 105 origin=origin, 106 limit=limit, 107 page_size=page_size, 108 )) 109 110 def page(self, beta=values.unset, friendly_name=values.unset, 111 phone_number=values.unset, origin=values.unset, 112 page_token=values.unset, page_number=values.unset, 113 page_size=values.unset): 114 """ 115 Retrieve a single page of IncomingPhoneNumberInstance records from the API. 116 Request is executed immediately 117 118 :param bool beta: Whether to include new phone numbers 119 :param unicode friendly_name: A string that identifies the IncomingPhoneNumber resources to read 120 :param unicode phone_number: The phone numbers of the IncomingPhoneNumber resources to read 121 :param unicode origin: Include phone numbers based on their origin. By default, phone numbers of all origin are included. 122 :param str page_token: PageToken provided by the API 123 :param int page_number: Page Number, this value is simply for client state 124 :param int page_size: Number of records to return, defaults to 50 125 126 :returns: Page of IncomingPhoneNumberInstance 127 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage 128 """ 129 data = values.of({ 130 'Beta': beta, 131 'FriendlyName': friendly_name, 132 'PhoneNumber': phone_number, 133 'Origin': origin, 134 'PageToken': page_token, 135 'Page': page_number, 136 'PageSize': page_size, 137 }) 138 139 response = self._version.page(method='GET', uri=self._uri, params=data, ) 140 141 return IncomingPhoneNumberPage(self._version, response, self._solution) 142 143 def get_page(self, target_url): 144 """ 145 Retrieve a specific page of IncomingPhoneNumberInstance records from the API. 146 Request is executed immediately 147 148 :param str target_url: API-generated URL for the requested results page 149 150 :returns: Page of IncomingPhoneNumberInstance 151 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage 152 """ 153 response = self._version.domain.twilio.request( 154 'GET', 155 target_url, 156 ) 157 158 return IncomingPhoneNumberPage(self._version, response, self._solution) 159 160 def create(self, api_version=values.unset, friendly_name=values.unset, 161 sms_application_sid=values.unset, sms_fallback_method=values.unset, 162 sms_fallback_url=values.unset, sms_method=values.unset, 163 sms_url=values.unset, status_callback=values.unset, 164 status_callback_method=values.unset, 165 voice_application_sid=values.unset, 166 voice_caller_id_lookup=values.unset, 167 voice_fallback_method=values.unset, voice_fallback_url=values.unset, 168 voice_method=values.unset, voice_url=values.unset, 169 emergency_status=values.unset, emergency_address_sid=values.unset, 170 trunk_sid=values.unset, identity_sid=values.unset, 171 address_sid=values.unset, voice_receive_mode=values.unset, 172 bundle_sid=values.unset, phone_number=values.unset, 173 area_code=values.unset): 174 """ 175 Create the IncomingPhoneNumberInstance 176 177 :param unicode api_version: The API version to use for incoming calls made to the new phone number 178 :param unicode friendly_name: A string to describe the new phone number 179 :param unicode sms_application_sid: The SID of the application to handle SMS messages 180 :param unicode sms_fallback_method: HTTP method used with sms_fallback_url 181 :param unicode sms_fallback_url: The URL we call when an error occurs while executing TwiML 182 :param unicode sms_method: The HTTP method to use with sms url 183 :param unicode sms_url: The URL we should call when the new phone number receives an incoming SMS message 184 :param unicode status_callback: The URL we should call to send status information to your application 185 :param unicode status_callback_method: HTTP method we should use to call status_callback 186 :param unicode voice_application_sid: The SID of the application to handle the new phone number 187 :param bool voice_caller_id_lookup: Whether to lookup the caller's name 188 :param unicode voice_fallback_method: The HTTP method used with voice_fallback_url 189 :param unicode voice_fallback_url: The URL we will call when an error occurs in TwiML 190 :param unicode voice_method: The HTTP method used with the voice_url 191 :param unicode voice_url: The URL we should call when the phone number receives a call 192 :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: Displays if emergency calling is enabled for this number. 193 :param unicode emergency_address_sid: The emergency address configuration to use for emergency calling 194 :param unicode trunk_sid: SID of the trunk to handle calls to the new phone number 195 :param unicode identity_sid: The SID of the Identity resource to associate with the new phone number 196 :param unicode address_sid: The SID of the Address resource associated with the phone number 197 :param IncomingPhoneNumberInstance.VoiceReceiveMode voice_receive_mode: Incoming call type: fax or voice 198 :param unicode bundle_sid: The SID of the Bundle resource associated with number 199 :param unicode phone_number: The phone number to purchase in E.164 format 200 :param unicode area_code: The desired area code for the new phone number 201 202 :returns: The created IncomingPhoneNumberInstance 203 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 204 """ 205 data = values.of({ 206 'PhoneNumber': phone_number, 207 'AreaCode': area_code, 208 'ApiVersion': api_version, 209 'FriendlyName': friendly_name, 210 'SmsApplicationSid': sms_application_sid, 211 'SmsFallbackMethod': sms_fallback_method, 212 'SmsFallbackUrl': sms_fallback_url, 213 'SmsMethod': sms_method, 214 'SmsUrl': sms_url, 215 'StatusCallback': status_callback, 216 'StatusCallbackMethod': status_callback_method, 217 'VoiceApplicationSid': voice_application_sid, 218 'VoiceCallerIdLookup': voice_caller_id_lookup, 219 'VoiceFallbackMethod': voice_fallback_method, 220 'VoiceFallbackUrl': voice_fallback_url, 221 'VoiceMethod': voice_method, 222 'VoiceUrl': voice_url, 223 'EmergencyStatus': emergency_status, 224 'EmergencyAddressSid': emergency_address_sid, 225 'TrunkSid': trunk_sid, 226 'IdentitySid': identity_sid, 227 'AddressSid': address_sid, 228 'VoiceReceiveMode': voice_receive_mode, 229 'BundleSid': bundle_sid, 230 }) 231 232 payload = self._version.create(method='POST', uri=self._uri, data=data, ) 233 234 return IncomingPhoneNumberInstance( 235 self._version, 236 payload, 237 account_sid=self._solution['account_sid'], 238 ) 239 240 @property 241 def local(self): 242 """ 243 Access the local 244 245 :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList 246 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList 247 """ 248 if self._local is None: 249 self._local = LocalList(self._version, account_sid=self._solution['account_sid'], ) 250 return self._local 251 252 @property 253 def mobile(self): 254 """ 255 Access the mobile 256 257 :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList 258 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList 259 """ 260 if self._mobile is None: 261 self._mobile = MobileList(self._version, account_sid=self._solution['account_sid'], ) 262 return self._mobile 263 264 @property 265 def toll_free(self): 266 """ 267 Access the toll_free 268 269 :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList 270 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList 271 """ 272 if self._toll_free is None: 273 self._toll_free = TollFreeList(self._version, account_sid=self._solution['account_sid'], ) 274 return self._toll_free 275 276 def get(self, sid): 277 """ 278 Constructs a IncomingPhoneNumberContext 279 280 :param sid: The unique string that identifies the resource 281 282 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 283 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 284 """ 285 return IncomingPhoneNumberContext(self._version, account_sid=self._solution['account_sid'], sid=sid, ) 286 287 def __call__(self, sid): 288 """ 289 Constructs a IncomingPhoneNumberContext 290 291 :param sid: The unique string that identifies the resource 292 293 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 294 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 295 """ 296 return IncomingPhoneNumberContext(self._version, account_sid=self._solution['account_sid'], sid=sid, ) 297 298 def __repr__(self): 299 """ 300 Provide a friendly representation 301 302 :returns: Machine friendly representation 303 :rtype: str 304 """ 305 return '<Twilio.Api.V2010.IncomingPhoneNumberList>' 306 307 308class IncomingPhoneNumberPage(Page): 309 310 def __init__(self, version, response, solution): 311 """ 312 Initialize the IncomingPhoneNumberPage 313 314 :param Version version: Version that contains the resource 315 :param Response response: Response from the API 316 :param account_sid: The SID of the Account that created the resource 317 318 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage 319 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage 320 """ 321 super(IncomingPhoneNumberPage, self).__init__(version, response) 322 323 # Path Solution 324 self._solution = solution 325 326 def get_instance(self, payload): 327 """ 328 Build an instance of IncomingPhoneNumberInstance 329 330 :param dict payload: Payload response from the API 331 332 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 333 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 334 """ 335 return IncomingPhoneNumberInstance( 336 self._version, 337 payload, 338 account_sid=self._solution['account_sid'], 339 ) 340 341 def __repr__(self): 342 """ 343 Provide a friendly representation 344 345 :returns: Machine friendly representation 346 :rtype: str 347 """ 348 return '<Twilio.Api.V2010.IncomingPhoneNumberPage>' 349 350 351class IncomingPhoneNumberContext(InstanceContext): 352 353 def __init__(self, version, account_sid, sid): 354 """ 355 Initialize the IncomingPhoneNumberContext 356 357 :param Version version: Version that contains the resource 358 :param account_sid: The SID of the Account that created the resource to fetch 359 :param sid: The unique string that identifies the resource 360 361 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 362 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 363 """ 364 super(IncomingPhoneNumberContext, self).__init__(version) 365 366 # Path Solution 367 self._solution = {'account_sid': account_sid, 'sid': sid, } 368 self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{sid}.json'.format(**self._solution) 369 370 # Dependents 371 self._assigned_add_ons = None 372 373 def update(self, account_sid=values.unset, api_version=values.unset, 374 friendly_name=values.unset, sms_application_sid=values.unset, 375 sms_fallback_method=values.unset, sms_fallback_url=values.unset, 376 sms_method=values.unset, sms_url=values.unset, 377 status_callback=values.unset, status_callback_method=values.unset, 378 voice_application_sid=values.unset, 379 voice_caller_id_lookup=values.unset, 380 voice_fallback_method=values.unset, voice_fallback_url=values.unset, 381 voice_method=values.unset, voice_url=values.unset, 382 emergency_status=values.unset, emergency_address_sid=values.unset, 383 trunk_sid=values.unset, voice_receive_mode=values.unset, 384 identity_sid=values.unset, address_sid=values.unset, 385 bundle_sid=values.unset): 386 """ 387 Update the IncomingPhoneNumberInstance 388 389 :param unicode account_sid: The SID of the Account that created the resource to update 390 :param unicode api_version: The API version to use for incoming calls made to the phone number 391 :param unicode friendly_name: A string to describe the resource 392 :param unicode sms_application_sid: Unique string that identifies the application 393 :param unicode sms_fallback_method: HTTP method used with sms_fallback_url 394 :param unicode sms_fallback_url: The URL we call when an error occurs while executing TwiML 395 :param unicode sms_method: The HTTP method to use with sms_url 396 :param unicode sms_url: The URL we should call when the phone number receives an incoming SMS message 397 :param unicode status_callback: The URL we should call to send status information to your application 398 :param unicode status_callback_method: The HTTP method we should use to call status_callback 399 :param unicode voice_application_sid: The SID of the application to handle the phone number 400 :param bool voice_caller_id_lookup: Whether to lookup the caller's name 401 :param unicode voice_fallback_method: The HTTP method used with fallback_url 402 :param unicode voice_fallback_url: The URL we will call when an error occurs in TwiML 403 :param unicode voice_method: The HTTP method used with the voice_url 404 :param unicode voice_url: The URL we should call when the phone number receives a call 405 :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: Displays if emergency calling is enabled for this number. 406 :param unicode emergency_address_sid: The emergency address configuration to use for emergency calling 407 :param unicode trunk_sid: SID of the trunk to handle phone calls to the phone number 408 :param IncomingPhoneNumberInstance.VoiceReceiveMode voice_receive_mode: Incoming call type: fax or voice 409 :param unicode identity_sid: Unique string that identifies the identity associated with number 410 :param unicode address_sid: The SID of the Address resource associated with the phone number 411 :param unicode bundle_sid: The SID of the Bundle resource associated with number 412 413 :returns: The updated IncomingPhoneNumberInstance 414 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 415 """ 416 data = values.of({ 417 'AccountSid': account_sid, 418 'ApiVersion': api_version, 419 'FriendlyName': friendly_name, 420 'SmsApplicationSid': sms_application_sid, 421 'SmsFallbackMethod': sms_fallback_method, 422 'SmsFallbackUrl': sms_fallback_url, 423 'SmsMethod': sms_method, 424 'SmsUrl': sms_url, 425 'StatusCallback': status_callback, 426 'StatusCallbackMethod': status_callback_method, 427 'VoiceApplicationSid': voice_application_sid, 428 'VoiceCallerIdLookup': voice_caller_id_lookup, 429 'VoiceFallbackMethod': voice_fallback_method, 430 'VoiceFallbackUrl': voice_fallback_url, 431 'VoiceMethod': voice_method, 432 'VoiceUrl': voice_url, 433 'EmergencyStatus': emergency_status, 434 'EmergencyAddressSid': emergency_address_sid, 435 'TrunkSid': trunk_sid, 436 'VoiceReceiveMode': voice_receive_mode, 437 'IdentitySid': identity_sid, 438 'AddressSid': address_sid, 439 'BundleSid': bundle_sid, 440 }) 441 442 payload = self._version.update(method='POST', uri=self._uri, data=data, ) 443 444 return IncomingPhoneNumberInstance( 445 self._version, 446 payload, 447 account_sid=self._solution['account_sid'], 448 sid=self._solution['sid'], 449 ) 450 451 def fetch(self): 452 """ 453 Fetch the IncomingPhoneNumberInstance 454 455 :returns: The fetched IncomingPhoneNumberInstance 456 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 457 """ 458 payload = self._version.fetch(method='GET', uri=self._uri, ) 459 460 return IncomingPhoneNumberInstance( 461 self._version, 462 payload, 463 account_sid=self._solution['account_sid'], 464 sid=self._solution['sid'], 465 ) 466 467 def delete(self): 468 """ 469 Deletes the IncomingPhoneNumberInstance 470 471 :returns: True if delete succeeds, False otherwise 472 :rtype: bool 473 """ 474 return self._version.delete(method='DELETE', uri=self._uri, ) 475 476 @property 477 def assigned_add_ons(self): 478 """ 479 Access the assigned_add_ons 480 481 :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList 482 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList 483 """ 484 if self._assigned_add_ons is None: 485 self._assigned_add_ons = AssignedAddOnList( 486 self._version, 487 account_sid=self._solution['account_sid'], 488 resource_sid=self._solution['sid'], 489 ) 490 return self._assigned_add_ons 491 492 def __repr__(self): 493 """ 494 Provide a friendly representation 495 496 :returns: Machine friendly representation 497 :rtype: str 498 """ 499 context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) 500 return '<Twilio.Api.V2010.IncomingPhoneNumberContext {}>'.format(context) 501 502 503class IncomingPhoneNumberInstance(InstanceResource): 504 505 class AddressRequirement(object): 506 NONE = "none" 507 ANY = "any" 508 LOCAL = "local" 509 FOREIGN = "foreign" 510 511 class EmergencyStatus(object): 512 ACTIVE = "Active" 513 INACTIVE = "Inactive" 514 515 class EmergencyAddressStatus(object): 516 REGISTERED = "registered" 517 UNREGISTERED = "unregistered" 518 PENDING_REGISTRATION = "pending-registration" 519 REGISTRATION_FAILURE = "registration-failure" 520 PENDING_UNREGISTRATION = "pending-unregistration" 521 UNREGISTRATION_FAILURE = "unregistration-failure" 522 523 class VoiceReceiveMode(object): 524 VOICE = "voice" 525 FAX = "fax" 526 527 def __init__(self, version, payload, account_sid, sid=None): 528 """ 529 Initialize the IncomingPhoneNumberInstance 530 531 :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 532 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 533 """ 534 super(IncomingPhoneNumberInstance, self).__init__(version) 535 536 # Marshaled Properties 537 self._properties = { 538 'account_sid': payload.get('account_sid'), 539 'address_sid': payload.get('address_sid'), 540 'address_requirements': payload.get('address_requirements'), 541 'api_version': payload.get('api_version'), 542 'beta': payload.get('beta'), 543 'capabilities': payload.get('capabilities'), 544 'date_created': deserialize.rfc2822_datetime(payload.get('date_created')), 545 'date_updated': deserialize.rfc2822_datetime(payload.get('date_updated')), 546 'friendly_name': payload.get('friendly_name'), 547 'identity_sid': payload.get('identity_sid'), 548 'phone_number': payload.get('phone_number'), 549 'origin': payload.get('origin'), 550 'sid': payload.get('sid'), 551 'sms_application_sid': payload.get('sms_application_sid'), 552 'sms_fallback_method': payload.get('sms_fallback_method'), 553 'sms_fallback_url': payload.get('sms_fallback_url'), 554 'sms_method': payload.get('sms_method'), 555 'sms_url': payload.get('sms_url'), 556 'status_callback': payload.get('status_callback'), 557 'status_callback_method': payload.get('status_callback_method'), 558 'trunk_sid': payload.get('trunk_sid'), 559 'uri': payload.get('uri'), 560 'voice_receive_mode': payload.get('voice_receive_mode'), 561 'voice_application_sid': payload.get('voice_application_sid'), 562 'voice_caller_id_lookup': payload.get('voice_caller_id_lookup'), 563 'voice_fallback_method': payload.get('voice_fallback_method'), 564 'voice_fallback_url': payload.get('voice_fallback_url'), 565 'voice_method': payload.get('voice_method'), 566 'voice_url': payload.get('voice_url'), 567 'emergency_status': payload.get('emergency_status'), 568 'emergency_address_sid': payload.get('emergency_address_sid'), 569 'emergency_address_status': payload.get('emergency_address_status'), 570 'bundle_sid': payload.get('bundle_sid'), 571 'status': payload.get('status'), 572 } 573 574 # Context 575 self._context = None 576 self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'], } 577 578 @property 579 def _proxy(self): 580 """ 581 Generate an instance context for the instance, the context is capable of 582 performing various actions. All instance actions are proxied to the context 583 584 :returns: IncomingPhoneNumberContext for this IncomingPhoneNumberInstance 585 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext 586 """ 587 if self._context is None: 588 self._context = IncomingPhoneNumberContext( 589 self._version, 590 account_sid=self._solution['account_sid'], 591 sid=self._solution['sid'], 592 ) 593 return self._context 594 595 @property 596 def account_sid(self): 597 """ 598 :returns: The SID of the Account that created the resource 599 :rtype: unicode 600 """ 601 return self._properties['account_sid'] 602 603 @property 604 def address_sid(self): 605 """ 606 :returns: The SID of the Address resource associated with the phone number 607 :rtype: unicode 608 """ 609 return self._properties['address_sid'] 610 611 @property 612 def address_requirements(self): 613 """ 614 :returns: Whether the phone number requires an Address registered with Twilio. 615 :rtype: IncomingPhoneNumberInstance.AddressRequirement 616 """ 617 return self._properties['address_requirements'] 618 619 @property 620 def api_version(self): 621 """ 622 :returns: The API version used to start a new TwiML session 623 :rtype: unicode 624 """ 625 return self._properties['api_version'] 626 627 @property 628 def beta(self): 629 """ 630 :returns: Whether the phone number is new to the Twilio platform 631 :rtype: bool 632 """ 633 return self._properties['beta'] 634 635 @property 636 def capabilities(self): 637 """ 638 :returns: Indicate if a phone can receive calls or messages 639 :rtype: unicode 640 """ 641 return self._properties['capabilities'] 642 643 @property 644 def date_created(self): 645 """ 646 :returns: The RFC 2822 date and time in GMT that the resource was created 647 :rtype: datetime 648 """ 649 return self._properties['date_created'] 650 651 @property 652 def date_updated(self): 653 """ 654 :returns: The RFC 2822 date and time in GMT that the resource was last updated 655 :rtype: datetime 656 """ 657 return self._properties['date_updated'] 658 659 @property 660 def friendly_name(self): 661 """ 662 :returns: The string that you assigned to describe the resource 663 :rtype: unicode 664 """ 665 return self._properties['friendly_name'] 666 667 @property 668 def identity_sid(self): 669 """ 670 :returns: The SID of the Identity resource associated with number 671 :rtype: unicode 672 """ 673 return self._properties['identity_sid'] 674 675 @property 676 def phone_number(self): 677 """ 678 :returns: The phone number in E.164 format 679 :rtype: unicode 680 """ 681 return self._properties['phone_number'] 682 683 @property 684 def origin(self): 685 """ 686 :returns: The phone number's origin. Can be twilio or hosted. 687 :rtype: unicode 688 """ 689 return self._properties['origin'] 690 691 @property 692 def sid(self): 693 """ 694 :returns: The unique string that identifies the resource 695 :rtype: unicode 696 """ 697 return self._properties['sid'] 698 699 @property 700 def sms_application_sid(self): 701 """ 702 :returns: The SID of the application that handles SMS messages sent to the phone number 703 :rtype: unicode 704 """ 705 return self._properties['sms_application_sid'] 706 707 @property 708 def sms_fallback_method(self): 709 """ 710 :returns: The HTTP method used with sms_fallback_url 711 :rtype: unicode 712 """ 713 return self._properties['sms_fallback_method'] 714 715 @property 716 def sms_fallback_url(self): 717 """ 718 :returns: The URL that we call when an error occurs while retrieving or executing the TwiML 719 :rtype: unicode 720 """ 721 return self._properties['sms_fallback_url'] 722 723 @property 724 def sms_method(self): 725 """ 726 :returns: The HTTP method to use with sms_url 727 :rtype: unicode 728 """ 729 return self._properties['sms_method'] 730 731 @property 732 def sms_url(self): 733 """ 734 :returns: The URL we call when the phone number receives an incoming SMS message 735 :rtype: unicode 736 """ 737 return self._properties['sms_url'] 738 739 @property 740 def status_callback(self): 741 """ 742 :returns: The URL to send status information to your application 743 :rtype: unicode 744 """ 745 return self._properties['status_callback'] 746 747 @property 748 def status_callback_method(self): 749 """ 750 :returns: The HTTP method we use to call status_callback 751 :rtype: unicode 752 """ 753 return self._properties['status_callback_method'] 754 755 @property 756 def trunk_sid(self): 757 """ 758 :returns: The SID of the Trunk that handles calls to the phone number 759 :rtype: unicode 760 """ 761 return self._properties['trunk_sid'] 762 763 @property 764 def uri(self): 765 """ 766 :returns: The URI of the resource, relative to `https://api.twilio.com` 767 :rtype: unicode 768 """ 769 return self._properties['uri'] 770 771 @property 772 def voice_receive_mode(self): 773 """ 774 :returns: The voice_receive_mode 775 :rtype: IncomingPhoneNumberInstance.VoiceReceiveMode 776 """ 777 return self._properties['voice_receive_mode'] 778 779 @property 780 def voice_application_sid(self): 781 """ 782 :returns: The SID of the application that handles calls to the phone number 783 :rtype: unicode 784 """ 785 return self._properties['voice_application_sid'] 786 787 @property 788 def voice_caller_id_lookup(self): 789 """ 790 :returns: Whether to lookup the caller's name 791 :rtype: bool 792 """ 793 return self._properties['voice_caller_id_lookup'] 794 795 @property 796 def voice_fallback_method(self): 797 """ 798 :returns: The HTTP method used with voice_fallback_url 799 :rtype: unicode 800 """ 801 return self._properties['voice_fallback_method'] 802 803 @property 804 def voice_fallback_url(self): 805 """ 806 :returns: The URL we call when an error occurs in TwiML 807 :rtype: unicode 808 """ 809 return self._properties['voice_fallback_url'] 810 811 @property 812 def voice_method(self): 813 """ 814 :returns: The HTTP method used with the voice_url 815 :rtype: unicode 816 """ 817 return self._properties['voice_method'] 818 819 @property 820 def voice_url(self): 821 """ 822 :returns: The URL we call when the phone number receives a call 823 :rtype: unicode 824 """ 825 return self._properties['voice_url'] 826 827 @property 828 def emergency_status(self): 829 """ 830 :returns: Displays if emergency calling is enabled for this number. 831 :rtype: IncomingPhoneNumberInstance.EmergencyStatus 832 """ 833 return self._properties['emergency_status'] 834 835 @property 836 def emergency_address_sid(self): 837 """ 838 :returns: The emergency address configuration to use for emergency calling 839 :rtype: unicode 840 """ 841 return self._properties['emergency_address_sid'] 842 843 @property 844 def emergency_address_status(self): 845 """ 846 :returns: State of the emergency address configuration for the phone number 847 :rtype: IncomingPhoneNumberInstance.EmergencyAddressStatus 848 """ 849 return self._properties['emergency_address_status'] 850 851 @property 852 def bundle_sid(self): 853 """ 854 :returns: The SID of the Bundle resource associated with number 855 :rtype: unicode 856 """ 857 return self._properties['bundle_sid'] 858 859 @property 860 def status(self): 861 """ 862 :returns: The status 863 :rtype: unicode 864 """ 865 return self._properties['status'] 866 867 def update(self, account_sid=values.unset, api_version=values.unset, 868 friendly_name=values.unset, sms_application_sid=values.unset, 869 sms_fallback_method=values.unset, sms_fallback_url=values.unset, 870 sms_method=values.unset, sms_url=values.unset, 871 status_callback=values.unset, status_callback_method=values.unset, 872 voice_application_sid=values.unset, 873 voice_caller_id_lookup=values.unset, 874 voice_fallback_method=values.unset, voice_fallback_url=values.unset, 875 voice_method=values.unset, voice_url=values.unset, 876 emergency_status=values.unset, emergency_address_sid=values.unset, 877 trunk_sid=values.unset, voice_receive_mode=values.unset, 878 identity_sid=values.unset, address_sid=values.unset, 879 bundle_sid=values.unset): 880 """ 881 Update the IncomingPhoneNumberInstance 882 883 :param unicode account_sid: The SID of the Account that created the resource to update 884 :param unicode api_version: The API version to use for incoming calls made to the phone number 885 :param unicode friendly_name: A string to describe the resource 886 :param unicode sms_application_sid: Unique string that identifies the application 887 :param unicode sms_fallback_method: HTTP method used with sms_fallback_url 888 :param unicode sms_fallback_url: The URL we call when an error occurs while executing TwiML 889 :param unicode sms_method: The HTTP method to use with sms_url 890 :param unicode sms_url: The URL we should call when the phone number receives an incoming SMS message 891 :param unicode status_callback: The URL we should call to send status information to your application 892 :param unicode status_callback_method: The HTTP method we should use to call status_callback 893 :param unicode voice_application_sid: The SID of the application to handle the phone number 894 :param bool voice_caller_id_lookup: Whether to lookup the caller's name 895 :param unicode voice_fallback_method: The HTTP method used with fallback_url 896 :param unicode voice_fallback_url: The URL we will call when an error occurs in TwiML 897 :param unicode voice_method: The HTTP method used with the voice_url 898 :param unicode voice_url: The URL we should call when the phone number receives a call 899 :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: Displays if emergency calling is enabled for this number. 900 :param unicode emergency_address_sid: The emergency address configuration to use for emergency calling 901 :param unicode trunk_sid: SID of the trunk to handle phone calls to the phone number 902 :param IncomingPhoneNumberInstance.VoiceReceiveMode voice_receive_mode: Incoming call type: fax or voice 903 :param unicode identity_sid: Unique string that identifies the identity associated with number 904 :param unicode address_sid: The SID of the Address resource associated with the phone number 905 :param unicode bundle_sid: The SID of the Bundle resource associated with number 906 907 :returns: The updated IncomingPhoneNumberInstance 908 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 909 """ 910 return self._proxy.update( 911 account_sid=account_sid, 912 api_version=api_version, 913 friendly_name=friendly_name, 914 sms_application_sid=sms_application_sid, 915 sms_fallback_method=sms_fallback_method, 916 sms_fallback_url=sms_fallback_url, 917 sms_method=sms_method, 918 sms_url=sms_url, 919 status_callback=status_callback, 920 status_callback_method=status_callback_method, 921 voice_application_sid=voice_application_sid, 922 voice_caller_id_lookup=voice_caller_id_lookup, 923 voice_fallback_method=voice_fallback_method, 924 voice_fallback_url=voice_fallback_url, 925 voice_method=voice_method, 926 voice_url=voice_url, 927 emergency_status=emergency_status, 928 emergency_address_sid=emergency_address_sid, 929 trunk_sid=trunk_sid, 930 voice_receive_mode=voice_receive_mode, 931 identity_sid=identity_sid, 932 address_sid=address_sid, 933 bundle_sid=bundle_sid, 934 ) 935 936 def fetch(self): 937 """ 938 Fetch the IncomingPhoneNumberInstance 939 940 :returns: The fetched IncomingPhoneNumberInstance 941 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance 942 """ 943 return self._proxy.fetch() 944 945 def delete(self): 946 """ 947 Deletes the IncomingPhoneNumberInstance 948 949 :returns: True if delete succeeds, False otherwise 950 :rtype: bool 951 """ 952 return self._proxy.delete() 953 954 @property 955 def assigned_add_ons(self): 956 """ 957 Access the assigned_add_ons 958 959 :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList 960 :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList 961 """ 962 return self._proxy.assigned_add_ons 963 964 def __repr__(self): 965 """ 966 Provide a friendly representation 967 968 :returns: Machine friendly representation 969 :rtype: str 970 """ 971 context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) 972 return '<Twilio.Api.V2010.IncomingPhoneNumberInstance {}>'.format(context) 973