Create instance from request PDU.

        :param pdu: A request PDU.
        :return: Instance of this class.
552194
def create_from_request_pdu(pdu):
        
        _, starting_address, quantity, byte_count = \
            struct.unpack('>BHHB', pdu[:6])

        # Values are 16 bit, so each value takes up 2 bytes.
        fmt = '>' + (conf.MULTI_BIT_VALUE_FORMAT_CHARACTER *
                     int((byte_count / 2)))

        values = list(struct.unpack(fmt, pdu[6:]))

        instance = WriteMultipleRegisters()
        instance.starting_address = starting_address
        instance.values = values

        return instance
1253660
def instance(cls) -> 'MiddlewareManager':
        

        if cls._instance is None:
            cls._instance = cls()
            cls._instance.init()
        return cls._instance
1317011
def create(self, _attributes=None, _joining=None, _touch=True, **attributes):
        
        if _attributes is not None:
            attributes.update(_attributes)

        instance = self._related.new_instance(attributes)

        instance.save({"touch": False})

        self.attach(instance.get_key(), _joining, _touch)

        return instance
1241881
def create(self,
               institution_id,
               initial_products,
               _options=None,
               webhook=None,
               transactions__start_date=None,
               transactions__end_date=None,
               ):
        '''
        
        '''
        options = _options or {}

        if webhook is not None:
            options['webhook'] = webhook

        transaction_options = {}
        transaction_options.update(options.get('transactions', {}))
        if transactions__start_date is not None:
            transaction_options['start_date'] = transactions__start_date
        if transactions__end_date is not None:
            transaction_options['end_date'] = transactions__end_date
        if transaction_options:
            options['transactions'] = transaction_options

        return self.client.post_public_key('/sandbox/public_token/create', {
            'institution_id': institution_id,
            'initial_products': initial_products,
            'options': options,
        })
1093374
def create_response_pdu(self, data):
        
        log.debug('Create multi bit response pdu {0}.'.format(data))
        fmt = '>BB' + conf.TYPE_CHAR * len(data)

        return struct.pack(fmt, self.function_code, len(data) * 2, *data)
728703
def create_response_pdu(self):
        
        return struct.pack('>BHH', self.function_code, self.starting_address,
                           len(self.values))
66021
def create(self, max_wait=180, **kwargs):
        
        # Will need to wait for the service to be provisioned before can add
        # service keys and get env details.
        self.service.create(async=True, create_keys=False)
        while self._create_in_progress() and max_wait > 0:
            time.sleep(1)
            max_wait -= 1

        # Now get the service env (via service keys)
        cfg = self.service._get_service_config()
        self.service.settings.save(cfg)

        host = predix.config.get_env_key(self.use_class, 'host')
        os.environ[host] = self.service.settings.data['host']

        password = predix.config.get_env_key(self.use_class, 'password')
        os.environ[password] = self.service.settings.data['password']

        port = predix.config.get_env_key(self.use_class, 'port')
        os.environ[port] = str(self.service.settings.data['port'])
1052661
def CreateInstance(self, *args, **kwargs):
        

        inst = args[0] if args else kwargs['NewInstance']
        try:
            self.instances[self.default_namespace].append(inst)
        except KeyError:
            self.instances[self.default_namespace] = [inst]
        return inst.path
764307
def request_pdu(self):
        
        if None in [self.address, self.value]:
            # TODO Raise proper exception.
            raise Exception

        return struct.pack('>BH' + conf.TYPE_CHAR, self.function_code,
                           self.address, self.value)
113504
def create_account(self, **kwargs):
        
        response = self.__requester.request(
            'POST',
            'accounts',
            _kwargs=combine_kwargs(**kwargs)
        )
        return Account(self.__requester, response.json())
1098571
def create(self, **kwargs):
        
        tmos_v = self._meta_data['bigip']._meta_data['tmos_version']
        if LooseVersion(tmos_v) == LooseVersion('11.5.4') or LooseVersion(
                tmos_v) == LooseVersion('12.1.1'):
            if 'uri' in self._meta_data:
                error = "There was an attempt to assign a new uri to this " \
                        "resource, the _meta_data['uri'] is %s and it should" \
                        " not be changed." % (self._meta_data['uri'])
                raise URICreationCollision(error)
            self._check_exclusive_parameters(**kwargs)
            requests_params = self._handle_requests_params(kwargs)
            self._check_create_parameters(**kwargs)

            # Reduce boolean pairs as specified by the meta_data entry below
            for key1, key2 in self._meta_data['reduction_forcing_pairs']:
                kwargs = self._reduce_boolean_pair(kwargs, key1, key2)

            # Make convenience variable with short names for this method.
            _create_uri = self._meta_data['container']._meta_data['uri']
            session = self._meta_data['bigip']._meta_data['icr_session']
            # We using try/except just in case some HF will fix
            # this in 11.5.4

            try:
                response = session.post(
                    _create_uri, json=kwargs, **requests_params)

            except HTTPError as err:
                if err.response.status_code != 404:
                    raise
                if err.response.status_code == 404:
                    return self._return_object(self._meta_data['container'],
                                               kwargs['name'])
            # Make new instance of self
            return self._produce_instance(response)
        else:
            return self._create(**kwargs)
990049
def request_pdu(self):
        
        if None in [self.starting_address, self.quantity]:
            # TODO Raise proper exception.
            raise Exception

        return struct.pack('>BHH', self.function_code, self.starting_address,
                           self.quantity)
619420
def create_from_request_pdu(pdu):
        
        _, address, value = struct.unpack('>BHH', pdu)

        value = 1 if value == 0xFF00 else value

        instance = WriteSingleCoil()
        instance.address = address
        instance.value = value

        return instance
604322
def create(self, using=None, **kwargs):
        
        self._get_connection(using).indices.create(index=self._name, body=self.to_dict(), **kwargs)
186489
def create(cls, key, crt):
        
        options = {'crt': crt, 'key': key}
        return cls.call('cert.hosted.create', options)
149910
def createInstance(self, codec=None):
        
        if type(self.klass) is type:
            return self.klass.__new__(self.klass)

        return self.klass()
1138101
def process(self, request_adu):
        
        meta_data = self.get_meta_data(request_adu)
        request_pdu = self.get_request_pdu(request_adu)

        response_pdu = self.execute_route(meta_data, request_pdu)
        response_adu = self.create_response_adu(meta_data, response_pdu)

        return response_adu