Skip to content

Commit b17d3ba

Browse files
GG-HHclaude
andcommitted
refactor(api-status): rename Account ID to Workspace ID
Use "Workspace ID" / "workspace_id" consistently in the text and JSON output, matching the upstream API field name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 92bf0cf commit b17d3ba

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

changelog.d/20260525_account_id_api_status.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Added
2+
3+
- `ggshield api-status` now displays the workspace ID associated with the current token, in both text and JSON output.

doc/schemas/api-status.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"items": { "type": "string" },
3939
"description": "List of scopes granted to the current authentication token"
4040
},
41-
"account_id": {
41+
"workspace_id": {
4242
"type": "integer",
43-
"description": "Identifier of the workspace (account) the authentication token belongs to"
43+
"description": "Identifier of the workspace the authentication token belongs to"
4444
}
4545
},
4646
"required": [

ggshield/cmd/status.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def status_cmd(ctx: click.Context, **kwargs: Any) -> int:
3333
raise UnexpectedError("Unexpected health check response")
3434

3535
token_scopes: Optional[List[str]] = None
36-
account_id: Optional[int] = None
36+
workspace_id: Optional[int] = None
3737
token_response = client.api_tokens()
3838
if isinstance(token_response, APITokensResponse):
3939
token_scopes = token_response.scopes
40-
account_id = token_response.workspace_id
40+
workspace_id = token_response.workspace_id
4141

4242
instance, instance_source = ctx_obj.config.get_instance_name_and_source()
4343
_, api_key_source = ctx_obj.config.get_api_key_and_source()
@@ -48,23 +48,23 @@ def status_cmd(ctx: click.Context, **kwargs: Any) -> int:
4848
json_output["api_key_source"] = api_key_source.name
4949
if token_scopes is not None:
5050
json_output["token_scopes"] = token_scopes
51-
if account_id is not None:
52-
json_output["account_id"] = account_id
51+
if workspace_id is not None:
52+
json_output["workspace_id"] = workspace_id
5353
click.echo(json.dumps(json_output))
5454
else:
5555
scopes_line = (
5656
f"{format_text('Token scopes:', STYLE['key'])} {', '.join(token_scopes)}\n"
5757
if token_scopes is not None
5858
else ""
5959
)
60-
account_line = (
61-
f"{format_text('Account ID:', STYLE['key'])} {account_id}\n"
62-
if account_id is not None
60+
workspace_line = (
61+
f"{format_text('Workspace ID:', STYLE['key'])} {workspace_id}\n"
62+
if workspace_id is not None
6363
else ""
6464
)
6565
click.echo(
6666
f"{format_text('API URL:', STYLE['key'])} {instance}\n"
67-
+ account_line
67+
+ workspace_line
6868
+ f"{format_text('Status:', STYLE['key'])} {format_healthcheck_status(response)}\n"
6969
f"{format_text('App version:', STYLE['key'])} {response.app_version or 'Unknown'}\n"
7070
f"{format_text('Secrets engine version:', STYLE['key'])} "

tests/unit/cmd/test_status.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_api_status(cli_fs_runner, api_status_json_schema):
4848
"instance_source": In(x.name for x in ConfigSource),
4949
"api_key_source": In(x.name for x in ConfigSource),
5050
"token_scopes": ["scan"],
51-
"account_id": 1,
51+
"workspace_id": 1,
5252
}
5353
)
5454
)
@@ -199,22 +199,22 @@ def test_api_status_shows_token_scopes(cli_fs_runner):
199199
assert "scan" in result.output
200200

201201

202-
def test_api_status_shows_account_id(cli_fs_runner):
202+
def test_api_status_shows_workspace_id(cli_fs_runner):
203203
"""
204204
GIVEN a valid API token
205205
WHEN running api-status
206-
THEN the workspace id is displayed as the account id, right below the API URL
206+
THEN the workspace id is displayed right below the API URL
207207
"""
208208
with my_vcr.use_cassette("test_health_check"):
209209
result = cli_fs_runner.invoke(cli, ["api-status"], color=False)
210210
assert_invoke_ok(result)
211-
assert "Account ID: 1" in result.output
211+
assert "Workspace ID: 1" in result.output
212212

213213
lines = result.output.splitlines()
214214
api_url_index = next(
215215
i for i, line in enumerate(lines) if line.startswith("API URL:")
216216
)
217-
assert lines[api_url_index + 1].startswith("Account ID:")
217+
assert lines[api_url_index + 1].startswith("Workspace ID:")
218218

219219

220220
@mock.patch(
@@ -231,10 +231,10 @@ def test_api_status_scopes_omitted_on_error(
231231
"""
232232
GIVEN an api_tokens call that returns an error
233233
WHEN running api-status
234-
THEN the command succeeds and token scopes and account id are simply
234+
THEN the command succeeds and token scopes and workspace id are simply
235235
omitted from the output
236236
"""
237237
result = cli_fs_runner.invoke(cli, ["api-status"], color=False)
238238
assert_invoke_ok(result)
239239
assert "Token scopes:" not in result.output
240-
assert "Account ID:" not in result.output
240+
assert "Workspace ID:" not in result.output

0 commit comments

Comments
 (0)