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

{managementpartner} Migrate to AAZ Codegen #8031

Merged
merged 6 commits into from
Oct 8, 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
12 changes: 12 additions & 0 deletions src/managementpartner/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. :changelog:

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

1.0.0
+++++++++++++++
* Migrate to AAZ codegen.

0.1.3
+++++++++++++++
* Initial release.
22 changes: 13 additions & 9 deletions src/managementpartner/azext_managementpartner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@
from azure.cli.core import AzCommandsLoader

from ._help import helps # pylint: disable=unused-import
from ._client_factory import managementpartner_partner_client_factory
from ._exception_handler import managementpartner_exception_handler


class ManagementpartnerCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
managementpartner_custom = CliCommandType(
operations_tmpl='azext_managementpartner.custom#{}',
client_factory=managementpartner_partner_client_factory,
exception_handler=managementpartner_exception_handler
operations_tmpl='azext_managementpartner.custom#{}'
)

super(ManagementpartnerCommandsLoader, self).__init__(
cli_ctx=cli_ctx,
custom_command_type=managementpartner_custom)
super().__init__(cli_ctx=cli_ctx, custom_command_type=managementpartner_custom)

def load_command_table(self, args):
from .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
15 changes: 0 additions & 15 deletions src/managementpartner/azext_managementpartner/_client_factory.py

This file was deleted.

This file was deleted.

27 changes: 1 addition & 26 deletions src/managementpartner/azext_managementpartner/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,4 @@
# --------------------------------------------------------------------------------------------


from knack.help_files import helps

helps['managementpartner'] = """
type: group
short-summary: Allows the partners to associate a Microsoft Partner Network(MPN) ID to a user or service principal in the customer's Azure directory.
"""

helps['managementpartner create'] = """
type: command
short-summary: Associates a Microsoft Partner Network(MPN) ID to the current authenticated user or service principal.
"""

helps['managementpartner show'] = """
type: command
short-summary: Gets the Microsoft Partner Network(MPN) ID of the current authenticated user or service principal.
"""

helps['managementpartner update'] = """
type: command
short-summary: Updates the Microsoft Partner Network(MPN) ID of the current authenticated user or service principal.
"""

helps['managementpartner delete'] = """
type: command
short-summary: Delete the Microsoft Partner Network(MPN) ID of the current authenticated user or service principal.
"""
from knack.help_files import helps # pylint: disable=unused-import
8 changes: 3 additions & 5 deletions src/managementpartner/azext_managementpartner/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-argument

def load_arguments(self, _):
with self.argument_context('managementpartner') as c:
c.argument('partner_id', help='Microsoft partner network ID')

with self.argument_context('managementpartner show') as c:
c.argument('partner_id', required=False)
def load_arguments(self, _):
pass
6 changes: 6 additions & 0 deletions src/managementpartner/azext_managementpartner/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
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# coding=utf-8
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

VERSION = "0.1.2"
# 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(
"managementpartner",
)
class __CMDGroup(AAZCommandGroup):
"""Allows the partners to associate a Microsoft Partner Network(MPN) ID to a user or service principal in the customer's Azure directory.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# 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 ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# --------------------------------------------------------------------------------------------
# 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(
"managementpartner create",
)
class Create(AAZCommand):
"""Associates a Microsoft Partner Network(MPN) ID to the current authenticated user or service principal.
"""

_aaz_info = {
"version": "2018-02-01",
"resources": [
["mgmt-plane", "/providers/microsoft.managementpartner/partners/{}", "2018-02-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.partner_id = AAZStrArg(
options=["--partner-id"],
help="Microsoft partner network ID",
required=True,
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.PartnerCreate(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 PartnerCreate(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(
"/providers/Microsoft.ManagementPartner/partners/{partnerId}",
**self.url_parameters
)

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

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

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"partnerId", self.ctx.args.partner_id,
required=True,
),
}
return parameters

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

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

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.etag = AAZIntType()
_schema_on_200.id = AAZStrType(
flags={"read_only": True},
)
_schema_on_200.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200.type = AAZStrType(
flags={"read_only": True},
)

properties = cls._schema_on_200.properties
properties.created_time = AAZStrType(
serialized_name="createdTime",
)
properties.object_id = AAZStrType(
serialized_name="objectId",
)
properties.partner_id = AAZStrType(
serialized_name="partnerId",
)
properties.partner_name = AAZStrType(
serialized_name="partnerName",
)
properties.state = AAZStrType()
properties.tenant_id = AAZStrType(
serialized_name="tenantId",
)
properties.updated_time = AAZStrType(
serialized_name="updatedTime",
)
properties.version = AAZIntType()

return cls._schema_on_200


class _CreateHelper:
"""Helper class for Create"""


__all__ = ["Create"]
Loading
Loading