Build an instance of UsageInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.preview.wireless.sim.usage.UsageInstance
        :rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance
192250
def get_instance(self, payload):
        
        return UsageInstance(self._version, payload, sim_sid=self._solution['sim_sid'], )
945273
def instance_provisioned(device_id):
    """"""
    session = db.get_reader_session()
    with session.begin():
        port_model = models_v2.Port
        res = bool(session.query(port_model)
                   .filter(port_model.device_id == device_id).count())
    return res
82051
def _get_usage(self, account_number, number):
        
        # Prepare data
        data = {"ctn": number,
                "language": "en-US",
                "accountNumber": account_number}
        # Http request
        try:
            raw_res = yield from self._session.post(USAGE_URL,
                                                    data=data,
                                                    headers=self._headers,
                                                    timeout=self._timeout)
        except OSError:
            raise PyFidoError("Can not get usage")
        # Load answer as json
        try:
            output = yield from raw_res.json()
        except (OSError, ValueError):
            raise PyFidoError("Can not get usage as json")
        # Format data
        ret_data = {}
        for data_name, keys in DATA_MAP.items():
            key, subkey = keys
            for data in output.get(key)[0].get('wirelessUsageSummaryInfoList'):
                if data.get('usageSummaryType') == subkey:
                    # Prepare keys:
                    used_key = "{}_used".format(data_name)
                    remaining_key = "{}_remaining".format(data_name)
                    limit_key = "{}_limit".format(data_name)
                    # Get values
                    ret_data[used_key] = data.get('used', 0.0)
                    if data.get('remaining') >= 0:
                        ret_data[remaining_key] = data.get('remaining')
                    else:
                        ret_data[remaining_key] = None
                    if data.get('total') >= 0:
                        ret_data[limit_key] = data.get('total')
                    else:
                        ret_data[limit_key] = None

        return ret_data
48264
def authenticate_credentials(self, payload):
        
        User = get_user_model()
        username = jwt_get_username_from_payload(payload)

        if not username:
            msg = _('Invalid payload.')
            raise exceptions.AuthenticationFailed(msg)

        try:
            user = User.objects.get_by_natural_key(username)
        except User.DoesNotExist:
            msg = _('Invalid signature.')
            raise exceptions.AuthenticationFailed(msg)

        if not user.is_active:
            msg = _('User account is disabled.')
            raise exceptions.AuthenticationFailed(msg)

        return user
1352181
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return UserChannelInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            user_sid=self._solution['user_sid'],
            channel_sid=self._solution['channel_sid'],
        )
1063314
def get_instance(self, payload):
        
        return ShortCodeInstance(self._version, payload, account_sid=self._solution['account_sid'], )
457732
def get_instance(self, payload):
        
        return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'], )
1154210
def usage(self):
        
        if self._usage is None:
            self._usage = UsageList(self._version, sim_sid=self._solution['sid'], )
        return self._usage
757945
def get_instance(self, payload):
        
        return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'], )
658165
def get_instance(self, payload):
        
        return DialogueInstance(self._version, payload, assistant_sid=self._solution['assistant_sid'], )
316408
def get_instance(self, payload):
        
        return MessageInstance(self._version, payload, session_sid=self._solution['session_sid'], )
1360188
def get_instance(self, payload):
        
        return SyncStreamInstance(self._version, payload, service_sid=self._solution['service_sid'], )
176800
def get_used_fields(payload):
    
    return [
        tag
        for tag, descriptor in payload.CHILD_MAP.items()
        if descriptor.__get__(payload, type(payload)) is not None
    ]
639451
def get_instance(self, payload):
        
        return FactorInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            identity=self._solution['identity'],
        )
977466
def get_instance(self, payload):
        
        return MessageInstance(self._version, payload, account_sid=self._solution['account_sid'], )
996692
def authenticate_credentials(self, payload):
        
        User = get_user_model()  # noqa
        username = jwt_get_username_from_payload_handler(payload)

        if not username:
            msg = _('Invalid payload.')
            raise exceptions.AuthenticationFailed(msg)

        try:
            user = User.objects.get(email=username)
        except User.DoesNotExist:
            msg = _('Invalid signature.')
            raise exceptions.AuthenticationFailed(msg)

        return user
565844
def get_instance(self, payload):
        
        return KeyInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'], )