File: __init__.py

package info (click to toggle)
python-twilio 6.51.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,260 kB
  • sloc: python: 128,982; makefile: 51
file content (1019 lines) | stat: -rw-r--r-- 33,859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# coding=utf-8
r"""
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
"""

from twilio.base import deserialize
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.page import Page
from twilio.rest.api.v2010.account.address import AddressList
from twilio.rest.api.v2010.account.application import ApplicationList
from twilio.rest.api.v2010.account.authorized_connect_app import AuthorizedConnectAppList
from twilio.rest.api.v2010.account.available_phone_number import AvailablePhoneNumberCountryList
from twilio.rest.api.v2010.account.balance import BalanceList
from twilio.rest.api.v2010.account.call import CallList
from twilio.rest.api.v2010.account.conference import ConferenceList
from twilio.rest.api.v2010.account.connect_app import ConnectAppList
from twilio.rest.api.v2010.account.incoming_phone_number import IncomingPhoneNumberList
from twilio.rest.api.v2010.account.key import KeyList
from twilio.rest.api.v2010.account.message import MessageList
from twilio.rest.api.v2010.account.new_key import NewKeyList
from twilio.rest.api.v2010.account.new_signing_key import NewSigningKeyList
from twilio.rest.api.v2010.account.notification import NotificationList
from twilio.rest.api.v2010.account.outgoing_caller_id import OutgoingCallerIdList
from twilio.rest.api.v2010.account.queue import QueueList
from twilio.rest.api.v2010.account.recording import RecordingList
from twilio.rest.api.v2010.account.short_code import ShortCodeList
from twilio.rest.api.v2010.account.signing_key import SigningKeyList
from twilio.rest.api.v2010.account.sip import SipList
from twilio.rest.api.v2010.account.token import TokenList
from twilio.rest.api.v2010.account.transcription import TranscriptionList
from twilio.rest.api.v2010.account.usage import UsageList
from twilio.rest.api.v2010.account.validation_request import ValidationRequestList


class AccountList(ListResource):

    def __init__(self, version):
        """
        Initialize the AccountList

        :param Version version: Version that contains the resource

        :returns: twilio.rest.api.v2010.account.AccountList
        :rtype: twilio.rest.api.v2010.account.AccountList
        """
        super(AccountList, self).__init__(version)

        # Path Solution
        self._solution = {}
        self._uri = '/Accounts.json'.format(**self._solution)

    def create(self, friendly_name=values.unset):
        """
        Create the AccountInstance

        :param unicode friendly_name: A human readable description of the account

        :returns: The created AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        data = values.of({'FriendlyName': friendly_name, })

        payload = self._version.create(method='POST', uri=self._uri, data=data, )

        return AccountInstance(self._version, payload, )

    def stream(self, friendly_name=values.unset, status=values.unset, limit=None,
               page_size=None):
        """
        Streams AccountInstance records from the API as a generator stream.
        This operation lazily loads records as efficiently as possible until the limit
        is reached.
        The results are returned as a generator, so this operation is memory efficient.

        :param unicode friendly_name: FriendlyName to filter on
        :param AccountInstance.Status status: Status to filter on
        :param int limit: Upper limit for the number of records to return. stream()
                          guarantees to never return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, stream() will attempt to read the
                              limit with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        :rtype: list[twilio.rest.api.v2010.account.AccountInstance]
        """
        limits = self._version.read_limits(limit, page_size)

        page = self.page(friendly_name=friendly_name, status=status, page_size=limits['page_size'], )

        return self._version.stream(page, limits['limit'])

    def list(self, friendly_name=values.unset, status=values.unset, limit=None,
             page_size=None):
        """
        Lists AccountInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param unicode friendly_name: FriendlyName to filter on
        :param AccountInstance.Status status: Status to filter on
        :param int limit: Upper limit for the number of records to return. list() guarantees
                          never to return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, list() will attempt to read the limit
                              with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        :rtype: list[twilio.rest.api.v2010.account.AccountInstance]
        """
        return list(self.stream(
            friendly_name=friendly_name,
            status=status,
            limit=limit,
            page_size=page_size,
        ))

    def page(self, friendly_name=values.unset, status=values.unset,
             page_token=values.unset, page_number=values.unset,
             page_size=values.unset):
        """
        Retrieve a single page of AccountInstance records from the API.
        Request is executed immediately

        :param unicode friendly_name: FriendlyName to filter on
        :param AccountInstance.Status status: Status to filter on
        :param str page_token: PageToken provided by the API
        :param int page_number: Page Number, this value is simply for client state
        :param int page_size: Number of records to return, defaults to 50

        :returns: Page of AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountPage
        """
        data = values.of({
            'FriendlyName': friendly_name,
            'Status': status,
            'PageToken': page_token,
            'Page': page_number,
            'PageSize': page_size,
        })

        response = self._version.page(method='GET', uri=self._uri, params=data, )

        return AccountPage(self._version, response, self._solution)

    def get_page(self, target_url):
        """
        Retrieve a specific page of AccountInstance records from the API.
        Request is executed immediately

        :param str target_url: API-generated URL for the requested results page

        :returns: Page of AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountPage
        """
        response = self._version.domain.twilio.request(
            'GET',
            target_url,
        )

        return AccountPage(self._version, response, self._solution)

    def get(self, sid):
        """
        Constructs a AccountContext

        :param sid: Fetch by unique Account Sid

        :returns: twilio.rest.api.v2010.account.AccountContext
        :rtype: twilio.rest.api.v2010.account.AccountContext
        """
        return AccountContext(self._version, sid=sid, )

    def __call__(self, sid):
        """
        Constructs a AccountContext

        :param sid: Fetch by unique Account Sid

        :returns: twilio.rest.api.v2010.account.AccountContext
        :rtype: twilio.rest.api.v2010.account.AccountContext
        """
        return AccountContext(self._version, sid=sid, )

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return '<Twilio.Api.V2010.AccountList>'


class AccountPage(Page):

    def __init__(self, version, response, solution):
        """
        Initialize the AccountPage

        :param Version version: Version that contains the resource
        :param Response response: Response from the API

        :returns: twilio.rest.api.v2010.account.AccountPage
        :rtype: twilio.rest.api.v2010.account.AccountPage
        """
        super(AccountPage, self).__init__(version, response)

        # Path Solution
        self._solution = solution

    def get_instance(self, payload):
        """
        Build an instance of AccountInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.api.v2010.account.AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        return AccountInstance(self._version, payload, )

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return '<Twilio.Api.V2010.AccountPage>'


class AccountContext(InstanceContext):

    def __init__(self, version, sid):
        """
        Initialize the AccountContext

        :param Version version: Version that contains the resource
        :param sid: Fetch by unique Account Sid

        :returns: twilio.rest.api.v2010.account.AccountContext
        :rtype: twilio.rest.api.v2010.account.AccountContext
        """
        super(AccountContext, self).__init__(version)

        # Path Solution
        self._solution = {'sid': sid, }
        self._uri = '/Accounts/{sid}.json'.format(**self._solution)

        # Dependents
        self._addresses = None
        self._applications = None
        self._authorized_connect_apps = None
        self._available_phone_numbers = None
        self._balance = None
        self._calls = None
        self._conferences = None
        self._connect_apps = None
        self._incoming_phone_numbers = None
        self._keys = None
        self._messages = None
        self._new_keys = None
        self._new_signing_keys = None
        self._notifications = None
        self._outgoing_caller_ids = None
        self._queues = None
        self._recordings = None
        self._signing_keys = None
        self._sip = None
        self._short_codes = None
        self._tokens = None
        self._transcriptions = None
        self._usage = None
        self._validation_requests = None

    def fetch(self):
        """
        Fetch the AccountInstance

        :returns: The fetched AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        payload = self._version.fetch(method='GET', uri=self._uri, )

        return AccountInstance(self._version, payload, sid=self._solution['sid'], )

    def update(self, friendly_name=values.unset, status=values.unset):
        """
        Update the AccountInstance

        :param unicode friendly_name: FriendlyName to update
        :param AccountInstance.Status status: Status to update the Account with

        :returns: The updated AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        data = values.of({'FriendlyName': friendly_name, 'Status': status, })

        payload = self._version.update(method='POST', uri=self._uri, data=data, )

        return AccountInstance(self._version, payload, sid=self._solution['sid'], )

    @property
    def addresses(self):
        """
        Access the addresses

        :returns: twilio.rest.api.v2010.account.address.AddressList
        :rtype: twilio.rest.api.v2010.account.address.AddressList
        """
        if self._addresses is None:
            self._addresses = AddressList(self._version, account_sid=self._solution['sid'], )
        return self._addresses

    @property
    def applications(self):
        """
        Access the applications

        :returns: twilio.rest.api.v2010.account.application.ApplicationList
        :rtype: twilio.rest.api.v2010.account.application.ApplicationList
        """
        if self._applications is None:
            self._applications = ApplicationList(self._version, account_sid=self._solution['sid'], )
        return self._applications

    @property
    def authorized_connect_apps(self):
        """
        Access the authorized_connect_apps

        :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList
        :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList
        """
        if self._authorized_connect_apps is None:
            self._authorized_connect_apps = AuthorizedConnectAppList(
                self._version,
                account_sid=self._solution['sid'],
            )
        return self._authorized_connect_apps

    @property
    def available_phone_numbers(self):
        """
        Access the available_phone_numbers

        :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList
        :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList
        """
        if self._available_phone_numbers is None:
            self._available_phone_numbers = AvailablePhoneNumberCountryList(
                self._version,
                account_sid=self._solution['sid'],
            )
        return self._available_phone_numbers

    @property
    def balance(self):
        """
        Access the balance

        :returns: twilio.rest.api.v2010.account.balance.BalanceList
        :rtype: twilio.rest.api.v2010.account.balance.BalanceList
        """
        if self._balance is None:
            self._balance = BalanceList(self._version, account_sid=self._solution['sid'], )
        return self._balance

    @property
    def calls(self):
        """
        Access the calls

        :returns: twilio.rest.api.v2010.account.call.CallList
        :rtype: twilio.rest.api.v2010.account.call.CallList
        """
        if self._calls is None:
            self._calls = CallList(self._version, account_sid=self._solution['sid'], )
        return self._calls

    @property
    def conferences(self):
        """
        Access the conferences

        :returns: twilio.rest.api.v2010.account.conference.ConferenceList
        :rtype: twilio.rest.api.v2010.account.conference.ConferenceList
        """
        if self._conferences is None:
            self._conferences = ConferenceList(self._version, account_sid=self._solution['sid'], )
        return self._conferences

    @property
    def connect_apps(self):
        """
        Access the connect_apps

        :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppList
        :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList
        """
        if self._connect_apps is None:
            self._connect_apps = ConnectAppList(self._version, account_sid=self._solution['sid'], )
        return self._connect_apps

    @property
    def incoming_phone_numbers(self):
        """
        Access the incoming_phone_numbers

        :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList
        :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList
        """
        if self._incoming_phone_numbers is None:
            self._incoming_phone_numbers = IncomingPhoneNumberList(
                self._version,
                account_sid=self._solution['sid'],
            )
        return self._incoming_phone_numbers

    @property
    def keys(self):
        """
        Access the keys

        :returns: twilio.rest.api.v2010.account.key.KeyList
        :rtype: twilio.rest.api.v2010.account.key.KeyList
        """
        if self._keys is None:
            self._keys = KeyList(self._version, account_sid=self._solution['sid'], )
        return self._keys

    @property
    def messages(self):
        """
        Access the messages

        :returns: twilio.rest.api.v2010.account.message.MessageList
        :rtype: twilio.rest.api.v2010.account.message.MessageList
        """
        if self._messages is None:
            self._messages = MessageList(self._version, account_sid=self._solution['sid'], )
        return self._messages

    @property
    def new_keys(self):
        """
        Access the new_keys

        :returns: twilio.rest.api.v2010.account.new_key.NewKeyList
        :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList
        """
        if self._new_keys is None:
            self._new_keys = NewKeyList(self._version, account_sid=self._solution['sid'], )
        return self._new_keys

    @property
    def new_signing_keys(self):
        """
        Access the new_signing_keys

        :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList
        :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList
        """
        if self._new_signing_keys is None:
            self._new_signing_keys = NewSigningKeyList(self._version, account_sid=self._solution['sid'], )
        return self._new_signing_keys

    @property
    def notifications(self):
        """
        Access the notifications

        :returns: twilio.rest.api.v2010.account.notification.NotificationList
        :rtype: twilio.rest.api.v2010.account.notification.NotificationList
        """
        if self._notifications is None:
            self._notifications = NotificationList(self._version, account_sid=self._solution['sid'], )
        return self._notifications

    @property
    def outgoing_caller_ids(self):
        """
        Access the outgoing_caller_ids

        :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList
        :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList
        """
        if self._outgoing_caller_ids is None:
            self._outgoing_caller_ids = OutgoingCallerIdList(self._version, account_sid=self._solution['sid'], )
        return self._outgoing_caller_ids

    @property
    def queues(self):
        """
        Access the queues

        :returns: twilio.rest.api.v2010.account.queue.QueueList
        :rtype: twilio.rest.api.v2010.account.queue.QueueList
        """
        if self._queues is None:
            self._queues = QueueList(self._version, account_sid=self._solution['sid'], )
        return self._queues

    @property
    def recordings(self):
        """
        Access the recordings

        :returns: twilio.rest.api.v2010.account.recording.RecordingList
        :rtype: twilio.rest.api.v2010.account.recording.RecordingList
        """
        if self._recordings is None:
            self._recordings = RecordingList(self._version, account_sid=self._solution['sid'], )
        return self._recordings

    @property
    def signing_keys(self):
        """
        Access the signing_keys

        :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyList
        :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList
        """
        if self._signing_keys is None:
            self._signing_keys = SigningKeyList(self._version, account_sid=self._solution['sid'], )
        return self._signing_keys

    @property
    def sip(self):
        """
        Access the sip

        :returns: twilio.rest.api.v2010.account.sip.SipList
        :rtype: twilio.rest.api.v2010.account.sip.SipList
        """
        if self._sip is None:
            self._sip = SipList(self._version, account_sid=self._solution['sid'], )
        return self._sip

    @property
    def short_codes(self):
        """
        Access the short_codes

        :returns: twilio.rest.api.v2010.account.short_code.ShortCodeList
        :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList
        """
        if self._short_codes is None:
            self._short_codes = ShortCodeList(self._version, account_sid=self._solution['sid'], )
        return self._short_codes

    @property
    def tokens(self):
        """
        Access the tokens

        :returns: twilio.rest.api.v2010.account.token.TokenList
        :rtype: twilio.rest.api.v2010.account.token.TokenList
        """
        if self._tokens is None:
            self._tokens = TokenList(self._version, account_sid=self._solution['sid'], )
        return self._tokens

    @property
    def transcriptions(self):
        """
        Access the transcriptions

        :returns: twilio.rest.api.v2010.account.transcription.TranscriptionList
        :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList
        """
        if self._transcriptions is None:
            self._transcriptions = TranscriptionList(self._version, account_sid=self._solution['sid'], )
        return self._transcriptions

    @property
    def usage(self):
        """
        Access the usage

        :returns: twilio.rest.api.v2010.account.usage.UsageList
        :rtype: twilio.rest.api.v2010.account.usage.UsageList
        """
        if self._usage is None:
            self._usage = UsageList(self._version, account_sid=self._solution['sid'], )
        return self._usage

    @property
    def validation_requests(self):
        """
        Access the validation_requests

        :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestList
        :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList
        """
        if self._validation_requests is None:
            self._validation_requests = ValidationRequestList(self._version, account_sid=self._solution['sid'], )
        return self._validation_requests

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
        return '<Twilio.Api.V2010.AccountContext {}>'.format(context)


class AccountInstance(InstanceResource):

    class Status(object):
        ACTIVE = "active"
        SUSPENDED = "suspended"
        CLOSED = "closed"

    class Type(object):
        TRIAL = "Trial"
        FULL = "Full"

    def __init__(self, version, payload, sid=None):
        """
        Initialize the AccountInstance

        :returns: twilio.rest.api.v2010.account.AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        super(AccountInstance, self).__init__(version)

        # Marshaled Properties
        self._properties = {
            'auth_token': payload.get('auth_token'),
            'date_created': deserialize.rfc2822_datetime(payload.get('date_created')),
            'date_updated': deserialize.rfc2822_datetime(payload.get('date_updated')),
            'friendly_name': payload.get('friendly_name'),
            'owner_account_sid': payload.get('owner_account_sid'),
            'sid': payload.get('sid'),
            'status': payload.get('status'),
            'subresource_uris': payload.get('subresource_uris'),
            'type': payload.get('type'),
            'uri': payload.get('uri'),
        }

        # Context
        self._context = None
        self._solution = {'sid': sid or self._properties['sid'], }

    @property
    def _proxy(self):
        """
        Generate an instance context for the instance, the context is capable of
        performing various actions.  All instance actions are proxied to the context

        :returns: AccountContext for this AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountContext
        """
        if self._context is None:
            self._context = AccountContext(self._version, sid=self._solution['sid'], )
        return self._context

    @property
    def auth_token(self):
        """
        :returns: The authorization token for this account
        :rtype: unicode
        """
        return self._properties['auth_token']

    @property
    def date_created(self):
        """
        :returns: The date this account was created
        :rtype: datetime
        """
        return self._properties['date_created']

    @property
    def date_updated(self):
        """
        :returns: The date this account was last updated
        :rtype: datetime
        """
        return self._properties['date_updated']

    @property
    def friendly_name(self):
        """
        :returns: A human readable description of this account
        :rtype: unicode
        """
        return self._properties['friendly_name']

    @property
    def owner_account_sid(self):
        """
        :returns: The unique 34 character id representing the parent of this account
        :rtype: unicode
        """
        return self._properties['owner_account_sid']

    @property
    def sid(self):
        """
        :returns: A 34 character string that uniquely identifies this resource.
        :rtype: unicode
        """
        return self._properties['sid']

    @property
    def status(self):
        """
        :returns: The status of this account
        :rtype: AccountInstance.Status
        """
        return self._properties['status']

    @property
    def subresource_uris(self):
        """
        :returns: Account Instance Subresources
        :rtype: unicode
        """
        return self._properties['subresource_uris']

    @property
    def type(self):
        """
        :returns: The type of this account
        :rtype: AccountInstance.Type
        """
        return self._properties['type']

    @property
    def uri(self):
        """
        :returns: The URI for this resource, relative to `https://api.twilio.com`
        :rtype: unicode
        """
        return self._properties['uri']

    def fetch(self):
        """
        Fetch the AccountInstance

        :returns: The fetched AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        return self._proxy.fetch()

    def update(self, friendly_name=values.unset, status=values.unset):
        """
        Update the AccountInstance

        :param unicode friendly_name: FriendlyName to update
        :param AccountInstance.Status status: Status to update the Account with

        :returns: The updated AccountInstance
        :rtype: twilio.rest.api.v2010.account.AccountInstance
        """
        return self._proxy.update(friendly_name=friendly_name, status=status, )

    @property
    def addresses(self):
        """
        Access the addresses

        :returns: twilio.rest.api.v2010.account.address.AddressList
        :rtype: twilio.rest.api.v2010.account.address.AddressList
        """
        return self._proxy.addresses

    @property
    def applications(self):
        """
        Access the applications

        :returns: twilio.rest.api.v2010.account.application.ApplicationList
        :rtype: twilio.rest.api.v2010.account.application.ApplicationList
        """
        return self._proxy.applications

    @property
    def authorized_connect_apps(self):
        """
        Access the authorized_connect_apps

        :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList
        :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList
        """
        return self._proxy.authorized_connect_apps

    @property
    def available_phone_numbers(self):
        """
        Access the available_phone_numbers

        :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList
        :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList
        """
        return self._proxy.available_phone_numbers

    @property
    def balance(self):
        """
        Access the balance

        :returns: twilio.rest.api.v2010.account.balance.BalanceList
        :rtype: twilio.rest.api.v2010.account.balance.BalanceList
        """
        return self._proxy.balance

    @property
    def calls(self):
        """
        Access the calls

        :returns: twilio.rest.api.v2010.account.call.CallList
        :rtype: twilio.rest.api.v2010.account.call.CallList
        """
        return self._proxy.calls

    @property
    def conferences(self):
        """
        Access the conferences

        :returns: twilio.rest.api.v2010.account.conference.ConferenceList
        :rtype: twilio.rest.api.v2010.account.conference.ConferenceList
        """
        return self._proxy.conferences

    @property
    def connect_apps(self):
        """
        Access the connect_apps

        :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppList
        :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList
        """
        return self._proxy.connect_apps

    @property
    def incoming_phone_numbers(self):
        """
        Access the incoming_phone_numbers

        :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList
        :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList
        """
        return self._proxy.incoming_phone_numbers

    @property
    def keys(self):
        """
        Access the keys

        :returns: twilio.rest.api.v2010.account.key.KeyList
        :rtype: twilio.rest.api.v2010.account.key.KeyList
        """
        return self._proxy.keys

    @property
    def messages(self):
        """
        Access the messages

        :returns: twilio.rest.api.v2010.account.message.MessageList
        :rtype: twilio.rest.api.v2010.account.message.MessageList
        """
        return self._proxy.messages

    @property
    def new_keys(self):
        """
        Access the new_keys

        :returns: twilio.rest.api.v2010.account.new_key.NewKeyList
        :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList
        """
        return self._proxy.new_keys

    @property
    def new_signing_keys(self):
        """
        Access the new_signing_keys

        :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList
        :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList
        """
        return self._proxy.new_signing_keys

    @property
    def notifications(self):
        """
        Access the notifications

        :returns: twilio.rest.api.v2010.account.notification.NotificationList
        :rtype: twilio.rest.api.v2010.account.notification.NotificationList
        """
        return self._proxy.notifications

    @property
    def outgoing_caller_ids(self):
        """
        Access the outgoing_caller_ids

        :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList
        :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList
        """
        return self._proxy.outgoing_caller_ids

    @property
    def queues(self):
        """
        Access the queues

        :returns: twilio.rest.api.v2010.account.queue.QueueList
        :rtype: twilio.rest.api.v2010.account.queue.QueueList
        """
        return self._proxy.queues

    @property
    def recordings(self):
        """
        Access the recordings

        :returns: twilio.rest.api.v2010.account.recording.RecordingList
        :rtype: twilio.rest.api.v2010.account.recording.RecordingList
        """
        return self._proxy.recordings

    @property
    def signing_keys(self):
        """
        Access the signing_keys

        :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyList
        :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList
        """
        return self._proxy.signing_keys

    @property
    def sip(self):
        """
        Access the sip

        :returns: twilio.rest.api.v2010.account.sip.SipList
        :rtype: twilio.rest.api.v2010.account.sip.SipList
        """
        return self._proxy.sip

    @property
    def short_codes(self):
        """
        Access the short_codes

        :returns: twilio.rest.api.v2010.account.short_code.ShortCodeList
        :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList
        """
        return self._proxy.short_codes

    @property
    def tokens(self):
        """
        Access the tokens

        :returns: twilio.rest.api.v2010.account.token.TokenList
        :rtype: twilio.rest.api.v2010.account.token.TokenList
        """
        return self._proxy.tokens

    @property
    def transcriptions(self):
        """
        Access the transcriptions

        :returns: twilio.rest.api.v2010.account.transcription.TranscriptionList
        :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList
        """
        return self._proxy.transcriptions

    @property
    def usage(self):
        """
        Access the usage

        :returns: twilio.rest.api.v2010.account.usage.UsageList
        :rtype: twilio.rest.api.v2010.account.usage.UsageList
        """
        return self._proxy.usage

    @property
    def validation_requests(self):
        """
        Access the validation_requests

        :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestList
        :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList
        """
        return self._proxy.validation_requests

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items())
        return '<Twilio.Api.V2010.AccountInstance {}>'.format(context)