コード例 #1
0
    def delete(self, delete_devices=False):
        self.prep_attributes()

        if delete_devices and len(self.devices) == 0:
            self.load_devices()

        if self.sip_user_id is None:
            raise ValueError("can't call Account.delete() without a value for sip_user_id")

        # going to do this as a compound request so that it's pseudo-atomic...if one fails, the rest should
        # fail, regardless of where in the process that failure occurs
        b = BroadsoftRequest()
        self.inject_broadsoftinstance(child=b)

        # build XML to delete user
        user = UserDeleteRequest(sip_user_id=self.sip_user_id)
        b.commands = [user]

        # -- doing no device management in broadsoft, therefore no need for
        # -- "clear the decks behavior"...create device. Exists already? Fine.
        # for each device, add XML for device deletion
        # for d in self.devices:
        #    b.commands.append(d.delete(bundle=True))

        b.post()
        return [b]
コード例 #2
0
    def activate_voicemail(self, type=None, voicemail_object=None):
        if not self.sip_user_id:
            raise ValueError("can't call Account.activate_unity_voicemail without a value for sip_user_id")

        # no type provided? inherit from object.
        if type is None:
            type = self.voicemail

        # user didn't specify a custom Voicemail object? Instantiate the default for the given type.
        if voicemail_object is None:
            voicemail_object = Voicemail(type=type, broadsoftinstance=self.broadsoftinstance,
                                         logging_level=self.logging_level)

        # get email, sip_user_id, and mwi into voicemail object, whether constructed or passed
        if voicemail_object.email is None:
            voicemail_object.email = self.email
        if voicemail_object.sip_user_id is None:
            voicemail_object.sip_user_id = self.sip_user_id
        if voicemail_object.mwi is None:
            voicemail_object.mwi = self.voicemail_mwi
        if voicemail_object.sip_password is None:
            voicemail_object.sip_password = self.sip_password
        if voicemail_object.did is None:
            voicemail_object.did = self.did

        # going to do this as a compound request so that it's pseudo-atomic...if one fails, the rest should
        # fail, regardless of where in the process that failure occurs
        b = BroadsoftRequest()
        self.inject_broadsoftinstance(child=b)

        # build XML to activate chosen voicemail system
        # makes more sense to deactivate counterpart first, but this is the step that's more likely to fail, so might
        # as well put it first
        activate = voicemail_object.build_activate_command()

        # build XML to deactivate counterpart
        deactivate = voicemail_object.build_deactivate_counterpart_command()

        b.commands = activate + deactivate
        b.post()
        return [b]