Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sample Issue] Output format is wrong #4269

Open
2 of 9 tasks
tomasrudh opened this issue Mar 17, 2024 · 1 comment
Open
2 of 9 tasks

[Sample Issue] Output format is wrong #4269

tomasrudh opened this issue Mar 17, 2024 · 1 comment
Assignees
Labels
customer-reported issue-addressed question Further information is requested

Comments

@tomasrudh
Copy link

Link to sample

https://learn.microsoft.com/en-us/rest/api/billing/invoices/list-by-billing-profile?view=rest-billing-2020-05-01&tabs=Python

Library name and version

azure.mgmt.billing 6.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

I run this code:

from azure.mgmt.billing import BillingManagementClient
from azure.identity import ClientSecretCredential

credentials = ClientSecretCredential(
    tenant_id="<TenantID>",
    client_id="<ClientID>",
    client_secret="<ClientSecret>",
    api_version="2020-05-01"
)

client = BillingManagementClient(
    credential=credentials,
    subscription_id='<SubscriptionID>',
)

response = client.invoices.list_by_billing_profile(
    billing_account_name="<BillingAccount>",
    billing_profile_name="<BillingProfile>",
    period_start_date="2024-02-01",
    period_end_date="2024-02-29",
)
for item in response:
    print(item)

I don't get an invoice in return.

Expected behavior

An invoice description in JSON format.

Actual behavior

The sample code give me this output:

{'additional_properties': {}, 'id': '/providers/Microsoft.Billing/billingAccounts/<BillingAccount>/invoices/<Invoice>', 'name': 'G040589327', 'type': 'Microsoft.Billing/billingAccounts/invoices', 'due_date': datetime.datetime(2024,
    4,
    4,
    6,
    7,
    13,
    95965, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_date': datetime.datetime(2024,
    3,
    5,
    6,
    7,
    13,
    95965, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'status': 'Due', 'amount_due': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE779D0>, 'azure_prepayment_applied': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77A50>, 'billed_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77E50>, 'credit_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77E90>, 'free_azure_credit_applied': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77AD0>, 'sub_total': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77ED0>, 'tax_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77F90>, 'total_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77F50>, 'invoice_period_start_date': datetime.datetime(2024,
    2,
    1,
    0,
    0, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_period_end_date': datetime.datetime(2024,
    2,
    29,
    23,
    59,
    59,
    999999, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_type': None, 'is_monthly_invoice': True, 'billing_profile_id': '/providers/Microsoft.Billing/billingAccounts/<BillingAccount>/billingProfiles/<BillingProfile>', 'billing_profile_display_name': 'Formpipe Software Ltd', 'purchase_order_number': '', 'documents': [<azure.mgmt.billing.models._models_py3.Document object at 0x000002FEA11940D0>
    ], 'payments': [], 'rebill_details': None, 'document_type': 'Invoice', 'billed_document_id': None, 'credit_for_document_id': None, 'subscription_id': None
}

If I change to

for item in response:
    print(item.serialize())

I get this output:
{}

Reproduction Steps

Run the example.

Environment

Windows 11
Python 3.11.2

@microsoft-github-policy-service microsoft-github-policy-service bot added question Further information is requested customer-reported labels Mar 17, 2024
@msyyc msyyc self-assigned this Jul 2, 2024
@msyyc
Copy link
Member

msyyc commented Jul 2, 2024

Hi @tomasrudh Please try:

for item in response:
    print(item.serialize(keep_readonly=True))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported issue-addressed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants