Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,5 @@
/src/edgeoperator/ @kleyvaortega

/src/aro/ @kimorris27 @hlipsig @tsatam @rogbas @stevekuznetsov @mbarnes @twolff-gh

/src/foundry-cost-control @dargilco @M-Hietala @rhurey
4 changes: 4 additions & 0 deletions src/foundry-cost-control/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.0b2
++++++
* Override ``cognitiveservices account show`` to use API version ``2026-09-15-preview`` and return cost-control properties.

1.0.0b1
++++++
* Initial release.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def load_command_table(self, _): # pylint: disable=unused-argument
with self.command_group(
"cognitiveservices account",
client_factory=cf_accounts) as group:
group.custom_show_command("show", "account_show")
group.custom_command("update", "account_update")

with self.command_group(
Expand Down
16 changes: 16 additions & 0 deletions src/foundry-cost-control/azext_foundry_cost_control/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ def _deployment_resource_id(cmd, resource_group_name, account_name, deployment_n
)


def account_show(cmd, resource_group_name, account_name):
"""Get a Cognitive Services account using the preview cost-control API."""
account_id = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=resource_group_name,
namespace="Microsoft.CognitiveServices",
type="accounts",
name=account_name,
)
return show_resource(
cmd,
resource_ids=[account_id],
api_version=_API_VERSION,
)


def account_update(
cmd,
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"period": "month",
"recurring": true,
"match": {
"foundryCallerAgentId": [
"foundry-caller-agent-id": [
"agent-123"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"period": "month",
"recurring": true,
"match": {
"foundryProjectId": [
"foundry-project-id": [
"project-456"
]
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ def test_foundry_cost_control(self, resource_group):
]
)

# Verify account show returns the preview cost-control properties.
self.cmd(
'cognitiveservices account show '
'--resource-group {resource_group} '
'--name {account_name}',
checks=[
self.check(
'properties.costControlConnections.appInsightsConnectionId',
'{app_insights_connection_id}'
),
self.check(
'properties.costControlConnections.eventGridConnectionId',
'{event_grid_connection_id}'
),
self.check('properties.costControlIds[0]', '{cost_control_id_1}'),
]
)

# Create a deployment with the first cost control attached.
self.cmd(
'cognitiveservices account deployment create '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
_parse_cost_control_id,
)
from azext_foundry_cost_control.custom import (
account_show,
account_update,
deployment_create,
deployment_update,
Expand Down Expand Up @@ -53,6 +54,34 @@ def test_parse_cost_control_id_rejects_other_resource_type(self):
with self.assertRaises(InvalidArgumentValueError):
_parse_cost_control_id(ACCOUNT_ID)

@mock.patch("azext_foundry_cost_control.custom.show_resource")
@mock.patch("azext_foundry_cost_control.custom.resource_id", return_value=ACCOUNT_ID)
@mock.patch("azext_foundry_cost_control.custom.get_subscription_id", return_value="subscription-id")
def test_account_show_uses_preview_api(
self, get_subscription_id_mock, resource_id_mock, show_resource_mock):
cmd = mock.Mock()

result = account_show(
cmd=cmd,
resource_group_name="test-rg",
account_name="test-account",
)

self.assertIs(result, show_resource_mock.return_value)
get_subscription_id_mock.assert_called_once_with(cmd.cli_ctx)
resource_id_mock.assert_called_once_with(
subscription="subscription-id",
resource_group="test-rg",
namespace="Microsoft.CognitiveServices",
type="accounts",
name="test-account",
)
show_resource_mock.assert_called_once_with(
cmd,
resource_ids=[ACCOUNT_ID],
api_version="2026-09-15-preview",
)

@mock.patch("azext_foundry_cost_control.custom.patch_resource")
@mock.patch("azext_foundry_cost_control.custom.resource_id", return_value=ACCOUNT_ID)
@mock.patch("azext_foundry_cost_control.custom.get_subscription_id", return_value="subscription-id")
Expand Down
2 changes: 1 addition & 1 deletion src/foundry-cost-control/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


# HISTORY.rst entry.
VERSION = '1.0.0b1'
VERSION = '1.0.0b2'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading