Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StorageSync] az storagesync: Add check-name-availability, private-endpoint-connection list, and sync-group cloud-endpoint trigger-change-detection #7220

Merged
merged 4 commits into from
Jan 29, 2024
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
6 changes: 6 additions & 0 deletions src/storagesync/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

1.0.0
++++++
* Add `az storagesync check-name-availability`
* Add `az storagesync private-endpoint-connection list`
* Add `az storagesync sync-group cloud-endpoint trigger-change-detection`

0.1.2
++++++
* Migrate to track2 SDK
Expand Down
14 changes: 12 additions & 2 deletions src/storagesync/azext_storagesync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ def __init__(self, cli_ctx=None):
storagesync_custom = CliCommandType(
operations_tmpl='azext_storagesync.custom#{}',
client_factory=cf_storagesync)
super(MicrosoftStorageSyncCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=storagesync_custom)
super().__init__(cli_ctx=cli_ctx, custom_command_type=storagesync_custom)

def load_command_table(self, args):
from azext_storagesync.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

Expand Down
6 changes: 6 additions & 0 deletions src/storagesync/azext_storagesync/aaz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions src/storagesync/azext_storagesync/aaz/latest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"storagesync",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Azure File Sync.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._check_name_availability import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"storagesync check-name-availability",
)
class CheckNameAvailability(AAZCommand):
"""Check the give namespace name availability.
"""

_aaz_info = {
"version": "2022-06-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.storagesync/locations/{}/checknameavailability", "2022-06-01"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.location_name = AAZStrArg(
options=["--location-name"],
help="The desired region for the name check.",
required=True,
id_part="name",
)

# define Arg Group "Parameters"

_args_schema = cls._args_schema
_args_schema.name = AAZStrArg(
options=["--name"],
arg_group="Parameters",
help="The name to check for availability",
required=True,
)
_args_schema.type = AAZStrArg(
options=["--type"],
arg_group="Parameters",
help="The resource type. Must be set to Microsoft.StorageSync/storageSyncServices",
required=True,
enum={"Microsoft.StorageSync/storageSyncServices": "Microsoft.StorageSync/storageSyncServices"},
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.StorageSyncServicesCheckNameAvailability(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class StorageSyncServicesCheckNameAvailability(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"locationName", self.ctx.args.location_name,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2022-06-01",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}})

return self.serialize_content(_content_value)

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.message = AAZStrType(
flags={"read_only": True},
)
_schema_on_200.name_available = AAZBoolType(
serialized_name="nameAvailable",
flags={"read_only": True},
)
_schema_on_200.reason = AAZStrType(
flags={"read_only": True},
)

return cls._schema_on_200


class _CheckNameAvailabilityHelper:
"""Helper class for CheckNameAvailability"""


__all__ = ["CheckNameAvailability"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"storagesync private-endpoint-connection",
)
class __CMDGroup(AAZCommandGroup):
"""Manage private endpoint connection.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._list import *
Loading