如何使用 Google Python Cloud Functions Client 获取 Google Cloud Functions 的列表?
How can I get a list of Google Cloud Functions using Google Python Client for Cloud Functions?
我想执行我认为相当简单的任务 - 使用 python 我想获得给定项目中的 Google 云功能列表,并想找出正确的这样做的库。
我正在尝试了解 https://github.com/googleapis 上的无数回购协议。我可以看到有
但是在 https://github.com/googleapis/google-api-python-client#other-google-api-libraries 中指出:
The maintainers of this repository recommend using Cloud Client Libraries for Python, where possible, for new code development
然后 link 将我带到
其中有一个link到
由于 https://github.com/googleapis/google-api-python-client#other-google-api-libraries.
中所述的原因,这似乎是更适合使用的库 (pip install google-cloud-functions
)
我遇到的问题是,似乎有很多 examples/samples 证明了 https://github.com/googleapis/google-api-python-client 的用法,但 https://github.com/googleapis/python-functions 的证明较少。事实上,我的 google-fu 让我很失望,因为我找不到任何示例来说明如何使用 https://github.com/googleapis/python-functions 来完成我的任务(即获取 Google 云函数的列表) . https://googleapis.dev/python/cloudfunctions/latest/index.html 上的 API 文档有些帮助,但似乎缺少样本代码。例如,我问自己的一个问题是我应该使用
或
或者甚至是其他东西。
谁能解释一下如何使用 CloudFunctionsServiceClient
或 CloudFunctionsServiceAsyncClient
来获取函数列表?
想通了。这些工作
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceAsyncClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceAsyncClient().list_functions(list_functions_request)
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceClient().list_functions(list_functions_request)
我想执行我认为相当简单的任务 - 使用 python 我想获得给定项目中的 Google 云功能列表,并想找出正确的这样做的库。
我正在尝试了解 https://github.com/googleapis 上的无数回购协议。我可以看到有
但是在 https://github.com/googleapis/google-api-python-client#other-google-api-libraries 中指出:
The maintainers of this repository recommend using Cloud Client Libraries for Python, where possible, for new code development
然后 link 将我带到
其中有一个link到
由于 https://github.com/googleapis/google-api-python-client#other-google-api-libraries.
中所述的原因,这似乎是更适合使用的库 (pip install google-cloud-functions
)
我遇到的问题是,似乎有很多 examples/samples 证明了 https://github.com/googleapis/google-api-python-client 的用法,但 https://github.com/googleapis/python-functions 的证明较少。事实上,我的 google-fu 让我很失望,因为我找不到任何示例来说明如何使用 https://github.com/googleapis/python-functions 来完成我的任务(即获取 Google 云函数的列表) . https://googleapis.dev/python/cloudfunctions/latest/index.html 上的 API 文档有些帮助,但似乎缺少样本代码。例如,我问自己的一个问题是我应该使用
或
或者甚至是其他东西。
谁能解释一下如何使用 CloudFunctionsServiceClient
或 CloudFunctionsServiceAsyncClient
来获取函数列表?
想通了。这些工作
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceAsyncClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceAsyncClient().list_functions(list_functions_request)
from google.cloud.functions_v1.services.cloud_functions_service import CloudFunctionsServiceClient
from google.cloud.functions_v1.types import ListFunctionsRequest
list_functions_request = ListFunctionsRequest(parent=f"projects/{project}/locations/{region}")
await CloudFunctionsServiceClient().list_functions(list_functions_request)