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


Python requests.delete方法代码示例

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


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

示例1: autoscale

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def autoscale(self, proc_type, autoscale):
        """
        Set autoscale rules for the application
        """
        name = '{}-{}'.format(self.id, proc_type)
        # basically fake out a Deployment object (only thing we use) to assign to the HPA
        target = {'kind': 'Deployment', 'metadata': {'name': name}}

        try:
            # get the target for autoscaler, in this case Deployment
            self._scheduler.hpa.get(self.id, name)
            if autoscale is None:
                self._scheduler.hpa.delete(self.id, name)
            else:
                self._scheduler.hpa.update(
                    self.id, name, proc_type, target, **autoscale
                )
        except KubeHTTPException as e:
            if e.response.status_code == 404:
                self._scheduler.hpa.create(
                    self.id, name, proc_type, target, **autoscale
                )
            else:
                # let the user know about any other errors
                raise ServiceUnavailable(str(e)) from e 
开发者ID:deis,项目名称:controller,代码行数:27,代码来源:app.py

示例2: delete_listen_key

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_listen_key(self, listen_key):
        """
        Delete a specific listen key

        :param listen_key: the listenkey you want to delete
        :type listen_key: str

        :return: the response
        :rtype: str or False
        """
        logging.debug("BinanceWebSocketApiRestclient->delete_listen_key(" + str(listen_key) + ")")
        method = "delete"
        try:
            return self._request(method, self.path_userdata, False, {'listenKey': str(listen_key)})
        except KeyError:
            return False
        except TypeError:
            return False 
开发者ID:oliver-zehentleitner,项目名称:unicorn-binance-websocket-api,代码行数:20,代码来源:unicorn_binance_websocket_api_restclient.py

示例3: delete_post

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_post(self, pk, force=False):
        """
        Delete a Post.

        Arguments
        ---------

        pk : int
            The post id you want to delete.
        force : bool
            Whether to bypass trash and force deletion.
        """
        resp = self._delete('posts/{0}'.format(pk), params=locals())

        if resp.status_code == 200:
            return True
        else:
            raise Exception(resp.json())

    # Post Reivion Methods 
开发者ID:myles,项目名称:python-wp,代码行数:22,代码来源:api.py

示例4: delete_request

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_request(common_name, user="root"):
    # Validate CN
    if not re.match(const.RE_COMMON_NAME, common_name):
        raise ValueError("Invalid common name")

    path, buf, csr, submitted = get_request(common_name)
    os.unlink(path)

    logger.info("Rejected signing request %s by %s" % (
        common_name, user))

    # Publish event at CA channel
    push.publish("request-deleted", common_name)

    # Write empty certificate to long-polling URL
    requests.delete(
        config.LONG_POLL_PUBLISH % hashlib.sha256(buf).hexdigest(),
        headers={"User-Agent": "Certidude API"}) 
开发者ID:laurivosandi,项目名称:certidude,代码行数:20,代码来源:authority.py

示例5: test_50_docker_rabbitmq

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def test_50_docker_rabbitmq(self):
        try:
            os.environ['RABBITMQ_NAME'] = 'rabbitmq'
            os.environ['RABBITMQ_PORT_5672_TCP_ADDR'] = 'localhost'
            os.environ['RABBITMQ_PORT_5672_TCP_PORT'] = '5672'
            ctx = run.cli.make_context('test', [], None,
                                       obj=dict(testing_mode=True))
            ctx = run.cli.invoke(ctx)
            queue = ctx.obj.newtask_queue
            queue.put('abc')
            queue.delete()
        except Exception as e:
            self.assertIsNone(e)
        finally:
            del os.environ['RABBITMQ_NAME']
            del os.environ['RABBITMQ_PORT_5672_TCP_ADDR']
            del os.environ['RABBITMQ_PORT_5672_TCP_PORT'] 
开发者ID:binux,项目名称:pyspider,代码行数:19,代码来源:test_run.py

示例6: do_delete

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def do_delete(self, command, dry_run=False):
        '''
        Perform Delete

        :param command: String DELETE command to send to the REST endpoint
        :param dry_run: If true, will do a dry run with no actual execution of functionality.
        :return: Dict with response and status code/status
        '''

        ## TODO add timeout and exception handling (Timeout exeception)
        if self.verbose:
            print("DO DELETE")
            print(command)
        if dry_run:
            return({c_SUCCESS_RET_KEY: True,c_CODE_RET_KEY: c_DELETE_OK})
        head = {c_AUTH: 'token {}'.format(self.token), 'Accept': 'application/json'}
        return(self.check_api_return(requests.delete(command, headers=head, verify=self.verify_https))) 
开发者ID:broadinstitute,项目名称:single_cell_portal,代码行数:19,代码来源:scp_api.py

示例7: delete_study_external_resource

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_study_external_resource(self, study_name,
                                       resource_id,
                                       dry_run=False):
        '''
        Delete a study's external resource using the REST API.

        :param study_name: String study name
        :param resource_ids: String Id of external resource to delete
        :param dry_run: If true, will do a dry run with no actual execution of functionality.
        :return: Response
        '''
        if self.verbose: print("LOOKING AT " + study_name)
        # Error if the study does not exist
        if not self.study_exists(study_name=study_name, dry_run=dry_run) and not dry_run:
            return {
                c_SUCCESS_RET_KEY: False,
                c_CODE_RET_KEY: c_STUDY_DOES_NOT_EXIST
            }
        # Convert study name to study id
        study_id = self.study_name_to_id(study_name, dry_run=dry_run)
        ret_delete = self.do_delete(command=self.api_base + "studies/"+str(study_id) +
                                    "/external_resources/" + resource_id,
                                    dry_run=dry_run)

        return(ret_delete) 
开发者ID:broadinstitute,项目名称:single_cell_portal,代码行数:27,代码来源:scp_api.py

示例8: unsubscribe

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def unsubscribe(self, user_id):
        """Unsubscribe the given user.

        Args:
            user_id: ID of the user to unsubscribe.

        Returns: If successful, returns the ID of the unsubscribed user.

        """
        request_url = API_URL + 'users/' + str(user_id) + '/subscriptions'
        r = requests.delete(url=request_url, cookies={'jwt_token': self.jwt})

        json_response = r.json()
        removed_subscription = json_response['removedSubscription']

        return removed_subscription

    # --- Deck CRUD 
开发者ID:floscha,项目名称:tinycards-python-api,代码行数:20,代码来源:rest_api.py

示例9: delete_deck

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_deck(self, deck_id):
        """Delete an existing deck.

        Args:
            deck_id (str): The ID of the Deck to delete.

        Returns:
            Deck: The deleted Deck object if deletion was successful.

        """
        if not isinstance(deck_id, str):
            raise ValueError("'deck_id' parameter must be of type str")

        headers = DEFAULT_HEADERS

        r = requests.delete(url=API_URL + 'decks/' + deck_id, headers=headers,
                            cookies={'jwt_token': self.jwt})

        json_data = r.json()
        deleted_deck = json_converter.json_to_deck(json_data)

        return deleted_deck

    # --- Favorites CR(U)D 
开发者ID:floscha,项目名称:tinycards-python-api,代码行数:26,代码来源:rest_api.py

示例10: remove_favorite

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def remove_favorite(self, user_id, favorite_id):
        """Add a deck to the current user's favorites.

        Args:
            user_id (int): ID of the user to favorite the deck for.
            favorite_id (str): The ID of the favorite to be removed.

        Returns:
            str: The ID of the removed favorite.

        """
        request_url = API_URL + 'users/%d/favorites/%s' % (user_id,
                                                           favorite_id)
        r = requests.delete(url=request_url, cookies={'jwt_token': self.jwt})

        json_response = r.json()
        removed_favorite_id = json_response['removedFavoriteId']

        return removed_favorite_id

    # --- Search 
开发者ID:floscha,项目名称:tinycards-python-api,代码行数:23,代码来源:rest_api.py

示例11: __api_call

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def __api_call(self, url, http_method, data):
        #logger.debug('url:: %s http_method:: %s data:: %s headers:: %s', url, http_method, data, headers)
        headers = {"Content-Type": "application/json"} 
        if(len(self.__access_token) > 100):
            headers['X-Authorization-Token'] = self.__access_token
            headers['Connection'] = 'keep-alive'
        else:
            headers['client_id'] = self.__username
            headers['authorization'] = f"Bearer {self.__access_token}"
        r = None
        if http_method is Requests.POST:
            r = requests.post(url, data=json.dumps(data), headers=headers)
        elif http_method is Requests.DELETE:
            r = requests.delete(url, headers=headers)
        elif http_method is Requests.PUT:
            r = requests.put(url, data=json.dumps(data), headers=headers)
        elif http_method is Requests.GET:
            r = requests.get(url, headers=headers)
        return r 
开发者ID:krishnavelu,项目名称:alice_blue,代码行数:21,代码来源:alice_blue.py

示例12: _request

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def _request(self, uri, method="GET", json=None):
        if self.api_token:
            headers = {"Authorization": "Bearer {0}".format(self.api_token)}
        else:
            headers = {"X-Auth-Email": self.auth_email, "X-Auth-Key": self.auth_key}

        logger.info("Sending request: {0} {1} data: {2}".format(method, uri, json))

        if method == "GET":
            resp = requests.get(uri, headers=headers)
        elif method == "POST":
            resp = requests.post(uri, headers=headers, json=json)
        elif method == "PUT":
            resp = requests.put(uri, headers=headers, json=json)
        elif method == "DELETE":
            resp = requests.delete(uri, headers=headers)
        else:
            raise Exception("Unknown request method: {0}".format(method))

        if not resp.ok:
            raise Exception(
                "Got HTTP code {0}: {1}".format(resp.status_code, resp.text)
            )

        return resp.json() 
开发者ID:cloudflare,项目名称:salt-cloudflare,代码行数:27,代码来源:cloudflare.py

示例13: delete

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete(self, endpoint_url, data=None, params=None, auth=None):
        """
        :param str      endpoint_url:   the API endpoint to request
        :param dict     data:           the POST body
        :param bool     auth:           do HMAC auth
        :rtype: requests.Response
        """
        if auth is True:
            auth = self.auth

        data = json.dumps(data)

        params = dict_merge(self.default_params, params)

        headers = dict_merge(self.default_headers, {
            'Date': RestClient.httpdate(datetime.datetime.utcnow()),
            'Content-MD5': RestClient.content_md5(urlparse(self.api_endpoint + endpoint_url).path + "?" + urlencode(params)),
            'Content-Type': 'application/json'
        })

        response = requests.delete(self.api_endpoint + endpoint_url, data=data, params=params, headers=headers, auth=auth)

        return self.handle_response(response) 
开发者ID:blocktrail,项目名称:blocktrail-sdk-python,代码行数:25,代码来源:connection.py

示例14: delete_job

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete_job(args):
    if args.name is None:
        logger.error("Please provide a valid name of a job.")
    else:

        if not query_yes_no("Do you want to delete the job %s?" % args.name):
            logger.error("Aborting...")
            sys.exit(1)

        job_id = find_job_id_by_name(args)
        if job_id:
            url = urljoin(args.url, "/api/job/%s" % job_id)
            response = requests.delete(url, headers={'Authorization': args.token,
                                                     'content-type': 'application/json'},
                                       verify=args.ssl_verify)
            if response.status_code != 200:
                logging.error("Could not delete job %s: %s" % (args.name, response.text))
            else:
                logging.info("Deleted job %s." % args.name)
        else:
            logging.error("Could not find job %s." % args.name) 
开发者ID:fkie-cad,项目名称:LuckyCAT,代码行数:23,代码来源:fuzzjob_manager.py

示例15: delete

# 需要导入模块: import requests [as 别名]
# 或者: from requests import delete [as 别名]
def delete(self, target):
        full_url = urljoin(
                self.endpoint,
                target)

        r = requests.delete(
                full_url,
                headers={
                    "Authorization": "Bearer {}".format(self.service_token),
                    },
                timeout=self.timeout,
                verify=self.server_cert_ca_path)

        if not r.ok:
            log.error('An unexpected error occurred for target "%s": %i %s - %s',
                      target, r.status_code, r.reason, r.raw)
        r.raise_for_status()

        return r.json() 
开发者ID:intel,项目名称:workload-collocation-agent,代码行数:21,代码来源:kubeapi.py


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