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


Python RequestObject.set_http_method方法代码示例

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


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

示例1: VictimAssetFilterObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
class VictimAssetFilterObject(FilterObject):
    """ """

    def __init__(self, base_uri, tcl, victim_asset_type_enum=None):
        """ """
        super(VictimAssetFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # get resource type from indicator type
        if isinstance(victim_asset_type_enum, VictimAssetType):
            # get resource type from indicator type number
            resource_type = ResourceType(victim_asset_type_enum.value)

            # get resource properties from resource type name
            self._properties = ResourceProperties[resource_type.name].value(base_uri=self.base_uri)
        else:
            self._properties = ResourceProperties['VICTIM_ASSETS'].value(base_uri=self.base_uri)

        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('victimAssets', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:36,代码来源:VictimAssets.py

示例2: BulkFilterObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
class BulkFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(BulkFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        # self._properties = BulkProperties(base_uri=self.base_uri)
        self._properties = None
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('groups', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(IndicatorFilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:bschmoker,项目名称:threatconnect-python,代码行数:28,代码来源:Bulk.py

示例3: upload

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
    def upload(self, body):
        """ upload document  """
        if self._resource_type == ResourceType.DOCUMENTS:
            prop = self._resource_properties['document_upload']
        elif self._resource_type == ResourceType.SIGNATURES:
            prop = self._resource_properties['signature_upload']
        else:
            self._tc.tcl.error('Upload requested for wrong resource type.')
            raise AttributeError(ErrorCodes.e10330.value)

        ro = RequestObject()
        ro.set_body(body)
        ro.set_content_type('application/octet-stream')
        ro.set_description('upload document for "{0}"'.format(self._name))
        # determine whether the file contents exist using phase (not 100%)
        if self.phase == 1:
            ro.set_http_method(prop['http_method'])
        else:
            ro.set_http_method('PUT')
        ro.set_owner_allowed(prop['owner_allowed'])
        ro.set_request_uri(prop['uri'].format(self._id))
        ro.set_resource_pagination(prop['pagination'])
        ro.set_resource_type(self._resource_type)
        success_callback = lambda request, response: self.set_contents(request.body)
        ro.set_success_callback(success_callback)
        self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:28,代码来源:GroupObject.py

示例4: SignatureFilterObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
class SignatureFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(SignatureFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        self._properties = SignaturesProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('signatures', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            # special case for download
            if method_name == 'add_id':
                method = getattr(FilterMethods, 'add_id_signature')
                setattr(self, method_name, types.MethodType(method, self))
            else:
                method = getattr(FilterMethods, method_name)
                setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:32,代码来源:Signatures.py

示例5: BulkIndicatorFilterObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
class BulkIndicatorFilterObject(FilterObject):
    """ """

    def __init__(self, base_uri, tcl):
        """ """
        super(BulkIndicatorFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # pd('IndicatorFilterObject', header=True)
        # pd('indicator_type_enum', indicator_type_enum)

        self._properties = BulkIndicatorsProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('indicators', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            # pd('method_name', method_name)
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:31,代码来源:BulkIndicators.py

示例6: add_tag

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def add_tag(self, tag):
     """ add a tag to an indicator """
     prop = self._resource_properties['tag_add']
     ro = RequestObject()
     ro.set_description('add tag "{0}" to "{1}"'.format(tag, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(self._id, self._urlsafe(tag)))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:13,代码来源:GroupObject.py

示例7: default_request_object

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def default_request_object(self):
     """ default request when no filters are provided """
     resource_properties = ApiProperties.api_properties[self._resource_type.name]['properties']
     # create default request object for non-filtered requests
     request_object = RequestObject()
     request_object.set_http_method(resource_properties['base']['http_method'])
     request_object.set_owner_allowed(resource_properties['base']['owner_allowed'])
     request_object.set_request_uri(resource_properties['base']['uri'])
     request_object.set_resource_pagination(resource_properties['base']['pagination'])
     request_object.set_resource_type(self._resource_type)
     return request_object
开发者ID:bschmoker,项目名称:threatconnect-python,代码行数:13,代码来源:Documents.py

示例8: delete_tag

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def delete_tag(self, tag):
     """ delete tag from group """
     prop = self._resource_properties['tag_delete']
     ro = RequestObject()
     ro.set_description('delete tag "{0}" from "{1}"'.format(tag, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(
         self._id, self._urlsafe(tag)))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:14,代码来源:GroupObject.py

示例9: delete_security_label

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def delete_security_label(self, label):
     """ set the security label for this indicator """
     prop = self._resource_properties['security_label_delete']
     ro = RequestObject()
     ro.set_description('delete security label "{0}" from {1}'.format(label, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(
         self._id, self._urlsafe(label)))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:14,代码来源:GroupObject.py

示例10: delete_attribute

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def delete_attribute(self, attr_id):
     """ delete attribute from group by id """
     prop = self._resource_properties['attribute_delete']
     ro = RequestObject()
     ro.set_description('delete attribute id {0} from "{1}"'.format(attr_id, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(
         self._id, attr_id))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:14,代码来源:GroupObject.py

示例11: update_asset

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def update_asset(self, asset_id, asset_obj):
     """ add a asset to a victim """
     prop = self._resource_properties['asset_update']
     ro = RequestObject()
     ro.set_body(asset_obj.gen_body)
     ro.set_description('update asset type {0} with to {1}'.format(asset_obj.resource_type, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(self._id, asset_obj.uri_attribute, asset_id))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:percipient,项目名称:threatconnect-python,代码行数:14,代码来源:VictimObject.py

示例12: VictimFilterObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
class VictimFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(VictimFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        self._properties = VictimsProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('victims', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))

    # special case for indicator associations
    def filter_associations(self, base_resource_type, identifier):
        """Get victims associated with base resource object
        GET /v2/groups/adversaries/747266/victims

        GET /v2/indicators/addresses/4.3.2.1/victims

        """
        base_properties = ResourceProperties[base_resource_type.name].value()

        request_uri = base_properties.base_path + '/'
        request_uri += str(identifier)
        request_uri += '/victims'

        description = 'Get victim associations for {0} resource ({1}).'.format(
            base_resource_type.name.lower(), str(identifier))

        filter_type = 'victim association'
        ro = RequestObject(
            filter_type, '{0}|{1}'.format(base_resource_type.name.lower(), identifier))
        ro.set_description(description)
        ro.set_owner_allowed(False)
        ro.set_resource_pagination(True)
        ro.set_request_uri(request_uri)
        ro.set_resource_type(ResourceType.VICTIMS)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:54,代码来源:Victims.py

示例13: associate_indicator

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def associate_indicator(self, indicator_type, indicator):
     """ associate a group to group by id """
     prop = self._resource_properties['association_indicator_add']
     ro = RequestObject()
     ro.set_description('associate indicator {0} to "{1}"'.format(
         indicator, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_resource_pagination(prop['pagination'])
     indicator_uri_attribute = ApiProperties.api_properties[indicator_type.name]['uri_attribute']
     ro.set_request_uri(prop['uri'].format(indicator_uri_attribute, self._urlsafe(indicator), self.id))
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:15,代码来源:GroupObject.py

示例14: associate_group

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def associate_group(self, resource_type, resource_id):
     """ associate a group to group by id """
     prop = self._resource_properties['association_group_add']
     ro = RequestObject()
     ro.set_description('associate group type "{0}" id {1} to "{2}"'.format(
         resource_type.name, resource_id, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_resource_pagination(prop['pagination'])
     group_uri_attribute = ApiProperties.api_properties[resource_type.name]['uri_attribute']
     ro.set_request_uri(prop['uri'].format(self._id, group_uri_attribute, resource_id))
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:15,代码来源:GroupObject.py

示例15: associate_victim

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_http_method [as 别名]
 def associate_victim(self, resource_id):
     """ associate victim from group """
     prop = self._resource_properties['association_victim_add']
     ro = RequestObject()
     ro.set_description('associate victim id {0} from "{1}"'.format(
         resource_id, self._name))
     ro.set_http_method(prop['http_method'])
     ro.set_owner_allowed(prop['owner_allowed'])
     ro.set_request_uri(prop['uri'].format(
         self._id, resource_id))
     ro.set_resource_pagination(prop['pagination'])
     ro.set_resource_type(self._resource_type)
     self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:15,代码来源:GroupObject.py


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