Skip to content

feat: add api command#1457

Open
phm07 wants to merge 2 commits into
mainfrom
api-command
Open

feat: add api command#1457
phm07 wants to merge 2 commits into
mainfrom
api-command

Conversation

@phm07

@phm07 phm07 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR adds a command that allows users to directly interact with the API.

Closes #1448

@phm07 phm07 self-assigned this Jul 17, 2026
@phm07
phm07 requested a review from a team as a code owner July 17, 2026 09:24
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.27660% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.68%. Comparing base (6f2fcae) to head (95eaa36).

Files with missing lines Patch % Lines
internal/cmd/api/api.go 23.68% 29 Missing ⚠️
internal/hcapi2/client.go 0.00% 4 Missing ⚠️
internal/hcapi2/mock/client.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1457      +/-   ##
==========================================
- Coverage   72.89%   72.68%   -0.22%     
==========================================
  Files         300      301       +1     
  Lines       11127    11173      +46     
==========================================
+ Hits         8111     8121      +10     
- Misses       2118     2154      +36     
  Partials      898      898              
Flag Coverage Δ
e2e 51.23% <23.25%> (-0.13%) ⬇️
unit 67.57% <21.27%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread internal/cmd/api/api.go
var ApiCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Use: "api [options] <path>",

@lukasmetzner lukasmetzner Jul 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if this is relevant for the first iteration, but what about setting Content-Type and defaulting to json?

edit: we already set this in hcloud-go, so we would not need to default here.

Comment thread internal/cmd/api/api.go
return err
}

cmd.Print(string(respBody))

@lukasmetzner lukasmetzner Jul 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we do pretty print with indents, or have it as an option?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You could pipe the output to jq for pretty printing. Not sure if we need to implement this functionality in the CLI

@phm07

phm07 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

We also need to think about how to handle switching between the api.hetzner.cloud and api.hetzner.com endpoints.

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 generic hcloud api subcommand

2 participants