How can we retrieve the cost of child tenancies using the OCI Python SDK and the Usage API?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
Direzione di ricerca
La issue contiene un esempio Python che usa oci.usage_api.UsageapiClient e request_summarized_usages, ma non indica alcun file del repository né alcun test. Inizia esaminando la richiesta alla Usage API e i parametri di tenancy mostrati nell’esempio. Il lavoro sarebbe considerato completato con una spiegazione o documentazione chiara e verificata su come recuperare i costi delle tenancy figlie dalla tenancy principale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
How can we retrieve the costs of child tenancies using the OCI Python SDK and the Usage API.
Suppose I have four child tenancies, each associated with a single parent tenancy. I need to fetch the costs of those child tenancies with parent tenancies using Usage API calls.
@adizohar, can you guide me on how to achieve this?.
import oci
config = oci.config.from_file()
tenant_id = config['tenancy']
time_usage_started = "2024-04-01T00:00:00Z"
time_usage_ended = "2024-04-21T00:00:00Z"
lis=[]
usage_client = oci.usage_api.UsageapiClient(config,timeout=(10,3000))
requestSummarizedUsagesDetails = oci.usage_api.models.RequestSummarizedUsagesDetails(
tenant_id=tenant_id,
granularity='DAILY',
query_type='USAGE',
group_by=[ 'resourceId','service','compartmentName'],
time_usage_started=time_usage_started,
time_usage_ended=time_usage_ended,
compartment_depth=2
)
# CUSTOM_RETRY_STRATEGY = RetryStrategyBuilder().add_max_attempts(max_attempts=8) \
# .add_total_elapsed_time(total_elapsed_time_seconds=25000) \
# .add_service_error_check(service_error_retry_config=retry_checkers.RETRYABLE_STATUSES_AND_CODES,
# service_error_retry_on_any_5xx=True) \
# .get_retry_strategy()
# Retrieve summarized usage data
request_summarized_usages = usage_client.request_summarized_usages(
requestSummarizedUsagesDetails,
retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY
)
for item in request_summarized_usages.data.items:
print(len(item.resource_id))
- Lingua principale
- Python
- Stelle
- 474
- Fork
- 321
- Merge medio
- 23m
- PR unite (30g)
- 4
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oracle/oci-python-sdk
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
oracle/oci-python-sdk#890 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
oracle/oci-python-sdk#879 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
oracle/oci-python-sdk#878 ·
-
SDK
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
oracle/oci-python-sdk#861 · 5 commenti ·
-
SDK
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
oracle/oci-python-sdk#852 ·
Tutte le issue di oracle/oci-python-sdk
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·