英文:
How can I get google cloud cdn Invalidate cache result
问题
我已通过Google Cloud CDN的Python客户端库发送了清除缓存任务,并获得了GCP响应的请求ID。但是,我应该在哪里根据请求ID查询清除缓存任务的进度呢?
我发送请求的地址:https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache
我发送请求的地址:https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache
英文:
I have sent the task of clearing the cache through the python client library of google cloud cdn, and got the request id of the GCP response. However, where can I query the progress of the task of clearing the cache according to the request id.
The address where I send the request: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache
The address where I send the request: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache
答案1
得分: 0
在日志浏览器中,查看 cloudaudit.googleapis.com
feed 并附带您的请求 ID。您还可以使用 protoPayload.request.@type="type.googleapis.com/compute.urlMaps.invalidateCache"
过滤您的日志浏览器日志,以列出所有的失效操作。
您可能需要扩展您的 审计日志记录 权限,否则该信息可能对您不可见。
英文:
In Log Explorer, look under the cloudaudit.googleapis.com
feed along with your request ID. You could also just filter your log explorer logs using protoPayload.request.@type="type.googleapis.com/compute.urlMaps.invalidateCache"
to list all the invalidations made.
You may need to extend your audit logging permissions, else the information may not be visible to you.
答案2
得分: 0
无法使用请求 ID 查询缓存失效的状态;请求 ID 用于去重请求,而不是检索操作的状态。
要检索缓存失效的状态,请使用urlMaps.invalidateCache响应中返回的操作名称。您可以使用globalOperations.get来查询命名操作的状态。
如果您正在使用 Python 客户端库,您可以使用GlobalOperationsClient类。在gcloud的invalidate-cdn-cache
实现中有一个示例。
英文:
You can't query the status of a cache invalidation using the request ID; the request ID is used for deduplicating requests, not retrieving the status of an operation.
To retrieve the status of a cache invalidation, use the operation name returned in the urlMaps.invalidateCache response. You can query the status of the named operation using globalOperations.get.
If you're using the Python client library, you can use the GlobalOperationsClient class. There's an example in gcloud's invalidate-cdn-cache
implementation at github.com/googleapis/python-compute/blob/main/google/cloud/compute_v1/services/url_maps/client.py.
答案3
得分: 0
我通过以下文档中的API查询了Google Cloud CDN的缓存失效结果:https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get
并且我通过以下Python代码获取了我想要的信息:
def get_operation_result(gcp_request_id):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('compute', 'v1', credentials=credentials)
# 此请求的项目ID。
project = 'my-project' # TODO: 更新占位符的值。
# 要返回的操作资源的名称。
operation = gcp_request_id # TODO: 更新占位符的值。
request = service.globalOperations().get(project=project, operation=operation)
response = request.execute()
# TODO: 更改下面的代码以处理`response`字典:
mission_status = response['status']
return mission_status
英文:
I query the Invalidate cache result of Google Cloud CDN through the API in the following document: https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get
And I got the information I want through the following python code:
def get_operation_result(gcp_request_id):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('compute', 'v1', credentials=credentials)
# Project ID for this request.
project = 'my-project' # TODO: Update placeholder value.
# Name of the Operations resource to return.
operation = gcp_request_id # TODO: Update placeholder value.
request = service.globalOperations().get(project=project, operation=operation)
response = request.execute()
# TODO: Change code below to process the `response` dict:
mission_status = response['status']
return mission_status
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论