Skip to content

Conversation

@MarinX
Copy link
Contributor

@MarinX MarinX commented Nov 26, 2025

Closes #339

Adds a new account billing command to retrieve and display billing information for a specific month and year.

Example usage

  upctl account billing --year 2025 --month 7
  upctl account billing --year 2025 --month 1 --resource_id <uuid>
  upctl account billing --year 2025 --month 1 --username <username>
./upctl account billing --year 2025 --month 10
  
  Currency:     EUR      
  Total Amount: 34.31849 
  
  Networks
    Total Amount:       3.255         
    IPv4 Address Total: 3.255         
    Resource 1 ID:      xxxx-xxxx-xxxx 
    Resource 1 Amount:  3.255         
    Resource 1 Hours:   744           
  
  Storages
    Total Amount:      23.064                               
    Storage Total:     23.064                               
    Resource 1 ID:     xxxx-xxxx-xxxx 
    Resource 1 Amount: 23.064                               
    Resource 1 Hours:  744                                  
  
  Servers
    Total Amount:      7.99949                              
    Server Total:      7.99949                              
    Resource 1 ID:     xxxx-xxxx-xxxx 
    Resource 1 Amount: 7.99949                              
    Resource 1 Hours:  672                                  

@MarinX MarinX requested a review from a team as a code owner November 26, 2025 18:02
@kangasta
Copy link
Member

Hello and thank you for another pull request!

I tried testing this, but got an error:

$ upctl account billing --year 2025 --month 11
✗ Command execution failed                                                                                                                                               
  Error: json: cannot unmarshal string into Go struct field BillingResourceDetail.servers.server.resources.details.firewall of type float64
Error: Command execution failed for 1 resource(s)

I guess that might be a bug on the Go SDK side, though. I'll try to dig the raw response data to see how it looks like 👀 Also got an successful result with earlier month.

Comment on lines 118 to 134
for i, resource := range group.Resources {
section.Rows = append(section.Rows, output.DetailRow{
Title: fmt.Sprintf("Resource %d ID:", i+1),
Key: fmt.Sprintf("%s_resource_%d_id", groupName, i+1),
Value: resource.ResourceID,
})
section.Rows = append(section.Rows, output.DetailRow{
Title: fmt.Sprintf("Resource %d Amount:", i+1),
Key: fmt.Sprintf("%s_resource_%d_amount", groupName, i+1),
Value: resource.Amount,
})
section.Rows = append(section.Rows, output.DetailRow{
Title: fmt.Sprintf("Resource %d Hours:", i+1),
Key: fmt.Sprintf("%s_resource_%d_hours", groupName, i+1),
Value: resource.Hours,
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these would be easier to read as a table 🤔

For example instead of:

    Resource 1 ID:      008279cb-4124-4948-a321-d05c17155178 
    Resource 1 Amount:  0.01042                              
    Resource 1 Hours:   1                                    
    ...

something like:

 Resource ID                            Amount    Hours   
────────────────────────────────────── ───────── ──────── 
 008279cb-4124-4948-a321-d05c17155178   0.01042   1       
 ...

Comment on lines 91 to 93
Rows: []output.DetailRow{
{Title: "Total Amount:", Key: "total_amount", Value: category.TotalAmount},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If individual resources would be in category specific tables, maybe these category totals could be in a summary output.DetailsSection in the beginning. For example:

  Summary
    Managed Databases:         4.91665
    Managed Object Storages:   0.59718
    Storages:                  10.19171 (Backup: 0.0468, Storage: 10.14491)
    ...                             

Not sure if that category breakdown would be needed, though 🤔

@kangasta
Copy link
Member

Overall, looks good to me, but I would tune the human readable output a bit 👍

dependabot bot and others added 4 commits December 8, 2025 10:42
…Ltd#608)

Bumps [github/codeql-action](https://github.com/github/codeql-action)
from 4.31.5 to 4.31.6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/releases">github/codeql-action's
releases</a>.</em></p>
<blockquote>
<h2>v4.31.6</h2>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>4.31.6 - 01 Dec 2025</h2>
<p>No user facing changes.</p>
<p>See the full <a
href="https://github.com/github/codeql-action/blob/v4.31.6/CHANGELOG.md">CHANGELOG.md</a>
for more information.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/blob/main/CHANGELOG.md">github/codeql-action's
changelog</a>.</em></p>
<blockquote>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>[UNRELEASED]</h2>
<p>No user facing changes.</p>
<h2>4.31.6 - 01 Dec 2025</h2>
<p>No user facing changes.</p>
<h2>4.31.5 - 24 Nov 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.23.6. <a
href="https://redirect.github.com/github/codeql-action/pull/3321">#3321</a></li>
</ul>
<h2>4.31.4 - 18 Nov 2025</h2>
<p>No user facing changes.</p>
<h2>4.31.3 - 13 Nov 2025</h2>
<ul>
<li>CodeQL Action v3 will be deprecated in December 2026. The Action now
logs a warning for customers who are running v3 but could be running v4.
For more information, see <a
href="https://github.blog/changelog/2025-10-28-upcoming-deprecation-of-codeql-action-v3/">Upcoming
deprecation of CodeQL Action v3</a>.</li>
<li>Update default CodeQL bundle version to 2.23.5. <a
href="https://redirect.github.com/github/codeql-action/pull/3288">#3288</a></li>
</ul>
<h2>4.31.2 - 30 Oct 2025</h2>
<p>No user facing changes.</p>
<h2>4.31.1 - 30 Oct 2025</h2>
<ul>
<li>The <code>add-snippets</code> input has been removed from the
<code>analyze</code> action. This input has been deprecated since CodeQL
Action 3.26.4 in August 2024 when this removal was announced.</li>
</ul>
<h2>4.31.0 - 24 Oct 2025</h2>
<ul>
<li>Bump minimum CodeQL bundle version to 2.17.6. <a
href="https://redirect.github.com/github/codeql-action/pull/3223">#3223</a></li>
<li>When SARIF files are uploaded by the <code>analyze</code> or
<code>upload-sarif</code> actions, the CodeQL Action automatically
performs post-processing steps to prepare the data for the upload.
Previously, these post-processing steps were only performed before an
upload took place. We are now changing this so that the post-processing
steps will always be performed, even when the SARIF files are not
uploaded. This does not change anything for the
<code>upload-sarif</code> action. For <code>analyze</code>, this may
affect Advanced Setup for CodeQL users who specify a value other than
<code>always</code> for the <code>upload</code> input. <a
href="https://redirect.github.com/github/codeql-action/pull/3222">#3222</a></li>
</ul>
<h2>4.30.9 - 17 Oct 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.23.3. <a
href="https://redirect.github.com/github/codeql-action/pull/3205">#3205</a></li>
<li>Experimental: A new <code>setup-codeql</code> action has been added
which is similar to <code>init</code>, except it only installs the
CodeQL CLI and does not initialize a database. Do not use this in
production as it is part of an internal experiment and subject to change
at any time. <a
href="https://redirect.github.com/github/codeql-action/pull/3204">#3204</a></li>
</ul>
<h2>4.30.8 - 10 Oct 2025</h2>
<p>No user facing changes.</p>
<h2>4.30.7 - 06 Oct 2025</h2>
<ul>
<li>[v4+ only] The CodeQL Action now runs on Node.js v24. <a
href="https://redirect.github.com/github/codeql-action/pull/3169">#3169</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/github/codeql-action/commit/fe4161a26a8629af62121b670040955b330f9af2"><code>fe4161a</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/3336">#3336</a>
from github/update-v4.31.6-ecec1f887</li>
<li><a
href="https://github.com/github/codeql-action/commit/88c2ab5eee3b475eef2f7aabf89bd9f052153d91"><code>88c2ab5</code></a>
Update changelog for v4.31.6</li>
<li><a
href="https://github.com/github/codeql-action/commit/ecec1f88769052ebc45aa0affc53ea30d474cffa"><code>ecec1f8</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/3335">#3335</a>
from github/mbg/ci/run-codeql-on-all-prs</li>
<li><a
href="https://github.com/github/codeql-action/commit/23da73277866951560f258278028b48f68958a0a"><code>23da732</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/3334">#3334</a>
from github/kaspersv/overlay-minor-comments</li>
<li><a
href="https://github.com/github/codeql-action/commit/f7abc748a3da068e17cfd0e1086e8d72e51f17b6"><code>f7abc74</code></a>
Remove branch filter for PR event in CodeQL workflow</li>
<li><a
href="https://github.com/github/codeql-action/commit/32ada5e061c0433b9e40f11632c2412a55b745f9"><code>32ada5e</code></a>
Merge branch 'main' into kaspersv/overlay-minor-comments</li>
<li><a
href="https://github.com/github/codeql-action/commit/75b2f49aeaf4e8a9eab338ddc5d628eea7366eeb"><code>75b2f49</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/3333">#3333</a>
from github/kaspersv/overlay-no-resource-checks-option</li>
<li><a
href="https://github.com/github/codeql-action/commit/f036b1cb781fa664100fee1f7c56a0088663dd26"><code>f036b1c</code></a>
Merge branch 'main' into kaspersv/overlay-no-resource-checks-option</li>
<li><a
href="https://github.com/github/codeql-action/commit/58c5954801c246a3975b658372285b37c45de271"><code>58c5954</code></a>
Add comment to runnerSupportsOverlayAnalysis</li>
<li><a
href="https://github.com/github/codeql-action/commit/b02fa13292ce189c02cbb1ba5488f7dbbc8c6b14"><code>b02fa13</code></a>
Order feature flags alphabetically</li>
<li>Additional commits viewable in <a
href="https://github.com/github/codeql-action/compare/fdbfb4d2750291e159f0156def62b853c2798ca2...fe4161a26a8629af62121b670040955b330f9af2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github/codeql-action&package-manager=github_actions&previous-version=4.31.5&new-version=4.31.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@MarinX
Copy link
Contributor Author

MarinX commented Dec 8, 2025

changed the output to table format.
added category total to summary.

  Summary:

     Resource     Amount
    ────────── ──────────
     Networks    0.37625
     Storages      2.666
     Servers     8.13787
     Total      11.18012

  Networks - IPv4 Address Resources:

     Resource ID      Amount   Hours
    ─────────────── ───────── ───────
     XX.XXX.XX.X   0.37625      86

  Storages - Storage Resources:

     Resource ID                            Amount   Hours
    ────────────────────────────────────── ──────── ───────
     XXXX-XXXX-XXXX    2.666      86

  Servers - Server Resources:

     Resource ID                             Amount   Hours
    ────────────────────────────────────── ───────── ───────
     XXXX-XXXX-XXXX   0.13838      31
     XXXX-XXXX-XXXX   7.99949     672

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.

Support getting billing summary

2 participants