当前位置: 首页>>代码示例>>Python>>正文


Python Broker.get方法代码示例

本文整理汇总了Python中request.Broker.get方法的典型用法代码示例。如果您正苦于以下问题:Python Broker.get方法的具体用法?Python Broker.get怎么用?Python Broker.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在request.Broker的用法示例。


在下文中一共展示了Broker.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_members

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def get_members(self,
                    retries=None,
                    headers=None,
                    proxies=None,
                    verify=None):
        """
        Get the members of a Threat Privacy Group

        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: list
        """

        url = self._DETAILS + tpg.MEMBERS
        results = Broker.get(url,
                             retries=retries,
                             headers=headers,
                             proxies=proxies,
                             verify=verify)
        if t.DATA in results:
            return results[t.DATA]
        else:
            return []
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:31,代码来源:threat_privacy_group.py

示例2: objects

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def objects(cls, text=None, strict_text=False, type_=None, threat_type=None,
                fields=None, limit=None, since=None, until=None, __raw__=None,
                full_response=False, dict_generator=False, retries=None):
        """
        Get objects from ThreatExchange.

        :param text: The text used for limiting the search.
        :type text: str
        :param strict_text: Whether we should use strict searching.
        :type strict_text: bool, str, int
        :param type_: The Indicator type to limit to.
        :type type_: str
        :param threat_type: The Threat type to limit to.
        :type threat_type: str
        :param fields: Select specific fields to pull
        :type fields: str, list
        :param limit: The maximum number of objects to return.
        :type limit: int, str
        :param since: The timestamp to limit the beginning of the search.
        :type since: str
        :param until: The timestamp to limit the end of the search.
        :type until: str
        :param __raw__: Provide a dictionary to force as GET parameters.
                        Overrides all other arguments.
        :type __raw__: dict
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :returns: Generator, dict (using json.loads())
        """

        if __raw__:
            if isinstance(__raw__, dict):
                params = __raw__
            else:
                raise pytxValueError('__raw__ must be of type dict')
        else:
            params = Broker.build_get_parameters(
                text=text,
                strict_text=strict_text,
                type_=type_,
                threat_type=threat_type,
                fields=fields,
                limit=limit,
                since=since,
                until=until,
            )
        if full_response:
            return Broker.get(cls._URL, params=params, retries=retries)
        else:
            return Broker.get_generator(cls,
                                        cls._URL,
                                        to_dict=dict_generator,
                                        params=params,
                                        retries=retries)
开发者ID:WalKnDude,项目名称:ThreatExchange,代码行数:62,代码来源:common.py

示例3: _get_generator

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def _get_generator(cls, url, to_dict=False, params=None):
        """
        Send the GET request and return a generator.

        :param url: The URL to send the GET request to.
        :type url: str
        :param to_dict: Return a dictionary instead of an instantiated class.
        :type to_dict: bool
        :param params: The GET parameters to send in the request.
        :type params: dict
        :returns: Generator, dict (using json.loads())
        """

        if not params:
            params = dict()

        members = Broker.get(url, params=params).get(t.DATA, [])
        total = len(members)
        if total == t.MIN_TOTAL:
            yield None
        else:
            for member in members:
                if to_dict:
                    yield member
                else:
                    yield Broker.get_new(cls, member)
开发者ID:atticusliu,项目名称:ThreatExchange,代码行数:28,代码来源:threat_exchange_member.py

示例4: send

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def send(cls_or_self, id_=None, params=None, type_=None):
        """
        Send custom params to the object URL. If `id` is provided it will be
        appended to the URL. If this is an uninstantiated class we will use the
        object type url (ex: /threat_descriptors/). If this is an instantiated
        object we will use the details URL. The type_ should be either GET or
        POST. We will default to GET if this is an uninstantiated class, and
        POST if this is an instantiated class.

        :param id_: ID of a graph object.
        :type id_: str
        :param params: Parameters to submit in the request.
        :type params: dict
        :param type_: GET or POST
        :type type_: str

        :returns: dict (using json.loads())
        """

        if isinstance(cls_or_self, type):
            url = cls_or_self._URL
            if type_ is None:
                type_ = 'GET'
        else:
            url = cls_or_self._DETAILS
            if type_ is None:
                type_ = 'POST'
        if id_ is not None and len(id_) > 0:
            url = url + id_ + '/'
        if params is None:
            params = {}
        if type_ == 'GET':
            return Broker.get(url, params=params)
        else:
            return Broker.post(url, params=params)
开发者ID:jgarman,项目名称:ThreatExchange,代码行数:37,代码来源:common.py

示例5: mine

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def mine(cls,
             role=None,
             full_response=False,
             dict_generator=False,
             retries=None,
             headers=None,
             proxies=None,
             verify=None):
        """
        Find all of the Threat Privacy Groups that I am either the owner or a
        member.

        :param role: Whether you are an 'owner' or a 'member'
        :type role: str
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: Generator, dict (using json.loads())
        """

        if role is None:
            raise pytxValueError('Must provide a role')
        app_id = get_app_id() + '/'
        if role == 'owner':
            role = t.THREAT_PRIVACY_GROUPS_OWNER
        elif role == 'member':
            role = t.THREAT_PRIVACY_GROUPS_MEMBER
        else:
            raise pytxValueError('Role must be "owner" or "member"')
        params = {'fields': ','.join(cls._fields)}
        url = t.URL + t.VERSION + app_id + role
        if full_response:
            return Broker.get(url,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            return Broker.get_generator(cls,
                                        url,
                                        params=params,
                                        to_dict=dict_generator,
                                        retries=retries,
                                        headers=headers,
                                        proxies=proxies,
                                        verify=verify)
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:60,代码来源:threat_privacy_group.py

示例6: _get_generator

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def _get_generator(cls,
                       url,
                       to_dict=False,
                       params=None,
                       retries=None,
                       headers=None,
                       proxies=None,
                       verify=None):
        """
        Send the GET request and return a generator.

        :param url: The URL to send the GET request to.
        :type url: str
        :param to_dict: Return a dictionary instead of an instantiated class.
        :type to_dict: bool
        :param params: The GET parameters to send in the request.
        :type params: dict
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: Generator, dict (using json.loads())
        """

        if not params:
            params = dict()

        members = Broker.get(url,
                             params=params,
                             retries=retries,
                             headers=headers,
                             proxies=proxies,
                             verify=verify).get(t.DATA, [])
        total = len(members)
        if total == t.MIN_TOTAL:
            yield None
        else:
            for member in members:
                if to_dict:
                    yield member
                else:
                    yield Broker.get_new(cls, member)
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:48,代码来源:threat_exchange_member.py

示例7: objects

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def objects(cls, full_response=False, dict_generator=False):
        """
        Get a list of Threat Exchange Members

        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :returns: Generator, dict (using json.loads())
        """

        if full_response:
            return Broker.get(cls._URL)
        else:
            return cls._get_generator(cls._URL,
                                      to_dict=dict_generator)
开发者ID:atticusliu,项目名称:ThreatExchange,代码行数:20,代码来源:threat_exchange_member.py

示例8: objects

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def objects(cls,
                full_response=False,
                dict_generator=False,
                retries=None,
                headers=None,
                proxies=None,
                verify=None):
        """
        Get a list of Threat Exchange Members

        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: Generator, dict (using json.loads())
        """

        if full_response:
            return Broker.get(cls._URL,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            return cls._get_generator(cls._URL,
                                      to_dict=dict_generator,
                                      retries=retries,
                                      headers=headers,
                                      proxies=proxies,
                                      verify=verify)
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:42,代码来源:threat_exchange_member.py

示例9: details

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def details(cls_or_self,
                id=None,
                fields=None,
                connection=None,
                full_response=False,
                dict_generator=False,
                retries=None,
                headers=None,
                proxies=None,
                verify=None,
                metadata=False):
        """
        Get object details. Allows you to limit the fields returned in the
        object's details. Also allows you to provide a connection. If a
        connection is provided, the related objects will be returned instead
        of the object itself.

        NOTE: This method can be used on both instantiated and uninstantiated
        classes like so:

            foo = ThreatIndicator(id='1234')
            foo.details()

            foo = ThreatIndicator.details(id='1234')


        BE AWARE: Due to the nature of ThreatExchange allowing you to query for
        an object by ID but not actually telling you the type of object returned
        to you, using an ID for an object of a different type (ex: ID for a
        Malware object using ThreatIndicator class) will result in the wrong
        object populated with only data that is common between the two objects.

        :param id: The ID of the object to get details for if the class is not
                   instantiated.
        :type id: str
        :param fields: The fields to limit the details to.
        :type fields: None, str, list
        :param connection: The connection to find other related objects with.
        :type connection: None, str
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :param metadata: Get extra metadata in the response.
        :type metadata: bool
        :returns: Generator, dict, class
        """

        if isinstance(cls_or_self, type):
            url = t.URL + t.VERSION + id + '/'
        else:
            url = cls_or_self._DETAILS
        if connection:
            url = url + connection + '/'
        params = Broker.build_get_parameters()
        if isinstance(fields, basestring):
            fields = fields.split(',')
        if fields is not None and not isinstance(fields, list):
            raise pytxValueError('fields must be a list')
        if fields is not None:
            params[t.FIELDS] = ','.join(f.strip() for f in fields)
        if metadata:
            params[t.METADATA] = 1
        if full_response:
            return Broker.get(url,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            if connection:
                # Avoid circular imports
                from malware import Malware
                from malware_family import MalwareFamily
                from threat_indicator import ThreatIndicator
                from threat_descriptor import ThreatDescriptor
                conns = {
                    conn.DESCRIPTORS: ThreatDescriptor,
                    conn.DROPPED: Malware,
                    conn.DROPPED_BY: Malware,
                    conn.FAMILIES: MalwareFamily,
                    conn.MALWARE_ANALYSES: Malware,
                    conn.RELATED: ThreatIndicator,
                    conn.THREAT_INDICATORS: ThreatIndicator,
                    conn.VARIANTS: Malware,
                }
                klass = conns.get(connection, None)
                return Broker.get_generator(klass,
                                            url,
#.........这里部分代码省略.........
开发者ID:linearregression,项目名称:ThreatExchange,代码行数:103,代码来源:common.py

示例10: objects

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def objects(cls,
                text=None,
                strict_text=False,
                type_=None,
                threat_type=None,
                fields=None,
                limit=None,
                since=None,
                until=None,
                include_expired=False,
                max_confidence=None,
                min_confidence=None,
                owner=None,
                status=None,
                __raw__=None,
                full_response=False,
                dict_generator=False,
                retries=None,
                headers=None,
                proxies=None,
                verify=None):
        """
        Get objects from ThreatExchange.

        :param text: The text used for limiting the search.
        :type text: str
        :param strict_text: Whether we should use strict searching.
        :type strict_text: bool, str, int
        :param type_: The Indicator type to limit to.
        :type type_: str
        :param threat_type: The Threat type to limit to.
        :type threat_type: str
        :param fields: Select specific fields to pull
        :type fields: str, list
        :param limit: The maximum number of objects to return.
        :type limit: int, str
        :param since: The timestamp to limit the beginning of the search.
        :type since: str
        :param until: The timestamp to limit the end of the search.
        :type until: str
        :param include_expired: Include expired content in your results.
        :type include_expired: bool
        :param max_confidence: The max confidence level to search for.
        :type max_confidence: int
        :param min_confidence: The min confidence level to search for.
        :type min_confidence: int
        :param owner: The owner to limit to. This can be comma-delimited to
                      include multiple owners.
        :type owner: str
        :param status: The status to limit to.
        :type status: str
        :param __raw__: Provide a dictionary to force as GET parameters.
                        Overrides all other arguments.
        :type __raw__: dict
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: Generator, dict (using json.loads())
        """

        if __raw__:
            if isinstance(__raw__, dict):
                params = __raw__
            else:
                raise pytxValueError('__raw__ must be of type dict')
        else:
            params = Broker.build_get_parameters(
                text=text,
                strict_text=strict_text,
                type_=type_,
                threat_type=threat_type,
                fields=fields,
                limit=limit,
                since=since,
                until=until,
                include_expired=include_expired,
                max_confidence=max_confidence,
                min_confidence=min_confidence,
                owner=owner,
                status=status
            )
        if full_response:
            return Broker.get(cls._URL,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
#.........这里部分代码省略.........
开发者ID:linearregression,项目名称:ThreatExchange,代码行数:103,代码来源:common.py

示例11: connections

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def connections(cls_or_self,
                    id=None,
                    connection=None,
                    fields=None,
                    limit=None,
                    full_response=False,
                    dict_generator=False,
                    request_dict=False,
                    retries=None,
                    headers=None,
                    proxies=None,
                    verify=None,
                    metadata=False):
        """
        Get object connections. Allows you to limit the fields returned for the
        objects.

        NOTE: This method can be used on both instantiated and uninstantiated
        classes like so:

            foo = ThreatIndicator(id='1234')
            foo.connections(connections='foo')

            foo = ThreatIndicator.connetions(id='1234'
                                             connections='foo')

        :param id: The ID of the object to get connections for if the class is
                   not instantiated.
        :type id: str
        :param fields: The fields to limit the details to.
        :type fields: None, str, list
        :param limit: Limit the results.
        :type limit: None, int
        :param connection: The connection to find other related objects with.
        :type connection: None, str
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param request_dict: Return a request dictionary only.
        :type request_dict: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :param metadata: Get extra metadata in the response.
        :type metadata: bool
        :returns: Generator, dict, class, str
        """

        if isinstance(cls_or_self, type):
            url = t.URL + t.VERSION + id + '/'
        else:
            url = cls_or_self._DETAILS
        if connection:
            url = url + connection + '/'
        params = Broker.build_get_parameters(limit=limit)
        if isinstance(fields, basestring):
            fields = fields.split(',')
        if fields is not None and not isinstance(fields, list):
            raise pytxValueError('fields must be a list')
        if fields is not None:
            params[t.FIELDS] = ','.join(f.strip() for f in fields)
        if metadata:
            params[t.METADATA] = 1
        if request_dict:
            return Broker.request_dict('GET',
                                       url,
                                       params=params)
        if full_response:
            return Broker.get(url,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            # Avoid circular imports
            from malware import Malware
            from malware_family import MalwareFamily
            from threat_indicator import ThreatIndicator
            from threat_descriptor import ThreatDescriptor
            conns = {
                conn.DESCRIPTORS: ThreatDescriptor,
                conn.DROPPED: Malware,
                conn.DROPPED_BY: Malware,
                conn.FAMILIES: MalwareFamily,
                conn.MALWARE_ANALYSES: Malware,
                conn.RELATED: ThreatIndicator,
                conn.THREAT_INDICATORS: ThreatIndicator,
                conn.VARIANTS: Malware,
            }
            klass = conns.get(connection, None)
            return Broker.get_generator(klass,
#.........这里部分代码省略.........
开发者ID:pkdevboxy,项目名称:ThreatExchange,代码行数:103,代码来源:common.py

示例12: details

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def details(cls_or_self,
                id=None,
                fields=None,
                full_response=False,
                dict_generator=False,
                retries=None,
                headers=None,
                proxies=None,
                verify=None,
                metadata=False):
        """
        Get object details. Allows you to limit the fields returned in the
        object's details.

        NOTE: This method can be used on both instantiated and uninstantiated
        classes like so:

            foo = ThreatIndicator(id='1234')
            foo.details()

            foo = ThreatIndicator.details(id='1234')


        BE AWARE: Due to the nature of ThreatExchange allowing you to query for
        an object by ID but not actually telling you the type of object returned
        to you, using an ID for an object of a different type (ex: ID for a
        Malware object using ThreatIndicator class) will result in the wrong
        object populated with only data that is common between the two objects.

        :param id: The ID of the object to get details for if the class is not
                   instantiated.
        :type id: str
        :param fields: The fields to limit the details to.
        :type fields: None, str, list
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param retries: Number of retries to fetch a page before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :param metadata: Get extra metadata in the response.
        :type metadata: bool
        :returns: Generator, dict, class
        """

        if isinstance(cls_or_self, type):
            url = t.URL + t.VERSION + id + '/'
        else:
            url = cls_or_self._DETAILS
        params = Broker.build_get_parameters()
        if isinstance(fields, basestring):
            fields = fields.split(',')
        if fields is not None and not isinstance(fields, list):
            raise pytxValueError('fields must be a list')
        if fields is not None:
            params[t.FIELDS] = ','.join(f.strip() for f in fields)
        if metadata:
            params[t.METADATA] = 1
        if full_response:
            return Broker.get(url,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            if isinstance(cls_or_self, type):
                return Broker.get_new(cls_or_self,
                                      Broker.get(url,
                                                 params=params,
                                                 retries=retries,
                                                 headers=headers,
                                                 proxies=proxies,
                                                 verify=verify))
            else:
                cls_or_self.populate(Broker.get(url,
                                                params=params,
                                                retries=retries,
                                                headers=headers,
                                                proxies=proxies,
                                                verify=verify))
                cls_or_self._changed = []
开发者ID:pkdevboxy,项目名称:ThreatExchange,代码行数:92,代码来源:common.py

示例13: details

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def details(cls_or_self, id=None, fields=None, connection=None,
                full_response=False, dict_generator=False, metadata=False):
        """
        Get object details. Allows you to limit the fields returned in the
        object's details. Also allows you to provide a connection. If a
        connection is provided, the related objects will be returned instead
        of the object itself.

        NOTE: This method can be used on both instantiated and uninstantiated
        classes like so:

            foo = ThreatIndicator(id='1234')
            foo.details()

            foo = ThreatIndicator.details(id='1234')


        BE AWARE: Due to the nature of ThreatExchange allowing you to query for
        an object by ID but not actually telling you the type of object returned
        to you, using an ID for an object of a different type (ex: ID for a
        Malware object using ThreatIndicator class) will result in the wrong
        object populated with only data that is common between the two objects.

        :param id: The ID of the object to get details for if the class is not
                   instantiated.
        :type id: str
        :param fields: The fields to limit the details to.
        :type fields: None, str, list
        :param connection: The connection to find other related objects with.
        :type connection: None, str
        :param full_response: Return the full response instead of the generator.
                              Takes precedence over dict_generator.
        :type full_response: bool
        :param dict_generator: Return a dictionary instead of an instantiated
                               object.
        :type dict_generator: bool
        :param metadata: Get extra metadata in the response.
        :type metadata: bool
        :returns: Generator, dict, class
        """

        if isinstance(cls_or_self, type):
            url = t.URL + t.VERSION + id + '/'
        else:
            url = cls_or_self._DETAILS
        if connection:
            url = url + connection + '/'
        params = Broker.build_get_parameters()
        if isinstance(fields, basestring):
            fields = fields.split(',')
        if fields is not None and not isinstance(fields, list):
            raise pytxValueError('fields must be a list')
        if fields is not None:
            params[t.FIELDS] = ','.join(f.strip() for f in fields)
        if metadata:
            params[t.METADATA] = 1
        if full_response:
            return Broker.get(url, params=params)
        else:
            if connection:
                return Broker.get_generator(cls_or_self,
                                            url,
                                            t.NO_TOTAL,
                                            to_dict=dict_generator,
                                            params=params)
            else:
                if isinstance(cls_or_self, type):
                    return Broker.get_new(cls_or_self,
                                          Broker.get(url,
                                                     params=params))
                else:
                    cls_or_self.populate(Broker.get(url, params=params))
开发者ID:atticusliu,项目名称:ThreatExchange,代码行数:74,代码来源:common.py

示例14: send

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import get [as 别名]
    def send(cls_or_self,
             id_=None,
             params=None,
             type_=None,
             request_dict=False,
             retries=None,
             headers=None,
             proxies=None,
             verify=None):
        """
        Send custom params to the object URL. If `id` is provided it will be
        appended to the URL. If this is an uninstantiated class we will use the
        object type url (ex: /threat_descriptors/). If this is an instantiated
        object we will use the details URL. The type_ should be either GET or
        POST. We will default to GET if this is an uninstantiated class, and
        POST if this is an instantiated class.

        :param id_: ID of a graph object.
        :type id_: str
        :param params: Parameters to submit in the request.
        :type params: dict
        :param type_: GET or POST
        :type type_: str
        :param request_dict: Return a request dictionary only.
        :type request_dict: bool
        :param retries: Number of retries to submit before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: dict (using json.loads()), str
        """

        if isinstance(cls_or_self, type):
            url = cls_or_self._URL
            if type_ is None:
                type_ = 'GET'
        else:
            url = cls_or_self._DETAILS
            if type_ is None:
                type_ = 'POST'
        if id_ is not None and len(id_) > 0:
            url = url + id_ + '/'
        if params is None:
            params = {}
        if type_ == 'GET':
            if request_dict:
                return Broker.request_dict('GET',
                                           url,
                                           params=params)
            return Broker.get(url,
                              params=params,
                              retries=retries,
                              headers=headers,
                              proxies=proxies,
                              verify=verify)
        else:
            if request_dict:
                return Broker.request_dict('POST',
                                           url,
                                           body=params)
            return Broker.post(url,
                               params=params,
                               retries=retries,
                               headers=headers,
                               proxies=proxies,
                               verify=verify)
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:72,代码来源:common.py


注:本文中的request.Broker.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。