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.numbers.v2.regulatory_compliance.bundle.bundle_copy import BundleCopyList 16from twilio.rest.numbers.v2.regulatory_compliance.bundle.evaluation import EvaluationList 17from twilio.rest.numbers.v2.regulatory_compliance.bundle.item_assignment import ItemAssignmentList 18from twilio.rest.numbers.v2.regulatory_compliance.bundle.replace_items import ReplaceItemsList 19 20 21class BundleList(ListResource): 22 23 def __init__(self, version): 24 """ 25 Initialize the BundleList 26 27 :param Version version: Version that contains the resource 28 29 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleList 30 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleList 31 """ 32 super(BundleList, self).__init__(version) 33 34 # Path Solution 35 self._solution = {} 36 self._uri = '/RegulatoryCompliance/Bundles'.format(**self._solution) 37 38 def create(self, friendly_name, email, status_callback=values.unset, 39 regulation_sid=values.unset, iso_country=values.unset, 40 end_user_type=values.unset, number_type=values.unset): 41 """ 42 Create the BundleInstance 43 44 :param unicode friendly_name: The string that you assigned to describe the resource 45 :param unicode email: The email address 46 :param unicode status_callback: The URL we call to inform your application of status changes. 47 :param unicode regulation_sid: The unique string of a regulation. 48 :param unicode iso_country: The ISO country code of the country 49 :param BundleInstance.EndUserType end_user_type: The type of End User of the Bundle resource 50 :param unicode number_type: The type of phone number 51 52 :returns: The created BundleInstance 53 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 54 """ 55 data = values.of({ 56 'FriendlyName': friendly_name, 57 'Email': email, 58 'StatusCallback': status_callback, 59 'RegulationSid': regulation_sid, 60 'IsoCountry': iso_country, 61 'EndUserType': end_user_type, 62 'NumberType': number_type, 63 }) 64 65 payload = self._version.create(method='POST', uri=self._uri, data=data, ) 66 67 return BundleInstance(self._version, payload, ) 68 69 def stream(self, status=values.unset, friendly_name=values.unset, 70 regulation_sid=values.unset, iso_country=values.unset, 71 number_type=values.unset, limit=None, page_size=None): 72 """ 73 Streams BundleInstance records from the API as a generator stream. 74 This operation lazily loads records as efficiently as possible until the limit 75 is reached. 76 The results are returned as a generator, so this operation is memory efficient. 77 78 :param BundleInstance.Status status: The verification status of the Bundle resource 79 :param unicode friendly_name: The string that you assigned to describe the resource 80 :param unicode regulation_sid: The unique string of a regulation. 81 :param unicode iso_country: The ISO country code of the country 82 :param unicode number_type: The type of phone number 83 :param int limit: Upper limit for the number of records to return. stream() 84 guarantees to never return more than limit. Default is no limit 85 :param int page_size: Number of records to fetch per request, when not set will use 86 the default value of 50 records. If no page_size is defined 87 but a limit is defined, stream() will attempt to read the 88 limit with the most efficient page size, i.e. min(limit, 1000) 89 90 :returns: Generator that will yield up to limit results 91 :rtype: list[twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance] 92 """ 93 limits = self._version.read_limits(limit, page_size) 94 95 page = self.page( 96 status=status, 97 friendly_name=friendly_name, 98 regulation_sid=regulation_sid, 99 iso_country=iso_country, 100 number_type=number_type, 101 page_size=limits['page_size'], 102 ) 103 104 return self._version.stream(page, limits['limit']) 105 106 def list(self, status=values.unset, friendly_name=values.unset, 107 regulation_sid=values.unset, iso_country=values.unset, 108 number_type=values.unset, limit=None, page_size=None): 109 """ 110 Lists BundleInstance records from the API as a list. 111 Unlike stream(), this operation is eager and will load `limit` records into 112 memory before returning. 113 114 :param BundleInstance.Status status: The verification status of the Bundle resource 115 :param unicode friendly_name: The string that you assigned to describe the resource 116 :param unicode regulation_sid: The unique string of a regulation. 117 :param unicode iso_country: The ISO country code of the country 118 :param unicode number_type: The type of phone number 119 :param int limit: Upper limit for the number of records to return. list() guarantees 120 never to return more than limit. Default is no limit 121 :param int page_size: Number of records to fetch per request, when not set will use 122 the default value of 50 records. If no page_size is defined 123 but a limit is defined, list() will attempt to read the limit 124 with the most efficient page size, i.e. min(limit, 1000) 125 126 :returns: Generator that will yield up to limit results 127 :rtype: list[twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance] 128 """ 129 return list(self.stream( 130 status=status, 131 friendly_name=friendly_name, 132 regulation_sid=regulation_sid, 133 iso_country=iso_country, 134 number_type=number_type, 135 limit=limit, 136 page_size=page_size, 137 )) 138 139 def page(self, status=values.unset, friendly_name=values.unset, 140 regulation_sid=values.unset, iso_country=values.unset, 141 number_type=values.unset, page_token=values.unset, 142 page_number=values.unset, page_size=values.unset): 143 """ 144 Retrieve a single page of BundleInstance records from the API. 145 Request is executed immediately 146 147 :param BundleInstance.Status status: The verification status of the Bundle resource 148 :param unicode friendly_name: The string that you assigned to describe the resource 149 :param unicode regulation_sid: The unique string of a regulation. 150 :param unicode iso_country: The ISO country code of the country 151 :param unicode number_type: The type of phone number 152 :param str page_token: PageToken provided by the API 153 :param int page_number: Page Number, this value is simply for client state 154 :param int page_size: Number of records to return, defaults to 50 155 156 :returns: Page of BundleInstance 157 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundlePage 158 """ 159 data = values.of({ 160 'Status': status, 161 'FriendlyName': friendly_name, 162 'RegulationSid': regulation_sid, 163 'IsoCountry': iso_country, 164 'NumberType': number_type, 165 'PageToken': page_token, 166 'Page': page_number, 167 'PageSize': page_size, 168 }) 169 170 response = self._version.page(method='GET', uri=self._uri, params=data, ) 171 172 return BundlePage(self._version, response, self._solution) 173 174 def get_page(self, target_url): 175 """ 176 Retrieve a specific page of BundleInstance records from the API. 177 Request is executed immediately 178 179 :param str target_url: API-generated URL for the requested results page 180 181 :returns: Page of BundleInstance 182 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundlePage 183 """ 184 response = self._version.domain.twilio.request( 185 'GET', 186 target_url, 187 ) 188 189 return BundlePage(self._version, response, self._solution) 190 191 def get(self, sid): 192 """ 193 Constructs a BundleContext 194 195 :param sid: The unique string that identifies the resource. 196 197 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 198 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 199 """ 200 return BundleContext(self._version, sid=sid, ) 201 202 def __call__(self, sid): 203 """ 204 Constructs a BundleContext 205 206 :param sid: The unique string that identifies the resource. 207 208 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 209 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 210 """ 211 return BundleContext(self._version, sid=sid, ) 212 213 def __repr__(self): 214 """ 215 Provide a friendly representation 216 217 :returns: Machine friendly representation 218 :rtype: str 219 """ 220 return '<Twilio.Numbers.V2.BundleList>' 221 222 223class BundlePage(Page): 224 225 def __init__(self, version, response, solution): 226 """ 227 Initialize the BundlePage 228 229 :param Version version: Version that contains the resource 230 :param Response response: Response from the API 231 232 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundlePage 233 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundlePage 234 """ 235 super(BundlePage, self).__init__(version, response) 236 237 # Path Solution 238 self._solution = solution 239 240 def get_instance(self, payload): 241 """ 242 Build an instance of BundleInstance 243 244 :param dict payload: Payload response from the API 245 246 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 247 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 248 """ 249 return BundleInstance(self._version, payload, ) 250 251 def __repr__(self): 252 """ 253 Provide a friendly representation 254 255 :returns: Machine friendly representation 256 :rtype: str 257 """ 258 return '<Twilio.Numbers.V2.BundlePage>' 259 260 261class BundleContext(InstanceContext): 262 263 def __init__(self, version, sid): 264 """ 265 Initialize the BundleContext 266 267 :param Version version: Version that contains the resource 268 :param sid: The unique string that identifies the resource. 269 270 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 271 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 272 """ 273 super(BundleContext, self).__init__(version) 274 275 # Path Solution 276 self._solution = {'sid': sid, } 277 self._uri = '/RegulatoryCompliance/Bundles/{sid}'.format(**self._solution) 278 279 # Dependents 280 self._evaluations = None 281 self._item_assignments = None 282 self._bundle_copies = None 283 self._replace_items = None 284 285 def fetch(self): 286 """ 287 Fetch the BundleInstance 288 289 :returns: The fetched BundleInstance 290 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 291 """ 292 payload = self._version.fetch(method='GET', uri=self._uri, ) 293 294 return BundleInstance(self._version, payload, sid=self._solution['sid'], ) 295 296 def update(self, status=values.unset, status_callback=values.unset, 297 friendly_name=values.unset, email=values.unset): 298 """ 299 Update the BundleInstance 300 301 :param BundleInstance.Status status: The verification status of the Bundle resource 302 :param unicode status_callback: The URL we call to inform your application of status changes. 303 :param unicode friendly_name: The string that you assigned to describe the resource 304 :param unicode email: The email address 305 306 :returns: The updated BundleInstance 307 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 308 """ 309 data = values.of({ 310 'Status': status, 311 'StatusCallback': status_callback, 312 'FriendlyName': friendly_name, 313 'Email': email, 314 }) 315 316 payload = self._version.update(method='POST', uri=self._uri, data=data, ) 317 318 return BundleInstance(self._version, payload, sid=self._solution['sid'], ) 319 320 def delete(self): 321 """ 322 Deletes the BundleInstance 323 324 :returns: True if delete succeeds, False otherwise 325 :rtype: bool 326 """ 327 return self._version.delete(method='DELETE', uri=self._uri, ) 328 329 @property 330 def evaluations(self): 331 """ 332 Access the evaluations 333 334 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.evaluation.EvaluationList 335 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.evaluation.EvaluationList 336 """ 337 if self._evaluations is None: 338 self._evaluations = EvaluationList(self._version, bundle_sid=self._solution['sid'], ) 339 return self._evaluations 340 341 @property 342 def item_assignments(self): 343 """ 344 Access the item_assignments 345 346 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.item_assignment.ItemAssignmentList 347 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.item_assignment.ItemAssignmentList 348 """ 349 if self._item_assignments is None: 350 self._item_assignments = ItemAssignmentList(self._version, bundle_sid=self._solution['sid'], ) 351 return self._item_assignments 352 353 @property 354 def bundle_copies(self): 355 """ 356 Access the bundle_copies 357 358 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.bundle_copy.BundleCopyList 359 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.bundle_copy.BundleCopyList 360 """ 361 if self._bundle_copies is None: 362 self._bundle_copies = BundleCopyList(self._version, bundle_sid=self._solution['sid'], ) 363 return self._bundle_copies 364 365 @property 366 def replace_items(self): 367 """ 368 Access the replace_items 369 370 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.replace_items.ReplaceItemsList 371 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.replace_items.ReplaceItemsList 372 """ 373 if self._replace_items is None: 374 self._replace_items = ReplaceItemsList(self._version, bundle_sid=self._solution['sid'], ) 375 return self._replace_items 376 377 def __repr__(self): 378 """ 379 Provide a friendly representation 380 381 :returns: Machine friendly representation 382 :rtype: str 383 """ 384 context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) 385 return '<Twilio.Numbers.V2.BundleContext {}>'.format(context) 386 387 388class BundleInstance(InstanceResource): 389 390 class Status(object): 391 DRAFT = "draft" 392 PENDING_REVIEW = "pending-review" 393 IN_REVIEW = "in-review" 394 TWILIO_REJECTED = "twilio-rejected" 395 TWILIO_APPROVED = "twilio-approved" 396 PROVISIONALLY_APPROVED = "provisionally-approved" 397 398 class EndUserType(object): 399 INDIVIDUAL = "individual" 400 BUSINESS = "business" 401 402 def __init__(self, version, payload, sid=None): 403 """ 404 Initialize the BundleInstance 405 406 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 407 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 408 """ 409 super(BundleInstance, self).__init__(version) 410 411 # Marshaled Properties 412 self._properties = { 413 'sid': payload.get('sid'), 414 'account_sid': payload.get('account_sid'), 415 'regulation_sid': payload.get('regulation_sid'), 416 'friendly_name': payload.get('friendly_name'), 417 'status': payload.get('status'), 418 'valid_until': deserialize.iso8601_datetime(payload.get('valid_until')), 419 'email': payload.get('email'), 420 'status_callback': payload.get('status_callback'), 421 'date_created': deserialize.iso8601_datetime(payload.get('date_created')), 422 'date_updated': deserialize.iso8601_datetime(payload.get('date_updated')), 423 'url': payload.get('url'), 424 'links': payload.get('links'), 425 } 426 427 # Context 428 self._context = None 429 self._solution = {'sid': sid or self._properties['sid'], } 430 431 @property 432 def _proxy(self): 433 """ 434 Generate an instance context for the instance, the context is capable of 435 performing various actions. All instance actions are proxied to the context 436 437 :returns: BundleContext for this BundleInstance 438 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleContext 439 """ 440 if self._context is None: 441 self._context = BundleContext(self._version, sid=self._solution['sid'], ) 442 return self._context 443 444 @property 445 def sid(self): 446 """ 447 :returns: The unique string that identifies the resource. 448 :rtype: unicode 449 """ 450 return self._properties['sid'] 451 452 @property 453 def account_sid(self): 454 """ 455 :returns: The SID of the Account that created the resource 456 :rtype: unicode 457 """ 458 return self._properties['account_sid'] 459 460 @property 461 def regulation_sid(self): 462 """ 463 :returns: The unique string of a regulation. 464 :rtype: unicode 465 """ 466 return self._properties['regulation_sid'] 467 468 @property 469 def friendly_name(self): 470 """ 471 :returns: The string that you assigned to describe the resource 472 :rtype: unicode 473 """ 474 return self._properties['friendly_name'] 475 476 @property 477 def status(self): 478 """ 479 :returns: The verification status of the Bundle resource 480 :rtype: BundleInstance.Status 481 """ 482 return self._properties['status'] 483 484 @property 485 def valid_until(self): 486 """ 487 :returns: The ISO 8601 date and time in GMT when the resource will be valid until. 488 :rtype: datetime 489 """ 490 return self._properties['valid_until'] 491 492 @property 493 def email(self): 494 """ 495 :returns: The email address 496 :rtype: unicode 497 """ 498 return self._properties['email'] 499 500 @property 501 def status_callback(self): 502 """ 503 :returns: The URL we call to inform your application of status changes. 504 :rtype: unicode 505 """ 506 return self._properties['status_callback'] 507 508 @property 509 def date_created(self): 510 """ 511 :returns: The ISO 8601 date and time in GMT when the resource was created 512 :rtype: datetime 513 """ 514 return self._properties['date_created'] 515 516 @property 517 def date_updated(self): 518 """ 519 :returns: The ISO 8601 date and time in GMT when the resource was last updated 520 :rtype: datetime 521 """ 522 return self._properties['date_updated'] 523 524 @property 525 def url(self): 526 """ 527 :returns: The absolute URL of the Bundle resource 528 :rtype: unicode 529 """ 530 return self._properties['url'] 531 532 @property 533 def links(self): 534 """ 535 :returns: The URLs of the Assigned Items of the Bundle resource 536 :rtype: unicode 537 """ 538 return self._properties['links'] 539 540 def fetch(self): 541 """ 542 Fetch the BundleInstance 543 544 :returns: The fetched BundleInstance 545 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 546 """ 547 return self._proxy.fetch() 548 549 def update(self, status=values.unset, status_callback=values.unset, 550 friendly_name=values.unset, email=values.unset): 551 """ 552 Update the BundleInstance 553 554 :param BundleInstance.Status status: The verification status of the Bundle resource 555 :param unicode status_callback: The URL we call to inform your application of status changes. 556 :param unicode friendly_name: The string that you assigned to describe the resource 557 :param unicode email: The email address 558 559 :returns: The updated BundleInstance 560 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.BundleInstance 561 """ 562 return self._proxy.update( 563 status=status, 564 status_callback=status_callback, 565 friendly_name=friendly_name, 566 email=email, 567 ) 568 569 def delete(self): 570 """ 571 Deletes the BundleInstance 572 573 :returns: True if delete succeeds, False otherwise 574 :rtype: bool 575 """ 576 return self._proxy.delete() 577 578 @property 579 def evaluations(self): 580 """ 581 Access the evaluations 582 583 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.evaluation.EvaluationList 584 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.evaluation.EvaluationList 585 """ 586 return self._proxy.evaluations 587 588 @property 589 def item_assignments(self): 590 """ 591 Access the item_assignments 592 593 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.item_assignment.ItemAssignmentList 594 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.item_assignment.ItemAssignmentList 595 """ 596 return self._proxy.item_assignments 597 598 @property 599 def bundle_copies(self): 600 """ 601 Access the bundle_copies 602 603 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.bundle_copy.BundleCopyList 604 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.bundle_copy.BundleCopyList 605 """ 606 return self._proxy.bundle_copies 607 608 @property 609 def replace_items(self): 610 """ 611 Access the replace_items 612 613 :returns: twilio.rest.numbers.v2.regulatory_compliance.bundle.replace_items.ReplaceItemsList 614 :rtype: twilio.rest.numbers.v2.regulatory_compliance.bundle.replace_items.ReplaceItemsList 615 """ 616 return self._proxy.replace_items 617 618 def __repr__(self): 619 """ 620 Provide a friendly representation 621 622 :returns: Machine friendly representation 623 :rtype: str 624 """ 625 context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) 626 return '<Twilio.Numbers.V2.BundleInstance {}>'.format(context) 627