Python googleapiclient.http.HttpRequest() Examples
The following are 16
code examples of googleapiclient.http.HttpRequest().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
googleapiclient.http
, or try the search function
.
Example #1
Source File: campaign_manager.py From airflow with Apache License 2.0 | 6 votes |
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
Example #2
Source File: discovery.py From alfred-gmail with MIT License | 5 votes |
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()
Example #3
Source File: discovery.py From luci-py with Apache License 2.0 | 5 votes |
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()
Example #4
Source File: discovery.py From luci-py with Apache License 2.0 | 5 votes |
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()
Example #5
Source File: discovery.py From luci-py with Apache License 2.0 | 5 votes |
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()
Example #6
Source File: messaging.py From firebase-admin-python with Apache License 2.0 | 5 votes |
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)
Example #7
Source File: run_inference.py From tfx-bsl with Apache License 2.0 | 5 votes |
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
Example #8
Source File: run_inference.py From tfx-bsl with Apache License 2.0 | 5 votes |
def _make_request(self, body: Mapping[Text, List[Any]]) -> http.HttpRequest: return self._api_client.projects().predict( name=self._full_model_name, body=body)
Example #9
Source File: discovery.py From data with GNU General Public License v3.0 | 5 votes |
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()
Example #10
Source File: discovery.py From data with GNU General Public License v3.0 | 5 votes |
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()
Example #11
Source File: discovery.py From luci-py with Apache License 2.0 | 4 votes |
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)
Example #12
Source File: discovery.py From luci-py with Apache License 2.0 | 4 votes |
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)
Example #13
Source File: discovery.py From luci-py with Apache License 2.0 | 4 votes |
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)
Example #14
Source File: discovery.py From luci-py with Apache License 2.0 | 4 votes |
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)
Example #15
Source File: discovery.py From data with GNU General Public License v3.0 | 4 votes |
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)
Example #16
Source File: discovery.py From data with GNU General Public License v3.0 | 4 votes |
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)