from ...tl.mtproto_request import MTProtoRequest


class UpdateDcOptions(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x8e5e9873

    def __init__(self, dc_options):
        """
        :param dc_options: Telegram type: «DcOption». Must be a list.

        Constructor for Update: Instance of either UpdateNewMessage, UpdateMessageID, UpdateDeleteMessages, UpdateUserTyping, UpdateChatUserTyping, UpdateChatParticipants, UpdateUserStatus, UpdateUserName, UpdateUserPhoto, UpdateContactRegistered, UpdateContactLink, UpdateNewEncryptedMessage, UpdateEncryptedChatTyping, UpdateEncryption, UpdateEncryptedMessagesRead, UpdateChatParticipantAdd, UpdateChatParticipantDelete, UpdateDcOptions, UpdateUserBlocked, UpdateNotifySettings, UpdateServiceNotification, UpdatePrivacy, UpdateUserPhone, UpdateReadHistoryInbox, UpdateReadHistoryOutbox, UpdateWebPage, UpdateReadMessagesContents, UpdateChannelTooLong, UpdateChannel, UpdateNewChannelMessage, UpdateReadChannelInbox, UpdateDeleteChannelMessages, UpdateChannelMessageViews, UpdateChatAdmins, UpdateChatParticipantAdmin, UpdateNewStickerSet, UpdateStickerSetsOrder, UpdateStickerSets, UpdateSavedGifs, UpdateBotInlineQuery, UpdateBotInlineSend, UpdateEditChannelMessage, UpdateChannelPinnedMessage, UpdateBotCallbackQuery, UpdateEditMessage, UpdateInlineBotCallbackQuery, UpdateReadChannelOutbox, UpdateDraftMessage, UpdateReadFeaturedStickers, UpdateRecentStickers, UpdateConfig, UpdatePtsChanged, UpdateChannelWebPage, UpdateDialogPinned, UpdatePinnedDialogs, UpdateBotWebhookJSON, UpdateBotWebhookJSONQuery, UpdateBotShippingQuery, UpdateBotPrecheckoutQuery, UpdatePhoneCall.
        """
        super().__init__()

        self.dc_options = dc_options

    def on_send(self, writer):
        writer.write_int(UpdateDcOptions.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.dc_options))
        for dc_options_item in self.dc_options:
            dc_options_item.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return UpdateDcOptions(None)

    def on_response(self, reader):
        reader.read_int()  # Vector's constructor ID
        self.dc_options = []  # Initialize an empty list
        dc_options_len = reader.read_int()
        for _ in range(dc_options_len):
            dc_options_item = reader.tgread_object()
            self.dc_options.append(dc_options_item)

    def __repr__(self):
        return 'updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update'

    def __str__(self):
        return '(updateDcOptions (ID: 0x8e5e9873) = (dc_options={}))'.format(None if not self.dc_options else [str(_) for _ in self.dc_options])
