Skip to content

Commit e7db2b3

Browse files
[HORIZONDB] Add private endpoint CLI commands (#10043)
1 parent a550e1c commit e7db2b3

14 files changed

Lines changed: 745 additions & 13 deletions

File tree

src/horizondb/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
1.0.0b6
7+
+++++++
8+
* Add private endpoint connection commands: `az horizondb private-endpoint-connection list/show/approve/reject/delete`.
9+
* Add private link resource commands: `az horizondb private-link-resource list/show`.
10+
611
1.0.0b5
712
+++++++
813
* Add support for configuring public access on HorizonDB clusters through `az horizondb create --public-access` and `az horizondb update --public-access`. Supplying an IP address or range automatically creates a firewall rule.

src/horizondb/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,20 @@ az extension add --name horizondb
1919
- `az horizondb create`: Create a new Azure HorizonDB cluster.
2020
- `az horizondb delete`: Delete an Azure HorizonDB cluster.
2121
- `az horizondb show`: Show details of an Azure HorizonDB cluster.
22+
23+
### HorizonDB Private Endpoint Connections
24+
25+
*Commands:*
26+
27+
- `az horizondb private-endpoint-connection list`: List private endpoint connections for a HorizonDB cluster.
28+
- `az horizondb private-endpoint-connection show`: Show details of a HorizonDB private endpoint connection.
29+
- `az horizondb private-endpoint-connection approve`: Approve a HorizonDB private endpoint connection.
30+
- `az horizondb private-endpoint-connection reject`: Reject a HorizonDB private endpoint connection.
31+
- `az horizondb private-endpoint-connection delete`: Delete a HorizonDB private endpoint connection.
32+
33+
### HorizonDB Private Link Resources
34+
35+
*Commands:*
36+
37+
- `az horizondb private-link-resource list`: List private link resources for a HorizonDB cluster.
38+
- `az horizondb private-link-resource show`: Show details of a HorizonDB private link resource.

src/horizondb/azext_horizondb/_client_factory.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ def cf_horizondb_clusters(cli_ctx, _):
4040

4141
def cf_horizondb_firewall_rules(cli_ctx, _):
4242
return get_horizondb_management_client(cli_ctx).horizon_db_firewall_rules
43+
44+
45+
def cf_horizondb_private_endpoint_connections(cli_ctx, _):
46+
return get_horizondb_management_client(cli_ctx).horizon_db_private_endpoint_connections
47+
48+
49+
def cf_horizondb_private_link_resources(cli_ctx, _):
50+
return get_horizondb_management_client(cli_ctx).horizon_db_private_link_resources

src/horizondb/azext_horizondb/_help.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,86 @@
130130
- name: Delete a firewall rule.
131131
text: az horizondb firewall-rule delete --resource-group exampleresourcegroup --cluster-name examplecluster --name allowclientip
132132
"""
133+
134+
135+
helps['horizondb private-endpoint-connection'] = """
136+
type: group
137+
short-summary: Manage HorizonDB private endpoint connections.
138+
"""
139+
140+
141+
helps['horizondb private-endpoint-connection list'] = """
142+
type: command
143+
short-summary: List private endpoint connections for a HorizonDB cluster.
144+
examples:
145+
- name: List private endpoint connections for a HorizonDB cluster.
146+
text: az horizondb private-endpoint-connection list --resource-group exampleresourcegroup --cluster-name examplecluster
147+
"""
148+
149+
150+
helps['horizondb private-endpoint-connection show'] = """
151+
type: command
152+
short-summary: Show details of a HorizonDB private endpoint connection.
153+
examples:
154+
- name: Show a private endpoint connection by cluster and connection name.
155+
text: az horizondb private-endpoint-connection show --resource-group exampleresourcegroup --cluster-name examplecluster --name exampleconnection
156+
- name: Show a private endpoint connection by resource ID.
157+
text: az horizondb private-endpoint-connection show --id /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.HorizonDb/clusters/{clusterName}/privateEndpointConnections/{connectionName}
158+
"""
159+
160+
161+
helps['horizondb private-endpoint-connection approve'] = """
162+
type: command
163+
short-summary: Approve a HorizonDB private endpoint connection.
164+
examples:
165+
- name: Approve a private endpoint connection by cluster and connection name.
166+
text: az horizondb private-endpoint-connection approve --resource-group exampleresourcegroup --cluster-name examplecluster --name exampleconnection --description "Approved"
167+
- name: Approve a private endpoint connection by resource ID.
168+
text: az horizondb private-endpoint-connection approve --id /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.HorizonDb/clusters/{clusterName}/privateEndpointConnections/{connectionName} --description "Approved"
169+
"""
170+
171+
172+
helps['horizondb private-endpoint-connection reject'] = """
173+
type: command
174+
short-summary: Reject a HorizonDB private endpoint connection.
175+
examples:
176+
- name: Reject a private endpoint connection by cluster and connection name.
177+
text: az horizondb private-endpoint-connection reject --resource-group exampleresourcegroup --cluster-name examplecluster --name exampleconnection --description "Rejected"
178+
- name: Reject a private endpoint connection by resource ID.
179+
text: az horizondb private-endpoint-connection reject --id /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.HorizonDb/clusters/{clusterName}/privateEndpointConnections/{connectionName} --description "Rejected"
180+
"""
181+
182+
183+
helps['horizondb private-endpoint-connection delete'] = """
184+
type: command
185+
short-summary: Delete a HorizonDB private endpoint connection.
186+
examples:
187+
- name: Delete a private endpoint connection by cluster and connection name.
188+
text: az horizondb private-endpoint-connection delete --resource-group exampleresourcegroup --cluster-name examplecluster --name exampleconnection
189+
- name: Delete a private endpoint connection by resource ID.
190+
text: az horizondb private-endpoint-connection delete --id /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.HorizonDb/clusters/{clusterName}/privateEndpointConnections/{connectionName}
191+
"""
192+
193+
194+
helps['horizondb private-link-resource'] = """
195+
type: group
196+
short-summary: Manage HorizonDB private link resources.
197+
"""
198+
199+
200+
helps['horizondb private-link-resource list'] = """
201+
type: command
202+
short-summary: List private link resources for a HorizonDB cluster.
203+
examples:
204+
- name: List private link resources for a HorizonDB cluster.
205+
text: az horizondb private-link-resource list --resource-group exampleresourcegroup --cluster-name examplecluster
206+
"""
207+
208+
209+
helps['horizondb private-link-resource show'] = """
210+
type: command
211+
short-summary: Show details of a HorizonDB private link resource.
212+
examples:
213+
- name: Show a private link resource by group name.
214+
text: az horizondb private-link-resource show --resource-group exampleresourcegroup --cluster-name examplecluster --group-name DefaultPool
215+
"""

src/horizondb/azext_horizondb/_params.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def _horizondb_params():
4040
name='cluster_name',
4141
actions=[LocalContextAction.SET, LocalContextAction.GET],
4242
scopes=['horizondb']))
43-
4443
administrator_login_arg_type = CLIArgumentType(
4544
options_list=['--administrator-login', '-u'],
4645
help='The administrator login name for the cluster.',
@@ -73,6 +72,29 @@ def _horizondb_params():
7372
parameter_group_arg_type = CLIArgumentType(
7473
options_list=['--parameter-group'],
7574
help='The resource ID of the parameter group.')
75+
cluster_name_resource_arg_type = CLIArgumentType(
76+
metavar='NAME',
77+
options_list=['--cluster-name', '-c'],
78+
id_part=None,
79+
help="Name of the cluster. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.",
80+
local_context_attribute=LocalContextAttribute(
81+
name='cluster_name',
82+
actions=[LocalContextAction.SET, LocalContextAction.GET],
83+
scopes=['horizondb']))
84+
private_endpoint_connection_name_arg_type = CLIArgumentType(
85+
options_list=['--name', '-n'],
86+
help='The name of the private endpoint connection associated with the HorizonDB cluster. '
87+
'Required if --id is not specified.')
88+
private_endpoint_connection_id_arg_type = CLIArgumentType(
89+
options_list=['--id'],
90+
help='The resource ID of the private endpoint connection associated with the HorizonDB cluster. '
91+
'If specified --cluster-name/-c and --name/-n, this should be omitted.')
92+
private_endpoint_connection_description_arg_type = CLIArgumentType(
93+
options_list=['--description', '-d'],
94+
help='Comments for the approval or rejection.')
95+
private_link_resource_group_name_arg_type = CLIArgumentType(
96+
options_list=['--group-name'],
97+
help='The private link resource group name. For HorizonDB this is the pool name, for example DefaultPool.')
7698

7799
public_access_create_arg_type = CLIArgumentType(
78100
options_list=['--public-access'],
@@ -161,4 +183,29 @@ def _horizondb_params():
161183
with self.argument_context('horizondb firewall-rule delete') as c:
162184
c.argument('yes', arg_type=yes_arg_type)
163185

186+
for scope in ['show', 'delete', 'approve', 'reject']:
187+
with self.argument_context('horizondb private-endpoint-connection {}'.format(scope)) as c:
188+
c.argument('resource_group_name', arg_type=resource_group_name_type, required=False)
189+
c.argument('cluster_name', arg_type=cluster_name_resource_arg_type, required=False)
190+
c.argument('private_endpoint_connection_name',
191+
arg_type=private_endpoint_connection_name_arg_type,
192+
required=False)
193+
c.extra('connection_id',
194+
arg_type=private_endpoint_connection_id_arg_type,
195+
required=False)
196+
if scope in ['approve', 'reject']:
197+
c.argument('description',
198+
arg_type=private_endpoint_connection_description_arg_type,
199+
required=True)
200+
201+
with self.argument_context('horizondb private-endpoint-connection list') as c:
202+
c.argument('cluster_name', arg_type=cluster_name_resource_arg_type)
203+
204+
with self.argument_context('horizondb private-link-resource list') as c:
205+
c.argument('cluster_name', arg_type=cluster_name_resource_arg_type)
206+
207+
with self.argument_context('horizondb private-link-resource show') as c:
208+
c.argument('cluster_name', arg_type=cluster_name_resource_arg_type)
209+
c.argument('group_name', arg_type=private_link_resource_group_name_arg_type, required=True)
210+
164211
_horizondb_params()

src/horizondb/azext_horizondb/cluster_commands.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
from azure.cli.core.commands import CliCommandType
77
from azext_horizondb._client_factory import (
88
cf_horizondb_clusters,
9-
cf_horizondb_firewall_rules)
9+
cf_horizondb_firewall_rules,
10+
cf_horizondb_private_endpoint_connections,
11+
cf_horizondb_private_link_resources)
1012
from azext_horizondb.utils._transformers import (
1113
table_transform_output)
14+
from azext_horizondb.utils.validators import (
15+
validate_private_endpoint_connection_id)
1216

1317

1418
# pylint: disable=too-many-locals, too-many-statements, line-too-long
@@ -24,6 +28,16 @@ def load_command_table(self, _):
2428
firewall_rule_custom = CliCommandType(
2529
operations_tmpl='azext_horizondb.commands.firewall_rule_commands#{}',
2630
client_factory=cf_horizondb_firewall_rules)
31+
private_endpoint_commands = CliCommandType(
32+
operations_tmpl='azext_horizondb.commands.private_endpoint_commands#{}')
33+
horizondb_private_endpoint_connections_sdk = CliCommandType(
34+
operations_tmpl='azext_horizondb.vendored_sdks.operations#HorizonDbPrivateEndpointConnectionsOperations.{}',
35+
client_factory=cf_horizondb_private_endpoint_connections
36+
)
37+
horizondb_private_link_resources_sdk = CliCommandType(
38+
operations_tmpl='azext_horizondb.vendored_sdks.operations#HorizonDbPrivateLinkResourcesOperations.{}',
39+
client_factory=cf_horizondb_private_link_resources
40+
)
2741

2842
with self.command_group('horizondb', horizondb_clusters_sdk,
2943
custom_command_type=custom_commands,
@@ -42,3 +56,22 @@ def load_command_table(self, _):
4256
g.custom_command('delete', 'horizondb_firewall_rule_delete')
4357
g.custom_show_command('show', 'horizondb_firewall_rule_get')
4458
g.custom_command('list', 'horizondb_firewall_rule_list')
59+
60+
with self.command_group('horizondb private-endpoint-connection',
61+
horizondb_private_endpoint_connections_sdk,
62+
custom_command_type=private_endpoint_commands,
63+
client_factory=cf_horizondb_private_endpoint_connections) as g:
64+
g.custom_command('list', 'horizondb_private_endpoint_connection_list')
65+
g.show_command('show', 'get', validator=validate_private_endpoint_connection_id)
66+
g.command('delete', 'begin_delete', validator=validate_private_endpoint_connection_id)
67+
g.custom_command('approve', 'horizondb_approve_private_endpoint_connection',
68+
validator=validate_private_endpoint_connection_id)
69+
g.custom_command('reject', 'horizondb_reject_private_endpoint_connection',
70+
validator=validate_private_endpoint_connection_id)
71+
72+
with self.command_group('horizondb private-link-resource',
73+
horizondb_private_link_resources_sdk,
74+
custom_command_type=private_endpoint_commands,
75+
client_factory=cf_horizondb_private_link_resources) as g:
76+
g.custom_command('list', 'horizondb_private_link_resource_list')
77+
g.custom_show_command('show', 'horizondb_private_link_resource_get')
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
7+
def horizondb_approve_private_endpoint_connection(
8+
client, resource_group_name, cluster_name, private_endpoint_connection_name,
9+
description=None):
10+
return _update_private_endpoint_connection_status(
11+
client, resource_group_name, cluster_name, private_endpoint_connection_name,
12+
is_approved=True, description=description)
13+
14+
15+
def horizondb_reject_private_endpoint_connection(
16+
client, resource_group_name, cluster_name, private_endpoint_connection_name,
17+
description=None):
18+
return _update_private_endpoint_connection_status(
19+
client, resource_group_name, cluster_name, private_endpoint_connection_name,
20+
is_approved=False, description=description)
21+
22+
23+
def _update_private_endpoint_connection_status(
24+
client, resource_group_name, cluster_name, private_endpoint_connection_name,
25+
is_approved=True, description=None):
26+
from azext_horizondb.vendored_sdks.models import (
27+
OptionalPropertiesUpdateableProperties,
28+
PrivateEndpointConnectionUpdate,
29+
PrivateLinkServiceConnectionState,
30+
)
31+
32+
new_status = 'Approved' if is_approved else 'Rejected'
33+
state = PrivateLinkServiceConnectionState(
34+
status=new_status,
35+
description=description)
36+
update = PrivateEndpointConnectionUpdate(
37+
properties=OptionalPropertiesUpdateableProperties(
38+
private_link_service_connection_state=state))
39+
40+
return client.begin_update(
41+
resource_group_name=resource_group_name,
42+
cluster_name=cluster_name,
43+
private_endpoint_connection_name=private_endpoint_connection_name,
44+
properties=update)
45+
46+
47+
def horizondb_private_endpoint_connection_list(
48+
client, resource_group_name, cluster_name):
49+
return client.list(
50+
resource_group_name=resource_group_name,
51+
cluster_name=cluster_name)
52+
53+
54+
def horizondb_private_link_resource_list(
55+
client, resource_group_name, cluster_name):
56+
return client.list(
57+
resource_group_name=resource_group_name,
58+
cluster_name=cluster_name)
59+
60+
61+
def horizondb_private_link_resource_get(
62+
client, resource_group_name, cluster_name, group_name):
63+
return client.get(
64+
resource_group_name=resource_group_name,
65+
cluster_name=cluster_name,
66+
group_name=group_name)

0 commit comments

Comments
 (0)