本文整理匯總了Python中googleapiclient.discovery.Resource方法的典型用法代碼示例。如果您正苦於以下問題:Python discovery.Resource方法的具體用法?Python discovery.Resource怎麽用?Python discovery.Resource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類googleapiclient.discovery
的用法示例。
在下文中一共展示了discovery.Resource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_conn
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def get_conn(self):
"""
Creates an authenticated api client for the given api service name and credentials.
:return: the authenticated api service.
:rtype: Resource
"""
self.log.info("Authenticating Google API Client")
if not self._conn:
http_authorized = self._authorize()
self._conn = build(
serviceName=self.api_service_name,
version=self.api_version,
http=http_authorized,
cache_discovery=False
)
return self._conn
示例2: _build_client
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def _build_client(self) -> discovery.Resource:
return self._build_arbitrary_client(self._client_name, self._client_version)
示例3: _get_client
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def _get_client(self) -> discovery.Resource:
return self._build_client()
示例4: get_conn
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def get_conn(self) -> Resource:
"""
Retrieves connection to DisplayVideo.
"""
if not self._conn:
http_authorized = self._authorize()
self._conn = build(
"doubleclickbidmanager",
self.api_version,
http=http_authorized,
cache_discovery=False,
)
return self._conn
示例5: get_conn_to_display_video
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def get_conn_to_display_video(self) -> Resource:
"""
Retrieves connection to DisplayVideo.
"""
if not self._conn:
http_authorized = self._authorize()
self._conn = build(
"displayvideo",
self.api_version,
http=http_authorized,
cache_discovery=False,
)
return self._conn
示例6: _paginate
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def _paginate(self, resource: Resource, list_args: Optional[Dict[str, Any]] = None):
list_args = list_args or {}
result: List[Dict] = []
while True:
# start index has value 1
request = resource.list(start_index=len(result) + 1, **list_args) # pylint: disable=no-member
response = request.execute(num_retries=self.num_retries)
result.extend(response.get("items", []))
# result is the number of fetched links from Analytics
# when all links will be added to the result
# the loop will break
if response["totalResults"] <= len(result):
break
return result
示例7: get_conn
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def get_conn(self) -> Resource:
"""
Retrieves connection to Google Analytics 360.
"""
if not self._conn:
http_authorized = self._authorize()
self._conn = build(
"analytics",
self.api_version,
http=http_authorized,
cache_discovery=False,
)
return self._conn
示例8: get_conn
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def get_conn(self) -> Resource:
"""
Retrieves connection to Campaign Manager.
"""
if not self._conn:
http_authorized = self._authorize()
self._conn = build(
"dfareporting",
self.api_version,
http=http_authorized,
cache_discovery=False,
)
return self._conn
示例9: execute
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def execute(self, run=True, iterate=True):
# start building call sequence with service object
self.function = get_service(self.api, self.version, self.auth, uri_file=self.uri)
# build calls along stack
# do not call functions, as the abstract is necessary for iterator page next calls
for f_n in self.function_stack:
#print(type(self.function), isinstance(self.function, Resource))
self.function = getattr(self.function if isinstance(self.function, Resource) else self.function(), f_n)
# for cases where job is handled manually, save the job
self.job = self.function(**self.function_kwargs)
if run:
self.response = API_Retry(self.job)
# if paginated, automatically iterate
if (iterate and (self.iterate or (isinstance(self.response, dict) and 'nextPageToken' in self.response))):
return API_Iterator(self.function, self.function_kwargs, self.response)
# if not paginated, return object as is
else:
return self.response
# if not run, just return job object ( for chunked upload for example )
else:
return self.job
示例10: test_mock_instantiation
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def test_mock_instantiation(self):
service = SheetsService().build(http=self.http_mocks)
assert isinstance(service, Resource)
示例11: __init__
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def __init__(self, cloudsource_service: discovery.Resource):
self._cloudsource_service = cloudsource_service
示例12: __init__
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def __init__(self, billing_service: discovery.Resource):
self._billing_service = billing_service
示例13: __init__
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def __init__(self, storage_service: discovery.Resource):
self._storage_service = storage_service
示例14: __init__
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def __init__(self, sqladmin_service: discovery.Resource):
self._sqladmin_service = sqladmin_service
示例15: __init__
# 需要導入模塊: from googleapiclient import discovery [as 別名]
# 或者: from googleapiclient.discovery import Resource [as 別名]
def __init__(self, service_usage_service: discovery.Resource):
self._service_usage_service = service_usage_service