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


Python RequestObject.set_content_type方法代码示例

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


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

示例1: upload

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_content_type [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

示例2: download_request

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_content_type [as 别名]
def download_request(self):
    """ """
    # build request object
    request_object = RequestObject(self._drd['name1'], self._drd['name2_method']())
    request_object.set_content_type(self._drd['content_type'])
    request_object.set_description(
        self._drd['description'].format(self._drd['identifier_method']()))
    request_object.set_http_method(self._drd['http_method'])
    request_object.set_request_uri(
        self._drd['request_uri_path'].format(self._drd['identifier_method']()))
    request_object.set_owner_allowed(self._drd['owner_allowed'])
    request_object.set_resource_pagination(self._drd['resource_pagination'])
    request_object.set_resource_type(self._drd['resource_type'])

    return request_object
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:17,代码来源:ResourceMethods.py

示例3: upload

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_content_type [as 别名]
    def upload(self, body):
        """ upload batch job  """
        prop = self._resource_properties['batch_job_upload']

        ro = RequestObject()
        ro.set_body(body)
        ro.set_content_type('application/octet-stream')
        ro.set_description('upload batch job for "{0}"'.format(self._id))
        ro.set_http_method(prop['http_method'])
        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)
        ro.empty_payload()
        self._resource_container.add_commit_queue(self.id, ro)
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:17,代码来源:BatchJobObject.py

示例4: RequestObject

# 需要导入模块: from threatconnect.RequestObject import RequestObject [as 别名]
# 或者: from threatconnect.RequestObject.RequestObject import set_content_type [as 别名]
from examples.working_init import *
from threatconnect.RequestObject import RequestObject

""" Toggle the Boolean to enable specific examples """
enable_example1 = False
enable_example2 = False

if enable_example1:
    #
    # build DOCUMENT request object
    #
    ro = RequestObject()
    ro.set_http_method('POST')
    body = {'name': 'Raw Upload Example', 'fileName': 'raw_example.txt'}
    ro.set_body(json.dumps(body))
    ro.set_content_type('application/json')
    ro.set_owner('Example Community')
    ro.set_owner_allowed(True)
    ro.set_resource_pagination(False)
    ro.set_request_uri('/v2/groups/documents')

    # display request object parameters
    print(ro)

    #
    # retrieve and display the results
    #
    results = tc.api_request(ro)
    if results.headers['content-type'] == 'application/json':
        data = results.json()
        print(json.dumps(data, indent=4))
开发者ID:madsc13ntist,项目名称:threatconnect-python,代码行数:33,代码来源:manual_commit.py


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