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

{DisconnectedOperations} Added az edge disconnected-operation edge-marketplace offer command #30980

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fdb30b0
initial commit
Feb 12, 2025
20ccfa2
fixed linter issues
Feb 12, 2025
fb71536
Added enhanced list and download logic
Feb 18, 2025
bdd0065
fixed linter comments
Feb 18, 2025
073d0d3
added get-offer
Feb 19, 2025
ded8819
updated help file
Feb 19, 2025
f084e8c
Added image download logic
Feb 25, 2025
4e310f1
removing mgmt storage latest
Feb 25, 2025
f888c18
Added storage mgmt version back
Feb 25, 2025
3de81a9
Merge branch 'dev' of https://github.com/kotewar/azure-cli into dev
Feb 26, 2025
dd577af
Merge branch 'Azure:dev' into dev
kotewar Feb 28, 2025
abe306c
initial commit
Feb 12, 2025
b3a27b7
fixed linter issues
Feb 12, 2025
d2159a2
Added enhanced list and download logic
Feb 18, 2025
a6544bb
fixed linter comments
Feb 18, 2025
82077ab
added get-offer
Feb 19, 2025
3a6d509
updated help file
Feb 19, 2025
5f2053d
Added image download logic
Feb 25, 2025
c0b969d
removing mgmt storage latest
Feb 25, 2025
65dd221
Added storage mgmt version back
Feb 25, 2025
d67dab0
fixed styling issues
Mar 3, 2025
e4effe4
Merge branch 'dev' of https://github.com/kotewar/azure-cli into dev
Mar 3, 2025
5f9ceff
Added unit tests
Mar 3, 2025
977bb3f
added more tests and fixed linting issues
Mar 3, 2025
7e11fbc
Updated test case
Mar 3, 2025
e28abbf
Merge branch 'Azure:dev' into dev
kotewar Mar 7, 2025
ff73e46
Merge branch 'Azure:dev' into dev
kotewar Mar 7, 2025
caa8d91
Addressed review comments for command and help
Mar 11, 2025
ae32b4a
Merge branch 'Azure:dev' into dev
kotewar Mar 11, 2025
b73d852
Addressed review comments for edge
Mar 11, 2025
a372b18
Merge branch 'Azure:dev' into dev
kotewar Mar 12, 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
4 changes: 3 additions & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from knack.log import get_logger


logger = get_logger(__name__)


Expand Down Expand Up @@ -84,6 +83,8 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
MGMT_CUSTOMLOCATION = ('azure.mgmt.extendedlocation', 'CustomLocations')
MGMT_CONTAINERSERVICE = ('azure.mgmt.containerservice', 'ContainerServiceClient')
MGMT_APPCONTAINERS = ('azure.mgmt.appcontainers', 'ContainerAppsAPIClient')
MGMT_DISCONNECTEDOPERATIONS = ('azure.mgmt.disconnectedoperations', 'DisconnectedOperationsClient')


# the "None" below will stay till a command module fills in the type so "get_mgmt_service_client"
# can be provided with "ResourceType.XXX" to initialize the client object. This usually happens
Expand Down Expand Up @@ -155,6 +156,7 @@ def default_api_version(self):

AZURE_API_PROFILES = {
'latest': {
ResourceType.MGMT_DISCONNECTEDOPERATIONS: '2024-12-01-preview',
ResourceType.MGMT_STORAGE: '2024-01-01',
ResourceType.MGMT_NETWORK: '2022-01-01',
ResourceType.MGMT_COMPUTE: SDKProfile('2024-07-01', {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# --------------------------------------------------------------------------------------------
# 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.command_modules.disconnectedoperations._client_factory import cf_image
from azure.cli.core import AzCommandsLoader

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please input the _help.py here like this

from azure.cli.command_modules.monitor._help import helps # pylint: disable=unused-import

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


class DisconnectedoperationsCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azure.cli.core.profiles import ResourceType

disconnectedoperations_custom = CliCommandType(
operations_tmpl="azure.cli.command_modules.disconnectedoperations.custom#{}",
client_factory=cf_image,
)
super().__init__(
cli_ctx=cli_ctx,
resource_type=ResourceType.MGMT_DISCONNECTEDOPERATIONS,
custom_command_type=disconnectedoperations_custom,
)

def load_command_table(self, args):
from azure.cli.command_modules.disconnectedoperations.commands import (
load_command_table,
)

load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azure.cli.command_modules.disconnectedoperations._params import (
load_arguments,
)

load_arguments(self, command)


COMMAND_LOADER_CLS = DisconnectedoperationsCommandsLoader
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def get_disconnectedoperations_management_client(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.disconnectedoperations import DisconnectedOperationsClient

return get_mgmt_service_client(cli_ctx, DisconnectedOperationsClient)


def cf_image(cli_ctx, *_):
return get_disconnectedoperations_management_client(cli_ctx).image
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.help_files import helps

helps['disconnectedoperations'] = """
type: group
short-summary: Manage disconnected operations.
"""

helps['disconnectedoperations edgemarketplace'] = """
type: group
short-summary: Manage Edge Marketplace offers for disconnected operations.
"""

helps['disconnectedoperations edgemarketplace listoffers'] = """
type: command
short-summary: List all available marketplace offers.
examples:
- name: List all marketplace offers for a specific resource
text: >
az disconnectedoperations edgemarketplace listoffers --resource-group myResourceGroup --resource-name myResource
- name: List offers and format output as table
text: >
az disconnectedoperations edgemarketplace listoffers -g myResourceGroup --resource-name myResource --output table
- name: List offers and filter output using JMESPath query
text: >
az disconnectedoperations edgemarketplace listoffers -g myResourceGroup --resource-name myResource --query "[?OS_Type=='Linux']"
parameters:
- name: --resource-group -g
type: string
short-summary: Name of resource group
- name: --resource-name
type: string
short-summary: The resource name
"""

helps['disconnectedoperations edgemarketplace getoffer'] = """
type: command
short-summary: Get details of a specific marketplace offer.
examples:
- name: Get details of a specific marketplace offer
text: >
az disconnectedoperations edgemarketplace getoffer --resource-group myResourceGroup --resource-name myResource --publisher-name publisherName --offer-name offerName
- name: Get offer details and output as JSON
text: >
az disconnectedoperations edgemarketplace getoffer -g myResourceGroup --resource-name myResource --publisher-name publisherName --offer-name offerName --output json
- name: Get offer details with custom query
text: >
az disconnectedoperations edgemarketplace getoffer -g myResourceGroup --resource-name myResource --publisher-name publisherName --offer-name offerName --query "[].{SKU:SKU,Version:Versions}"
parameters:
- name: --resource-group -g
type: string
short-summary: Name of resource group
- name: --resource-name
type: string
short-summary: The resource name
- name: --publisher-name
type: string
short-summary: The publisher name of the offer
- name: --offer-name
type: string
short-summary: The name of the offer
"""

helps['disconnectedoperations edgemarketplace packageoffer'] = """
type: command
short-summary: Download and package a marketplace offer with its metadata and icons.
long-summary: Downloads the marketplace offer metadata, icons, and creates a package in the specified output folder.
examples:
- name: Package a marketplace offer with specific version
text: >
az disconnectedoperations edgemarketplace packageoffer --resource-group myResourceGroup --resource-name myResource --publisher-name publisherName --offer-name offerName --sku skuName --version versionNumber --output-folder "D:\\MarketplacePackages"
parameters:
- name: --resource-group -g
type: string
short-summary: Name of resource group
- name: --resource-name
type: string
short-summary: The resource name
- name: --publisher-name
type: string
short-summary: The publisher name of the offer
- name: --offer-name
type: string
short-summary: The name of the offer
- name: --sku
type: string
short-summary: The SKU of the offer
- name: --version
type: string
short-summary: The version of the offer (optional, latest version will be used if not specified)
- name: --output-folder
type: string
short-summary: The folder path where the package will be downloaded
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# --------------------------------------------------------------------------------------------
# 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.commands.parameters import resource_group_name_type


def load_arguments(self, _):
with self.argument_context(
"disconnectedoperations edgemarketplace listoffers"
) as c:
c.argument("resource_group_name", arg_type=resource_group_name_type)
c.argument(
"resource_name", type=str, help="Name of the resource to list offers for"
)

with self.argument_context("disconnectedoperations edgemarketplace getoffer") as c:
c.argument("resource_group_name", arg_type=resource_group_name_type)
c.argument(
"resource_name", type=str, help="Name of the resource to list offers for"
)
c.argument("offer_name", type=str, help="Name of the offer")
c.argument("publisher_name", type=str, help="Name of the publisher")

with self.argument_context(
"disconnectedoperations edgemarketplace packageoffer"
) as c:
c.argument("resource_group_name", arg_type=resource_group_name_type)
c.argument(
"resource_name", type=str, help="Name of the resource to list offers for"
)
c.argument("publisher_name", type=str, help="Name of the publisher")
c.argument("offer_name", type=str, help="Name of the offer to package")
c.argument("sku", type=str, help="SKU of the product")
c.argument("version", type=str, help="Version of the product")
c.argument(
"output_folder",
type=str,
help="Drive and directory to save the package to. Example: E:\\ or D:\\packages\\",
)
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
# --------------------------------------------------------------------------------------------
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(
"edge",
is_preview=True,
)
class __CMDGroup(AAZCommandGroup):
"""Edge disconnected operations CLI
"""
pass


__all__ = ["__CMDGroup"]
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: skip-file
# flake8: noqa

from .__cmd_group import *
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(
"edge disconnected-operation",
is_preview=True,
)
class __CMDGroup(AAZCommandGroup):
"""Disconnected operations cli
"""
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