Billing Usage API, gRPC: MetadataService.GetLabel
GetLabel returns available label keys and values for a specific billing account
with pagination support.
This method retrieves all available label values for a specified label key
within the given date range. It supports filtering by label value substring
and provides pagination for handling large result sets.
The method can be used in several ways:
- With label_key only: Returns all values for that key with pagination
- With label_key and label_value: Returns array of matching labelValues with pagination
- With label_key and label_value_filter: Returns all values for that key with pagination
and a separate array of labelValues from the labelValueFilters parameter - With label_key, label_value and label_value_filter: returns only an array of matching labelValues
with pagination and ignores labelValueFilters (i.e., labelValueFilters won't be returned)
Implementation details:
- Case-insensitive label value matching when label_value is provided
- When label_value is specified, label_value_filter is ignored
- Label values are sorted alphabetically
- Pagination occurs when results exceed page_size
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 GetLabel (GetLabelRequest) returns (GetLabelResponse)
GetLabelRequest
{
"billing_account_id": "string",
"start_date": "google.protobuf.Timestamp",
"end_date": "google.protobuf.Timestamp",
"label_key": "string",
"label_value": "string",
"label_value_filter": [
"string"
],
"page_size": "int64",
"page_token": "string"
}
Request for retrieving label metadata
|
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. |
|
label_key |
string Required field. Label key to filter values for. If specified, response will contain values |
|
label_value |
string Optional. If provided along with label_key, the response will return |
|
label_value_filter[] |
string Optional array of label values to filter results: |
|
page_size |
int64 Optional. Page size for paginated results. |
|
page_token |
string Optional. Page token for paginated results. |
GetLabelResponse
{
"label_values": [
"string"
],
"label_value_filter": [
"string"
],
"next_page_token": "string"
}
Response for label metadata request
|
Field |
Description |
|
label_values[] |
string List of label values matching the request criteria |
|
label_value_filter[] |
string List of label values from the label_value_filter in the request |
|
next_page_token |
string Token for getting the next page of results. It should be passed verbatim in subsequent requests. |