Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
81d2160
Add mongo cluster extension v1
olivertowers Jul 10, 2025
8e840bf
Initial commands a customizations for mongo-cluster
olivertowers Jul 12, 2025
e3e7af6
Add additional commands, make commands preview, add test recordings
olivertowers Jul 15, 2025
5717221
Add mongo-cluster replica wait command
olivertowers Jul 15, 2025
ebe0eb9
Fix style
olivertowers Jul 15, 2025
c7c2630
Modify list connection strings. Follow standards for argument names
olivertowers Jul 15, 2025
ab94b23
fix style
olivertowers Jul 15, 2025
db8024a
Fix resource id handling
olivertowers Jul 15, 2025
a20a561
Initial AAZ generation
olivertowers Jul 18, 2025
f0a9e34
Refactor customizations and tests under document-db
olivertowers Jul 18, 2025
ca0921a
Fix tests and initial recordings
olivertowers Jul 18, 2025
0315d65
Add recording
olivertowers Jul 19, 2025
6cfdcdf
Add readme/history and register ext service name.
olivertowers Jul 21, 2025
fc36793
Merge branch 'feature-mongocluster-cli' into feature-documentdb-cli
olivertowers Jul 22, 2025
c891682
Merge branch 'main' into feature-mongocluster-cli
olivertowers Jul 22, 2025
bc1fc9b
Follow extension versioning schema to start with initial preview vers…
olivertowers Jul 22, 2025
4f2d4ce
Merge branch 'feature-mongocluster-cli' of https://github.com/olivert…
olivertowers Jul 22, 2025
76fd9ad
Full directory move/rename to docdb
olivertowers Jul 22, 2025
ca19801
in file refactory to docdb
olivertowers Jul 22, 2025
b96c887
Re-generate from aaz
olivertowers Jul 22, 2025
b68b154
Renames
olivertowers Jul 22, 2025
d718de0
Fix class names to match DocDB and update documentation in customizat…
olivertowers Jul 22, 2025
774dbd9
Fix recordings
olivertowers Jul 22, 2025
a2d2ed1
Fix service name
olivertowers Jul 22, 2025
342fe9d
Redo recordings
olivertowers Jul 23, 2025
2d6cf89
Merge branch 'main' into feature-mongocluster-cli
olivertowers Sep 15, 2025
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
8 changes: 8 additions & 0 deletions src/mongocluster/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

1.0.0b1
++++++
* Initial release.
5 changes: 5 additions & 0 deletions src/mongocluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Azure CLI Mongocluster Extension #
This is an extension to Azure CLI to manage Mongo Cluster resources.

## How to use ##
Please add commands usage here.
42 changes: 42 additions & 0 deletions src/mongocluster/azext_mongocluster/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# 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
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_mongocluster._help import helps # pylint: disable=unused-import


class MongoclusterCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_command_type = CliCommandType(
operations_tmpl='azext_mongocluster.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_mongocluster.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

def load_arguments(self, command):
from azext_mongocluster._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = MongoclusterCommandsLoader
11 changes: 11 additions & 0 deletions src/mongocluster/azext_mongocluster/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# 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: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import
13 changes: 13 additions & 0 deletions src/mongocluster/azext_mongocluster/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# 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: disable=too-many-lines
# pylint: disable=too-many-statements


def load_arguments(self, _): # pylint: disable=unused-argument
pass
6 changes: 6 additions & 0 deletions src/mongocluster/azext_mongocluster/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/mongocluster/azext_mongocluster/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,24 @@
# --------------------------------------------------------------------------------------------
# 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(
"mongo-cluster",
is_preview=True,
)
class __CMDGroup(AAZCommandGroup):
"""Manage Mongo cluster resources.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# 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 *
from ._create import *
from ._delete import *
from ._list import *
from ._promote import *
from ._show import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# --------------------------------------------------------------------------------------------
# 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(
"mongo-cluster check-name-availability",
is_preview=True,
)
class CheckNameAvailability(AAZCommand):
"""Check if mongo cluster name is available for use.

:example: Checks and confirms the Mongo Cluster name is availability for use.
az mongo-cluster check-name-availability --location westus2 --name newmongocluster
"""

_aaz_info = {
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.documentdb/locations/{}/checkmongoclusternameavailability", "2024-07-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 = AAZResourceLocationArg(
required=True,
id_part="name",
)

# define Arg Group "Body"

_args_schema = cls._args_schema
_args_schema.mongo_cluster_name = AAZStrArg(
options=["-n", "--name", "--mongo-cluster-name"],
arg_group="Body",
help="The name of the resource for which availability needs to be checked.",
)
_args_schema.type = AAZStrArg(
options=["--type"],
arg_group="Body",
help="The resource type.",
default="Microsoft.DocumentDB/mongoClusters",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.MongoClustersCheckNameAvailability(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 MongoClustersCheckNameAvailability(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.DocumentDB/locations/{location}/checkMongoClusterNameAvailability",
**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(
"location", self.ctx.args.location,
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", "2024-07-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, ".mongo_cluster_name")
_builder.set_prop("type", AAZStrType, ".type")

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()
_schema_on_200.name_available = AAZBoolType(
serialized_name="nameAvailable",
)
_schema_on_200.reason = AAZStrType()

return cls._schema_on_200


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


__all__ = ["CheckNameAvailability"]
Loading
Loading