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


Python RequestObject.empty_payload方法代码示例

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


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

示例1: upload

# 需要导入模块: from RequestObject import RequestObject [as 别名]
# 或者: from RequestObject.RequestObject import empty_payload [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:bschmoker,项目名称:threatconnect-python,代码行数:17,代码来源:BatchJobObject.py

示例2: commit

# 需要导入模块: from RequestObject import RequestObject [as 别名]
# 或者: from RequestObject.RequestObject import empty_payload [as 别名]
    def commit(self):
        """ commit victim and related assets, associations """
        r_id = self.id
        ro = RequestObject()
        ro.set_body(self.gen_body)
        ro.set_resource_type(self.resource_type)
        prop = self._resource_properties['add']
        ro.set_description('adding batchjob')
        ro.set_http_method(prop['http_method'])
        ro.set_owner_allowed(prop['owner_allowed'])
        ro.set_request_uri(prop['uri'].format(self._id))
        ro.empty_payload()
        if self._phase == 1:
            # validate all required fields are present
            if self.validate:
                api_response = self._tc.api_request(ro)
                if api_response.headers['content-type'] == 'application/json':
                    api_response_dict = api_response.json()
                    if api_response_dict['status'] == 'Success':
                        r_id = api_response_dict['data']['batchId']
            else:
                self._tc.tcl.debug('Resource Object'.format(self))
                raise RuntimeError('Cannot commit incomplete resource object')

        for ro in self._resource_container.commit_queue(self.id):
            # if self.owner_name is not None:
            #     ro.set_owner(self.owner_name)

            # replace the id
            if self.id != r_id:
                request_uri = str(ro.request_uri.replace(str(self.id), str(r_id)))
                ro.set_request_uri(request_uri)
            self._tc.tcl.debug('Replacing {0} with {1}'.format(self.id, str(r_id)))
            self._tc.tcl.debug('RO {0}'.format(ro))

            api_response2 = self._tc.api_request(ro)
            if api_response2.headers['content-type'] == 'application/json':
                api_response_dict2 = api_response2.json()
                if api_response_dict2['status'] != 'Success':
                    self._tc.tcl.error('API Request Failure: [{0}]'.format(ro.description))

        self.set_id(r_id)

        self.set_phase(0)

        # return object
        return self
开发者ID:bschmoker,项目名称:threatconnect-python,代码行数:49,代码来源:BatchJobObject.py


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