Load object with id/API pair

        Args:
            serverid (int): Discord 'guild' webhook is attached to
            api_key (`str`:uuid): unique ID for webhook
166004
def api_keys(self, serverid, api_key):
        
        if serverid and api_key:
            self.can_query = True # Yes, we _are_ (will be) configured
        self.serverid = int(serverid)
        self.api_key = api_key
        self.webhook_url = self.__base_url + str(self.serverid) + '/' + self.api_key
123406
def register(self, server=None):
        
        if (self.key or self.secret):
            return self.update()

        server_data = self.request(server)

        self.key = server_data["client_id"]
        self.secret = server_data["client_secret"]
        self.expirey = server_data["expires_at"]
100874
def _on_connection(self, data, unique_id):
        
        if unique_id is None:
            unique_id = self.stream_unique_id
        self.connection_id = data.get('connectionId')
        logger.info('[Connect: %s]: connection_id: %s' % (unique_id, self.connection_id))
239238
def server(id)
      id = id.resolve_id
      return @servers[id] if @servers[id]

      LOGGER.out("Resolving server #{id}")
      begin
        response = API::Server.resolve(token, id)
      rescue Discordrb::Errors::NoPermission
        return nil
      end
      server = Server.new(JSON.parse(response), self)
      @servers[id] = server
    end
1215715
def _process_for_id(cls, response_raw):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        id_ = converter.deserialize(
            Id,
            cls._unwrap_response_single(obj, cls._FIELD_ID)
        )

        return client.BunqResponse(id_.id_, response_raw.headers)
906462
def import_discord_user(self, uid, user):
		
		url = api_url+'users/social/'
		payload = {
			'user': int(user),
			'provider': 'discord',
			'uid': str(uid)
		}
		print(json.dumps(payload))
		r = requests.put(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return DiscordUser(r.json())
974801
def update(self, case_id, **attributes):
        

        response = self._thehive.do_patch("/api/case/{}".format(case_id), **attributes)

        if response.status_code == requests.codes.unauthorized:
            raise TheHiveException("Authentication failed")

        if self.status_ok(response.status_code):
            return self(response.json()['id'])
        else:
            raise CaseException("Server returned {}: {}".format(response.status_code, response.text))
1319543
def get_item_with_id(self, uid):
        
        for item in self.get_items():
            if item.id == uid:
                return item

        return None
926883
def get_server(self, UUID):
        
        server, IPAddresses, storages = self.get_server_data(UUID)

        return Server(
            server,
            ip_addresses=IPAddresses,
            storage_devices=storages,
            populated=True,
            cloud_manager=self
        )
169707
def usable_id(cls, id):
        
        try:
            # id is maybe a sshkey name
            qry_id = cls.from_name(id)
            if not qry_id:
                qry_id = int(id)
        except DuplicateResults as exc:
            cls.error(exc.errors)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
1050769
def request(self, id, **kwargs):
        
        data = self.get('requests', id, **kwargs)
        return data
1206599
def unfederate(self, serverId):
        
        url = self._url + "/servers/{serverid}/unfederate".format(
            serverid=serverId)
        params = {"f" : "json"}
        return self._get(url=url,
                         param_dict=params,
                         proxy_port=self._proxy_port,
                         proxy_url=self._proxy_ur)
964689
def load_batch(server_context, assay_id, batch_id):
    # type: (ServerContext, int, int) -> Union[Batch, None]
    
    load_batch_url = server_context.build_url('assay', 'getAssayBatch.api')
    loaded_batch = None

    payload = {
        'assayId': assay_id,
        'batchId': batch_id
    }

    headers = {
        'Content-type': 'application/json',
        'Accept': 'text/plain'
    }

    json_body = server_context.make_request(load_batch_url, json_dumps(payload, sort_keys=True), headers=headers)
    if json_body is not None:
        loaded_batch = Batch.from_data(json_body['batch'])

    return loaded_batch
822267
def load(uid=None):
    
    app.logger.info("GET /sync route with id: %s" % uid)

    try:
        user = Participant.query.\
            filter(Participant.uniqueid == uid).\
            one()
    except exc.SQLAlchemyError:
        app.logger.error("DB error: Unique user not found.")

    try:
        resp = json.loads(user.datastring)
    except:
        resp = {
            "condition": user.cond,
            "counterbalance": user.counterbalance,
            "assignmentId": user.assignmentid,
            "workerId": user.workerid,
            "hitId": user.hitid,
            "bonus": user.bonus
        }

    return jsonify(**resp)
20406
def open(self, pysession_id):
        '''
        
        '''
        self.id = id(self)
        self.funcserver = self.application.funcserver
        self.pysession_id = pysession_id

        # register this connection with node
        self.state = self.funcserver.websocks[self.id] = {'id': self.id, 'sock': self}
1121906
def generate_id(self, portal_type, batch_size = None):
        
        plone = getSite()
        portal_id = plone.getId()

        if portal_type == 'News Item':
            portal_type = 'NewsItem'

        idserver_url = os.environ.get('IDServerURL')
        try:
            if batch_size:
                # GET
                f = urllib.urlopen('%s/%s%s?%s' % (
                        idserver_url,
                        portal_id,
                        portal_type,
                        urllib.urlencode({'batch_size': batch_size}))
                        )
            else:
                f = urllib.urlopen('%s/%s%s' % (
                    idserver_url, portal_id, portal_type
                    )
                )
            id = f.read()
            f.close()
        except:
            from sys import exc_info
            info = exc_info()
            import zLOG; zLOG.LOG('INFO', 0, '', 'generate_id raised exception: %s, %s \n idserver_url: %s' % (info[0], info[1], idserver_url))
            raise IDServerUnavailable(_('ID Server unavailable'))
        return id
999037
def _get_api_id(self, event_properties):
        
        api_id = event_properties.get("RestApiId")
        if isinstance(api_id, dict) and "Ref" in api_id:
            api_id = api_id["Ref"]
        return api_id