oracle / oracle/oci-python-sdk
Tags - using usage_api call
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 474
- Forks
- 321
- Avg merge
- 23m
- Merged PRs (30d)
- 4
Description
Hi all,
i am trying to get all the tags associated for a resource weather it comes under defined tags or free form tags. and i am using usage_api.usageapiclient using the usage_api.models.requestsummarizedusagedetails and in the group_by filed i am giving 4 values which are resourceId, tagKey, tagNamespace, tagValue. and i am getting the response.
in this response we are seeing the tag column but we are getting only a single record or set of tagKey, tagNamespace, tagValue instead of all the key and values for that associated resource and also missing some key value pairs.
is this an expected behaviour or am i missing some thing here?
below i am attaching the code and response
identity = oci.identity.IdentityClient(config)
user = identity.get_user(config["user"]).data
identity_client = oci.identity.IdentityClient(config)
tenancy_id = config["tenancy"]
start_date = datetime.utcnow().replace(second=0, microsecond=0, minute=0,hour=0).replace(tzinfo=None) - timedelta(days = 30)
end_date = datetime.utcnow().replace(second=0, microsecond=0, minute=0,hour=0).replace(tzinfo=None)
usage_client = oci.usage_api.UsageapiClient(config)
requestSummarizedUsagesDetails = oci.usage_api.models.RequestSummarizedUsagesDetails(
tenant_id=tenancy_id,
granularity='DAILY',
query_type='COST',
group_by=['resourceId', 'tagKey', 'tagValue', 'skuName'],
time_usage_started=start_date,
time_usage_ended=end_date
)
usageClient.request_summarized_usages
request_summarized_usages = usage_client.request_summarized_usages(
requestSummarizedUsagesDetails,
retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY
)
file = '/home/ubuntu/Desktop/example2.txt'
temp = str(request_summarized_usages.data.items)
with open (file, 'w') as f:
f.write(temp)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python usage_api.UsageapiClient.request_summarized_usages call and the attached example2.txt response. Compare the requested group_by fields with the Usage API behavior and determine whether missing tag combinations are expected or indicate a service or SDK issue. Done means documenting the expected behavior or identifying a reproducible defect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100