本文整理汇总了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