Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

How can we retrieve the cost of child tenancies using the OCI Python SDK and the Usage API?

Đang mở
#763 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
20/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, cloud

Hướng nghiên cứu

Issue chứa một ví dụ Python sử dụng oci.usage_api.UsageapiClient và request_summarized_usages, nhưng không nêu tên tệp repository hoặc bài kiểm thử nào. Hãy bắt đầu bằng việc xem xét request tới Usage API và các tham số tenancy được trình bày trong ví dụ. Công việc được xem là hoàn tất khi có giải thích hoặc tài liệu rõ ràng, đã được xác minh, về cách truy xuất chi phí của các tenancy con từ tenancy cha.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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))
Ngôn ngữ chính
Python
Star
473
Fork
322
Merge trung bình
13 phút
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của oracle/oci-python-sdk

Tất cả issue của oracle/oci-python-sdk

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.