Skip to content

feat(account): add billing summary #385

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

Merged
merged 3 commits into from
Jul 28, 2025
Merged

feat(account): add billing summary #385

merged 3 commits into from
Jul 28, 2025

Conversation

MarinX
Copy link
Contributor

@MarinX MarinX commented Jul 24, 2025

This PR adds billing summary support to the account service.
Follows the API /account/billing/summary/{year-month} endpoint as documented in the account section.

Notes:

  • The BillingCategory and BillingResourceGroup structs handle the nested JSON structure where categories contain both a total_amount and a nested object (e.g., servers.server, managed_databases.managed_database). If there is a better approach, let me know.
  • Some billing categories like storages and networks are not included as they require specific API response examples. If you can provide with that details, I can implement.

@MarinX MarinX requested a review from a team as a code owner July 24, 2025 10:32
@kangasta
Copy link
Member

Thank you for the pull request!

Here's some example data for networks and storages from a test account:

{
  "currency": "EUR",
  "networks": {
    "ipv4_address": {
      "resources": [
        {
          "amount": 0.00438,
          "details": [
            {
              "amount": 0.00438,
              "hours": 1,
              "zone": "fi-hel1"
            }
          ],
          "hours": 1,
          "resource_id": "10.1.2.3"
        }
      ],
      "total_amount": 0.00438
    },
    "total_amount": 0.00438
  },
  "storages": {
    "backup": {
      "resources": [
        {
          "amount": 0.00078,
          "details": [
            {
              "amount": 0.00078,
              "hours": 1,
              "size": 10,
              "zone": "fi-hel1"
            }
          ],
          "hours": 1,
          "resource_id": "01e182d2-eb12-40dd-b473-afdff6300d9b"
        }
      ],
      "total_amount": 0.00078
    },
    "storage": {
      "resources": [
        {
          "amount": 0.00775,
          "details": [
            {
              "amount": 0.00775,
              "hours": 1,
              "labels": [
                {
                  "key": "_os_architecture",
                  "value": "64"
                },
                {
                  "key": "_os_brand_name",
                  "value": "Kubernetes"
                },
                {
                  "key": "_os_brand_version",
                  "value": "1.30"
                },
                {
                  "key": "_os_main_category",
                  "value": "Linux"
                },
                {
                  "key": "_os_storage",
                  "value": "01000000-0000-4000-8000-000020070100"
                },
                {
                  "key": "_os_type",
                  "value": "debian"
                },
                {
                  "key": "_template_uuid",
                  "value": "01000000-0000-4000-8000-000160060100"
                }
              ],
              "size": 25,
              "zone": "fi-hel2"
            }
          ],
          "hours": 1,
          "resource_id": "01bc075d-6bfb-4827-9e51-e49734017614"
        }
      ],
      "total_amount": 0.00775
    },
    "template": {
      "resources": [
        {
          "amount": 0.0031,
          "details": [
            {
              "amount": 0.0031,
              "hours": 1,
              "size": 10,
              "zone": "fi-hel1"
            }
          ],
          "hours": 1,
          "resource_id": "01ee2ceb-882f-4eb0-84a0-968f66449047"
        }
      ],
      "total_amount": 0.0031
    },
    "total_amount": 0.01163
  },
  "total_amount": 0.01601
}

There could also be bandwidth key under networks, but I don't have testdata for that at the moment.

@MarinX
Copy link
Contributor Author

MarinX commented Jul 24, 2025

Perfect. Thanks for the sample JSON.
Updated with additional billing categories.

@kangasta kangasta merged commit a09a159 into UpCloudLtd:main Jul 28, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants