Billing Usage API, gRPC: MetadataService.GetResources
GetResources returns available resources for specified service instances within a billing account
with optional filtering by service instance IDs, resource IDs and pagination support.
This method returns a hierarchical view of service instances and their resources that the user
has access to within the specified date range. Results can be filtered by
specific service instance IDs and/or resource IDs, and pagination is supported for handling
large result sets.
Implementation details:
- Filtering by resources is done using case-insensitive substring matching
- Filtering is done using case-insensitive substring matching
- Only service instances with at least one resource are included in the response
- Resource pagination is based on resource IDs, ordered alphabetically
- NextPageToken is only returned when there are more results available
- Base64-encoded page tokens are used for pagination state
Error handling:
- Returns INVALID_ARGUMENT if the request parameters fail validation
- Returns UNAUTHENTICATED if the user is not authenticated or the billing account does not exist
- Returns PERMISSION_DENIED if the user lacks required permissions
- Returns INTERNAL for internal server errors
Required permissions:
billing.accounts.getReporton the specified billing account
gRPC request
rpc GetResources (GetResourcesRequest) returns (GetResourcesResponse)
GetResourcesRequest
{
"billing_account_id": "string",
"start_date": "google.protobuf.Timestamp",
"end_date": "google.protobuf.Timestamp",
"service_instances_ids": [
"string"
],
"resource_ids": [
"string"
],
"page_size": "int64",
"page_token": "string"
}
GetResourcesRequest request for retrieving resources with associated service instances.
This message defines the parameters needed to fetch and filter resources
associated with a billing account within a date range.
|
Field |
Description |
|
billing_account_id |
string Required field. Required. Billing account identifier. |
|
start_date |
Required field. Start date for data retrieval. |
|
end_date |
Required field. End date for data retrieval. |
|
service_instances_ids[] |
string Optional. List of service instances IDs to filter service instances by. |
|
resource_ids[] |
string Optional. List of resource IDs to filter resources by. |
|
page_size |
int64 Optional. Page size for paginated results. |
|
page_token |
string Optional. Page token for paginated results. |
GetResourcesResponse
{
"items": [
{
"service_instance": {
"id": "string",
"type": "string",
"name": "string",
"billing_account_id": "string"
},
"resources": [
{
"id": "string",
"name": "string",
"service_instance_type": "string"
}
]
}
],
"next_page_token": "string"
}
The response for resources request.
This message contains a list of resource IDs splited by service instances that match the search criteria
specified in the request, along with pagination information.
|
Field |
Description |
|
items[] |
List of service instances matching the request criteria Note: only service instances with at least one resource are included in the response. |
|
next_page_token |
string Token for getting the next page of results. It should be passed verbatim in subsequent requests. |
ServiceInstanceInfo
Information about a service instances and its resources
|
Field |
Description |
|
service_instance |
Service instance information |
|
resources[] |
List of resources belonging to this service instances Only resources that had usage during the specified date range are included. |
ServiceInstance
Represents a service instance entity
|
Field |
Description |
|
id |
string Identifier of the service instance entity. |
|
type |
string Type of the service instance: tracker, datalens, cloud, etc. |
|
name |
string Human-readable display name of the service instance. |
|
billing_account_id |
string Optional billing account identifier associated with this service instance |
Resource
Represents a resource entity
|
Field |
Description |
|
id |
string Unique identifier of the resource entity. |
|
name |
string Human-readable display name of the resource. |
|
service_instance_type |
string Type of the service instance this resource is bound to (e.g. "cloud", "tracker", "datalens"). |