Exemplo n.º 1
0
    def find_device_by_mac_and_did(mac_address, did, **kwargs):
        from broadsoft.requestobjects.GroupAccessDeviceGetRequest import GroupAccessDeviceGetRequest
        from broadsoft.requestobjects.UserGetRequest import UserGetRequest
        from broadsoft.requestobjects.lib.BroadsoftRequest import BroadsoftRequest

        devices = GroupAccessDeviceGetListRequest.find_device_by_mac(
            mac_address=mac_address, **kwargs)
        for d in devices:
            # first, fetch the device based on the name.
            fetched_device_xml = GroupAccessDeviceGetRequest.get_device(
                name=d['Device Name'], **kwargs)

            # this will give us a user. fetch that user.
            sip_user_id = fetched_device_xml.findall('.//userName')[0].text
            user = UserGetRequest.get_user(sip_user_id=sip_user_id, **kwargs)

            # does the user match the passed DID? If so, the MAC/DID pair is assigned.
            results = user.findall('./command/phoneNumber')
            if len(results) > 1:
                raise RuntimeError(
                    "UserGetRequest.get_user() returned too many results")
            user_did = user.findall('./command/phoneNumber')[0].text
            user_did = BroadsoftRequest.convert_phone_number(number=user_did)
            did = BroadsoftRequest.convert_phone_number(number=did)

            if did == user_did:
                return d

        return None
Exemplo n.º 2
0
    def build_command_xml(self):
        if self.user_server is not None:
            self.user_server = BroadsoftRequest.convert_phone_number(
                number=self.user_server)
        self.prep_for_xml()
        self.validate()

        cmd = self.build_command_shell()

        uid = ET.SubElement(cmd, 'userId')
        uid.text = self.sip_user_id

        if self.is_active is not None:
            s = ET.SubElement(cmd, 'isActive')
            s.text = self.is_active

        if self.busy_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'busyRedirectToVoiceMail')
            s.text = self.busy_redirect_to_voice_mail

        if self.no_answer_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'noAnswerRedirectToVoiceMail')
            s.text = self.no_answer_redirect_to_voice_mail

        if self.server_selection is not None:
            s = ET.SubElement(cmd, 'serverSelection')
            s.text = self.server_selection

        if self.user_server is not None:
            s = ET.SubElement(cmd, 'userServer')
            s.text = str(self.user_server)

        if self.mailbox_id_type is not None:
            s = ET.SubElement(cmd, 'mailboxIdType')
            s.text = self.mailbox_id_type

        if self.no_answer_number_of_rings is not None:
            s = ET.SubElement(cmd, 'noAnswerNumberOfRings')
            s.text = str(self.no_answer_number_of_rings)

        if self.always_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'alwaysRedirectToVoiceMail')
            s.text = self.always_redirect_to_voice_mail

        if self.out_of_primary_zone_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'outOfPrimaryZoneRedirectToVoiceMail')
            s.text = self.out_of_primary_zone_redirect_to_voice_mail

        return cmd
Exemplo n.º 3
0
    def build_command_xml(self):
        self.prep_for_xml()
        self.validate()

        cmd = self.build_command_shell()

        if self.broadsoftinstance.service_provider:
            sp = ET.SubElement(cmd, 'serviceProviderId')
            sp.text = str(self.broadsoftinstance.service_provider)

        if self.group_id:
            gid = ET.SubElement(cmd, 'groupId')
            gid.text = self.group_id

        dd = ET.SubElement(cmd, 'defaultDomain')
        dd.text = self.broadsoftinstance.default_domain

        if self.user_limit is not None:
            ul = ET.SubElement(cmd, 'userLimit')
            ul.text = str(int(self.user_limit))

        if self.group_name:
            gid = ET.SubElement(cmd, 'groupName')
            gid.text = self.group_name

        clid = ET.SubElement(cmd, 'callingLineIdName')
        clid.text = self.derive_calling_line_id_name()

        tz = ET.SubElement(cmd, 'timeZone')
        tz.text = self.timezone

        if self.derive_build_contact():
            c = ET.SubElement(cmd, 'contact')

            if self.contact_name:
                cname = ET.SubElement(c, 'contactName')
                cname.text = self.contact_name

            if self.contact_number:
                cnumber = ET.SubElement(c, 'contactNumber')
                cnumber.text = BroadsoftRequest.convert_phone_number(
                    number=self.contact_number, dashes=True)

            if self.contact_email:
                ce = ET.SubElement(c, 'contactEmail')
                ce.text = self.contact_email

        return cmd
Exemplo n.º 4
0
 def derive_extension(self, digits=5):
     if not self.extension and self.did:
         self.did = BroadsoftRequest.convert_phone_number(number=self.did)
         self.extension = str(self.did)[-digits:]
Exemplo n.º 5
0
    def build_command_xml(self):
        if self.transfer_phone_number is not None:
            self.transfer_phone_number = BroadsoftRequest.convert_phone_number(
                number=self.transfer_phone_number)
        self.prep_for_xml()
        self.validate()

        cmd = self.build_command_shell()

        uid = ET.SubElement(cmd, 'userId')
        uid.text = self.sip_user_id

        if self.is_active is not None:
            s = ET.SubElement(cmd, 'isActive')
            s.text = self.is_active

        if self.processing is not None:
            s = ET.SubElement(cmd, 'processing')
            s.text = self.processing

        if self.voice_message_delivery_email_address is not None:
            s = ET.SubElement(cmd, 'voiceMessageDeliveryEmailAddress')
            s.text = self.voice_message_delivery_email_address

        if self.use_phone_message_waiting_indicator is not None:
            s = ET.SubElement(cmd, 'usePhoneMessageWaitingIndicator')
            s.text = self.use_phone_message_waiting_indicator

        if self.send_voice_message_notify_email is not None:
            s = ET.SubElement(cmd, 'sendVoiceMessageNotifyEmail')
            s.text = self.send_voice_message_notify_email

        if self.voice_message_notify_email_address is not None:
            s = ET.SubElement(cmd, 'voiceMessageNotifyEmailAddress')
            s.text = self.voice_message_notify_email_address

        if self.send_carbon_copy_voice_message is not None:
            s = ET.SubElement(cmd, 'sendCarbonCopyVoiceMessage')
            s.text = self.send_carbon_copy_voice_message

        if self.voice_message_carbon_copy_email_address is not None:
            s = ET.SubElement(cmd, 'voiceMessageCarbonCopyEmailAddress')
            s.text = self.voice_message_carbon_copy_email_address

        if self.transfer_on_zero_to_phone_number is not None:
            s = ET.SubElement(cmd, 'transferOnZeroToPhoneNumber')
            s.text = self.transfer_on_zero_to_phone_number

        if self.transfer_phone_number is not None:
            s = ET.SubElement(cmd, 'transferPhoneNumber')
            s.text = self.transfer_phone_number

        if self.always_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'alwaysRedirectToVoiceMail')
            s.text = self.always_redirect_to_voice_mail

        if self.busy_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'busyRedirectToVoiceMail')
            s.text = self.busy_redirect_to_voice_mail

        if self.no_answer_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'noAnswerRedirectToVoiceMail')
            s.text = self.no_answer_redirect_to_voice_mail

        if self.out_of_primary_zone_redirect_to_voice_mail is not None:
            s = ET.SubElement(cmd, 'outOfPrimaryZoneRedirectToVoiceMail')
            s.text = self.out_of_primary_zone_redirect_to_voice_mail

        return cmd