Exemplo n.º 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]
Exemplo n.º 2
0
    def build_provision_request(self):
        # 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)

        # object to create the user
        u_add = UserAddRequest()
        self.inject_broadsoftinstance(child=u_add)
        u_add.first_name = self.first_name
        u_add.last_name = self.last_name
        u_add.did = self.did
        u_add.kname = self.kname
        u_add.sip_user_id = self.sip_user_id
        u_add.sip_password = self.sip_password
        u_add.email = self.email
        b.commands = [u_add]

        # if there are services to add for user, add them
        self.add_services(req_object=b)

        # if there are devices to add for user, add them
        self.add_devices(req_object=b)

        # default settings for all SCAs, set once per account
        self.configure_sca_settings(req_object=b)

        # set authentication creds
        self.set_auth_creds(req_object=b)

        return b
Exemplo n.º 3
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]