Skip to content

Commit

Permalink
Upgrading mdp extension to latest version and supporting new commands (
Browse files Browse the repository at this point in the history
…#7760)

* Upgrading mdp extension to latest version and supporting new commands

* add tests and update history

* upgrade extension version

* fix update command
  • Loading branch information
ajaykn committed Jul 4, 2024
1 parent 4b1bc48 commit 45fe341
Show file tree
Hide file tree
Showing 22 changed files with 2,228 additions and 403 deletions.
4 changes: 4 additions & 0 deletions src/mdp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.0b2
++++++
* Upgrading to latest api version 2024-04-04-preview.

1.0.0b1
++++++
* Initial release.
182 changes: 132 additions & 50 deletions src/mdp/azext_mdp/aaz/latest/mdp/pool/_create.py

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/mdp/azext_mdp/aaz/latest/mdp/pool/_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
)
class Delete(AAZCommand):
"""Delete a pool
:example: Delete
az mdp pool delete --name "cli-contoso-pool" --resource-group "rg1"
"""

_aaz_info = {
"version": "2023-12-13-preview",
"version": "2024-04-04-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devopsinfrastructure/pools/{}", "2023-12-13-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devopsinfrastructure/pools/{}", "2024-04-04-preview"],
]
}

Expand Down Expand Up @@ -146,7 +147,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-12-13-preview",
"api-version", "2024-04-04-preview",
required=True,
),
}
Expand All @@ -158,6 +159,7 @@ def on_204(self, session):
def on_200_201(self, session):
pass


class _DeleteHelper:
"""Helper class for Delete"""

Expand Down
122 changes: 98 additions & 24 deletions src/mdp/azext_mdp/aaz/latest/mdp/pool/_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
is_preview=True,
)
class List(AAZCommand):
"""List all pool resources
"""List all pools
:example: List by resource group
az mdp pool list --resource-group "rg1"
Expand All @@ -26,10 +26,10 @@ class List(AAZCommand):
"""

_aaz_info = {
"version": "2023-12-13-preview",
"version": "2024-04-04-preview",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.devopsinfrastructure/pools", "2023-12-13-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devopsinfrastructure/pools", "2023-12-13-preview"],
["mgmt-plane", "/subscriptions/{}/providers/microsoft.devopsinfrastructure/pools", "2024-04-04-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devopsinfrastructure/pools", "2024-04-04-preview"],
]
}

Expand All @@ -55,12 +55,12 @@ def _build_arguments_schema(cls, *args, **kwargs):

def _execute_operations(self):
self.pre_operations()
condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id)
condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True
condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True
condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id)
if condition_0:
self.PoolsListByResourceGroup(ctx=self.ctx)()
if condition_1:
self.PoolsListBySubscription(ctx=self.ctx)()
if condition_1:
self.PoolsListByResourceGroup(ctx=self.ctx)()
self.post_operations()

@register_callback
Expand All @@ -76,7 +76,7 @@ def _output(self, *args, **kwargs):
next_link = self.deserialize_output(self.ctx.vars.instance.next_link)
return result, next_link

class PoolsListByResourceGroup(AAZHttpOperation):
class PoolsListBySubscription(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
Expand All @@ -90,7 +90,7 @@ def __call__(self, *args, **kwargs):
@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOpsInfrastructure/pools",
"/subscriptions/{subscriptionId}/providers/Microsoft.DevOpsInfrastructure/pools",
**self.url_parameters
)

Expand All @@ -105,10 +105,6 @@ def error_format(self):
@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
Expand All @@ -120,7 +116,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-12-13-preview",
"api-version", "2024-04-04-preview",
required=True,
),
}
Expand Down Expand Up @@ -203,7 +199,9 @@ def _build_schema_on_200(cls):
)

user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities
user_assigned_identities.Element = AAZObjectType()
user_assigned_identities.Element = AAZObjectType(
nullable=True,
)

_element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element
_element.client_id = AAZStrType(
Expand Down Expand Up @@ -247,11 +245,26 @@ def _build_schema_on_200(cls):
agent_profile.resource_predictions = AAZObjectType(
serialized_name="resourcePredictions",
)
agent_profile.resource_predictions_profile = AAZObjectType(
serialized_name="resourcePredictionsProfile",
)

resource_predictions_profile = cls._schema_on_200.value.Element.properties.agent_profile.resource_predictions_profile
resource_predictions_profile.kind = AAZStrType(
flags={"required": True},
)

disc_automatic = cls._schema_on_200.value.Element.properties.agent_profile.resource_predictions_profile.discriminate_by("kind", "Automatic")
disc_automatic.prediction_preference = AAZStrType(
serialized_name="predictionPreference",
)

disc_stateful = cls._schema_on_200.value.Element.properties.agent_profile.discriminate_by("kind", "Stateful")
disc_stateful.grace_period_time_span = AAZStrType(
serialized_name="gracePeriodTimeSpan",
)
disc_stateful.max_agent_lifetime = AAZStrType(
serialized_name="maxAgentLifetime",
flags={"required": True},
)

fabric_profile = cls._schema_on_200.value.Element.properties.fabric_profile
Expand Down Expand Up @@ -284,7 +297,9 @@ def _build_schema_on_200(cls):
_element.buffer = AAZStrType()
_element.resource_id = AAZStrType(
serialized_name="resourceId",
flags={"required": True},
)
_element.well_known_image_name = AAZStrType(
serialized_name="wellKnownImageName",
)

aliases = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").images.Element.aliases
Expand Down Expand Up @@ -326,10 +341,28 @@ def _build_schema_on_200(cls):
)

storage_profile = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile
storage_profile.data_disks = AAZListType(
serialized_name="dataDisks",
)
storage_profile.os_disk_storage_account_type = AAZStrType(
serialized_name="osDiskStorageAccountType",
)

data_disks = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile.data_disks
data_disks.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile.data_disks.Element
_element.caching = AAZStrType()
_element.disk_size_gi_b = AAZIntType(
serialized_name="diskSizeGiB",
)
_element.drive_letter = AAZStrType(
serialized_name="driveLetter",
)
_element.storage_account_type = AAZStrType(
serialized_name="storageAccountType",
)

organization_profile = cls._schema_on_200.value.Element.properties.organization_profile
organization_profile.kind = AAZStrType(
flags={"required": True},
Expand Down Expand Up @@ -411,7 +444,7 @@ def _build_schema_on_200(cls):

return cls._schema_on_200

class PoolsListBySubscription(AAZHttpOperation):
class PoolsListByResourceGroup(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
Expand All @@ -425,7 +458,7 @@ def __call__(self, *args, **kwargs):
@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/providers/Microsoft.DevOpsInfrastructure/pools",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOpsInfrastructure/pools",
**self.url_parameters
)

Expand All @@ -440,6 +473,10 @@ def error_format(self):
@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
Expand All @@ -451,7 +488,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-12-13-preview",
"api-version", "2024-04-04-preview",
required=True,
),
}
Expand Down Expand Up @@ -534,7 +571,9 @@ def _build_schema_on_200(cls):
)

user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities
user_assigned_identities.Element = AAZObjectType()
user_assigned_identities.Element = AAZObjectType(
nullable=True,
)

_element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element
_element.client_id = AAZStrType(
Expand Down Expand Up @@ -578,11 +617,26 @@ def _build_schema_on_200(cls):
agent_profile.resource_predictions = AAZObjectType(
serialized_name="resourcePredictions",
)
agent_profile.resource_predictions_profile = AAZObjectType(
serialized_name="resourcePredictionsProfile",
)

resource_predictions_profile = cls._schema_on_200.value.Element.properties.agent_profile.resource_predictions_profile
resource_predictions_profile.kind = AAZStrType(
flags={"required": True},
)

disc_automatic = cls._schema_on_200.value.Element.properties.agent_profile.resource_predictions_profile.discriminate_by("kind", "Automatic")
disc_automatic.prediction_preference = AAZStrType(
serialized_name="predictionPreference",
)

disc_stateful = cls._schema_on_200.value.Element.properties.agent_profile.discriminate_by("kind", "Stateful")
disc_stateful.grace_period_time_span = AAZStrType(
serialized_name="gracePeriodTimeSpan",
)
disc_stateful.max_agent_lifetime = AAZStrType(
serialized_name="maxAgentLifetime",
flags={"required": True},
)

fabric_profile = cls._schema_on_200.value.Element.properties.fabric_profile
Expand Down Expand Up @@ -615,7 +669,9 @@ def _build_schema_on_200(cls):
_element.buffer = AAZStrType()
_element.resource_id = AAZStrType(
serialized_name="resourceId",
flags={"required": True},
)
_element.well_known_image_name = AAZStrType(
serialized_name="wellKnownImageName",
)

aliases = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").images.Element.aliases
Expand Down Expand Up @@ -657,10 +713,28 @@ def _build_schema_on_200(cls):
)

storage_profile = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile
storage_profile.data_disks = AAZListType(
serialized_name="dataDisks",
)
storage_profile.os_disk_storage_account_type = AAZStrType(
serialized_name="osDiskStorageAccountType",
)

data_disks = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile.data_disks
data_disks.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element.properties.fabric_profile.discriminate_by("kind", "Vmss").storage_profile.data_disks.Element
_element.caching = AAZStrType()
_element.disk_size_gi_b = AAZIntType(
serialized_name="diskSizeGiB",
)
_element.drive_letter = AAZStrType(
serialized_name="driveLetter",
)
_element.storage_account_type = AAZStrType(
serialized_name="storageAccountType",
)

organization_profile = cls._schema_on_200.value.Element.properties.organization_profile
organization_profile.kind = AAZStrType(
flags={"required": True},
Expand Down
Loading

0 comments on commit 45fe341

Please sign in to comment.