當前位置: 首頁>>代碼示例>>Python>>正文


Python http.HttpRequest方法代碼示例

本文整理匯總了Python中googleapiclient.http.HttpRequest方法的典型用法代碼示例。如果您正苦於以下問題:Python http.HttpRequest方法的具體用法?Python http.HttpRequest怎麽用?Python http.HttpRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在googleapiclient.http的用法示例。


在下文中一共展示了http.HttpRequest方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_report_file

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def get_report_file(
        self, file_id: str, profile_id: str, report_id: str
    ) -> http.HttpRequest:
        """
        Retrieves a media part of report file.

        :param profile_id: The DFA user profile ID.
        :type profile_id: str
        :param report_id: The ID of the report.
        :type report_id: str
        :param file_id: The ID of the report file.
        :type file_id: str
        :return: googleapiclient.http.HttpRequest
        """
        request = (
            self.get_conn()  # pylint: disable=no-member
            .reports()
            .files()
            .get_media(fileId=file_id, profileId=profile_id, reportId=report_id)
        )
        return request 
開發者ID:apache,項目名稱:airflow,代碼行數:23,代碼來源:campaign_manager.py

示例2: __init__

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def __init__(self, http, baseUrl, model, requestBuilder, developerKey,
               resourceDesc, rootDesc, schema):
    """Build a Resource from the API description.

    Args:
      http: httplib2.Http, Object to make http requests with.
      baseUrl: string, base URL for the API. All requests are relative to this
          URI.
      model: googleapiclient.Model, converts to and from the wire format.
      requestBuilder: class or callable that instantiates an
          googleapiclient.HttpRequest object.
      developerKey: string, key obtained from
          https://code.google.com/apis/console
      resourceDesc: object, section of deserialized discovery document that
          describes a resource. Note that the top level discovery document
          is considered a resource.
      rootDesc: object, the entire deserialized discovery document.
      schema: object, mapping of schema names to schema descriptions.
    """
    self._dynamic_attrs = []

    self._http = http
    self._baseUrl = baseUrl
    self._model = model
    self._developerKey = developerKey
    self._requestBuilder = requestBuilder
    self._resourceDesc = resourceDesc
    self._rootDesc = rootDesc
    self._schema = schema

    self._set_service_methods() 
開發者ID:fniephaus,項目名稱:alfred-gmail,代碼行數:33,代碼來源:discovery.py

示例3: send_all

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def send_all(self, messages, dry_run=False):
        """Sends the given messages to FCM via the batch API."""
        if not isinstance(messages, list):
            raise ValueError('messages must be a list of messaging.Message instances.')
        if len(messages) > 500:
            raise ValueError('messages must not contain more than 500 elements.')

        responses = []

        def batch_callback(_, response, error):
            exception = None
            if error:
                exception = self._handle_batch_error(error)
            send_response = SendResponse(response, exception)
            responses.append(send_response)

        batch = http.BatchHttpRequest(
            callback=batch_callback, batch_uri=_MessagingService.FCM_BATCH_URL)
        for message in messages:
            body = json.dumps(self._message_data(message, dry_run))
            req = http.HttpRequest(
                http=self._transport,
                postproc=self._postproc,
                uri=self._fcm_url,
                method='POST',
                body=body,
                headers=self._fcm_headers
            )
            batch.add(req)

        try:
            batch.execute()
        except googleapiclient.http.HttpError as error:
            raise self._handle_batch_error(error)
        else:
            return BatchResponse(responses) 
開發者ID:firebase,項目名稱:firebase-admin-python,代碼行數:38,代碼來源:messaging.py

示例4: _execute_request

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def _execute_request(
      self,
      request: http.HttpRequest) -> Mapping[Text, Sequence[Mapping[Text, Any]]]:
    result = request.execute()
    if 'error' in result:
      raise ValueError(result['error'])
    return result 
開發者ID:tensorflow,項目名稱:tfx-bsl,代碼行數:9,代碼來源:run_inference.py

示例5: _make_request

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def _make_request(self, body: Mapping[Text, List[Any]]) -> http.HttpRequest:
    return self._api_client.projects().predict(
        name=self._full_model_name, body=body) 
開發者ID:tensorflow,項目名稱:tfx-bsl,代碼行數:5,代碼來源:run_inference.py

示例6: build

# 需要導入模塊: from googleapiclient import http [as 別名]
# 或者: from googleapiclient.http import HttpRequest [as 別名]
def build(serviceName,
          version,
          http=None,
          discoveryServiceUrl=DISCOVERY_URI,
          developerKey=None,
          model=None,
          requestBuilder=HttpRequest,
          credentials=None,
          cache_discovery=True,
          cache=None):
  """Construct a Resource for interacting with an API.

  Construct a Resource object for interacting with an API. The serviceName and
  version are the names from the Discovery service.

  Args:
    serviceName: string, name of the service.
    version: string, the version of the service.
    http: httplib2.Http, An instance of httplib2.Http or something that acts
      like it that HTTP requests will be made through.
    discoveryServiceUrl: string, a URI Template that points to the location of
      the discovery service. It should have two parameters {api} and
      {apiVersion} that when filled in produce an absolute URI to the discovery
      document for that service.
    developerKey: string, key obtained from
      https://code.google.com/apis/console.
    model: googleapiclient.Model, converts to and from the wire format.
    requestBuilder: googleapiclient.http.HttpRequest, encapsulator for an HTTP
      request.
    credentials: oauth2client.Credentials, credentials to be used for
      authentication.
    cache_discovery: Boolean, whether or not to cache the discovery doc.
    cache: googleapiclient.discovery_cache.base.CacheBase, an optional
      cache object for the discovery documents.

  Returns:
    A Resource object with methods for interacting with the service.
  """
  params = {
      'api': serviceName,
      'apiVersion': version
      }

  if http is None:
    http = httplib2.Http()

  requested_url = uritemplate.expand(discoveryServiceUrl, params)

  try:
    content = _retrieve_discovery_doc(requested_url, http, cache_discovery,
                                      cache)
  except HttpError as e:
    if e.resp.status == http_client.NOT_FOUND:
      raise UnknownApiNameOrVersion("name: %s  version: %s" % (serviceName,
                                                               version))
    else:
      raise e

  return build_from_document(content, base=discoveryServiceUrl, http=http,
      developerKey=developerKey, model=model, requestBuilder=requestBuilder,
      credentials=credentials) 
開發者ID:luci,項目名稱:luci-py,代碼行數:63,代碼來源:discovery.py


注:本文中的googleapiclient.http.HttpRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。