Skip to content
Open
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
10 changes: 10 additions & 0 deletions sdk/managementgroups/azure-mgmt-managementgroups/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 1.1.0 (2026-02-12)

### Bugs Fixed

- Fixed import error when upgrading to latest azure-core

### Other Changes

- Refreshed SDK code with latest code generator

## 1.1.0b2 (2024-11-05)

### Other Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
include _meta.json
recursive-include tests *.py *.json
recursive-include samples *.py *.md
include *.md
include azure/__init__.py
include azure/mgmt/__init__.py
include LICENSE
include azure/mgmt/managementgroups/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/mgmt/__init__.py
12 changes: 4 additions & 8 deletions sdk/managementgroups/azure-mgmt-managementgroups/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Microsoft Azure SDK for Python

This is the Microsoft Azure Management Groups Client Library.
This package has been tested with Python 3.8+.
This package has been tested with Python 3.9+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).

## _Disclaimer_
Expand All @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For

### Prerequisites

- Python 3.8+ is required to use this package.
- Python 3.9+ is required to use this package.
- [Azure subscription](https://azure.microsoft.com/free/)

### Install the package
Expand All @@ -24,23 +24,19 @@ pip install azure-identity

### Authentication

By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables.
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` for Azure client secret.

In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.

With above configuration, client can be authenticated by following code:

```python
from azure.identity import DefaultAzureCredential
from azure.mgmt.managementgroups import ManagementGroupsAPI
import os

sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
client = ManagementGroupsAPI(credential=DefaultAzureCredential(), subscription_id=sub_id)
client = ManagementGroupsAPI(credential=DefaultAzureCredential())
```

## Examples
Expand Down
11 changes: 0 additions & 11 deletions sdk/managementgroups/azure-mgmt-managementgroups/_meta.json

This file was deleted.

11 changes: 11 additions & 0 deletions sdk/managementgroups/azure-mgmt-managementgroups/_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commit": "91b5db1facc51f4bf2b44afec16d79d8d92440f5",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.10.2",
"use": [
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"autorest_command": "autorest specification/management/resource-manager/Microsoft.Management/ManagementGroups/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-2021-04 --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.10.2 --version-tolerant=False",
"readme": "specification/management/resource-manager/Microsoft.Management/ManagementGroups/readme.md"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"CrossLanguagePackageId": null,
"CrossLanguageDefinitionId": {
"azure.mgmt.managementgroups.models.AzureAsyncOperationResults": null,
"azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest": null,
"azure.mgmt.managementgroups.models.CheckNameAvailabilityResult": null,
"azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo": null,
"azure.mgmt.managementgroups.models.CreateManagementGroupDetails": null,
"azure.mgmt.managementgroups.models.CreateManagementGroupRequest": null,
"azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest": null,
"azure.mgmt.managementgroups.models.CreateParentGroupInfo": null,
"azure.mgmt.managementgroups.models.DescendantInfo": null,
"azure.mgmt.managementgroups.models.DescendantListResult": null,
"azure.mgmt.managementgroups.models.DescendantParentGroupInfo": null,
"azure.mgmt.managementgroups.models.EntityHierarchyItem": null,
"azure.mgmt.managementgroups.models.EntityInfo": null,
"azure.mgmt.managementgroups.models.EntityListResult": null,
"azure.mgmt.managementgroups.models.EntityParentGroupInfo": null,
"azure.mgmt.managementgroups.models.ErrorDetails": null,
"azure.mgmt.managementgroups.models.ErrorResponse": null,
"azure.mgmt.managementgroups.models.HierarchySettings": null,
"azure.mgmt.managementgroups.models.HierarchySettingsInfo": null,
"azure.mgmt.managementgroups.models.HierarchySettingsList": null,
"azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup": null,
"azure.mgmt.managementgroups.models.ManagementGroup": null,
"azure.mgmt.managementgroups.models.ManagementGroupChildInfo": null,
"azure.mgmt.managementgroups.models.ManagementGroupDetails": null,
"azure.mgmt.managementgroups.models.ManagementGroupInfo": null,
"azure.mgmt.managementgroups.models.ManagementGroupListResult": null,
"azure.mgmt.managementgroups.models.ManagementGroupPathElement": null,
"azure.mgmt.managementgroups.models.Operation": null,
"azure.mgmt.managementgroups.models.OperationDisplayProperties": null,
"azure.mgmt.managementgroups.models.OperationListResult": null,
"azure.mgmt.managementgroups.models.OperationResults": null,
"azure.mgmt.managementgroups.models.ParentGroupInfo": null,
"azure.mgmt.managementgroups.models.PatchManagementGroupRequest": null,
"azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup": null,
"azure.mgmt.managementgroups.models.TenantBackfillStatusResult": null,
"azure.mgmt.managementgroups.models.ManagementGroupChildType": null,
"azure.mgmt.managementgroups.models.Permissions": null,
"azure.mgmt.managementgroups.models.ManagementGroupExpandType": null,
"azure.mgmt.managementgroups.models.EntitySearchType": null,
"azure.mgmt.managementgroups.models.EntityViewParameterType": null,
"azure.mgmt.managementgroups.models.Reason": null,
"azure.mgmt.managementgroups.models.Status": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.list": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.list": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.get": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.get": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.begin_create_or_update": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.begin_create_or_update": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.update": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.update": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.begin_delete": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.begin_delete": null,
"azure.mgmt.managementgroups.operations.ManagementGroupsOperations.get_descendants": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.get_descendants": null,
"azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.create": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.create": null,
"azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.delete": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.delete": null,
"azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.get_subscription": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.get_subscription": null,
"azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.get_subscriptions_under_management_group": null,
"azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.get_subscriptions_under_management_group": null,
"azure.mgmt.managementgroups.operations.HierarchySettingsOperations.list": null,
"azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.list": null,
"azure.mgmt.managementgroups.operations.HierarchySettingsOperations.get": null,
"azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.get": null,
"azure.mgmt.managementgroups.operations.HierarchySettingsOperations.create_or_update": null,
"azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.create_or_update": null,
"azure.mgmt.managementgroups.operations.HierarchySettingsOperations.update": null,
"azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.update": null,
"azure.mgmt.managementgroups.operations.HierarchySettingsOperations.delete": null,
"azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.delete": null,
"azure.mgmt.managementgroups.operations.Operations.list": null,
"azure.mgmt.managementgroups.aio.operations.Operations.list": null,
"azure.mgmt.managementgroups.ManagementGroupsAPI.check_name_availability": null,
"azure.mgmt.managementgroups.aio.ManagementGroupsAPI.check_name_availability": null,
"azure.mgmt.managementgroups.ManagementGroupsAPI.start_tenant_backfill": null,
"azure.mgmt.managementgroups.aio.ManagementGroupsAPI.start_tenant_backfill": null,
"azure.mgmt.managementgroups.ManagementGroupsAPI.tenant_backfill_status": null,
"azure.mgmt.managementgroups.aio.ManagementGroupsAPI.tenant_backfill_status": null,
"azure.mgmt.managementgroups.operations.EntitiesOperations.list": null,
"azure.mgmt.managementgroups.aio.operations.EntitiesOperations.list": null
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._management_groups_api import ManagementGroupsAPI
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._management_groups_api import ManagementGroupsAPI # type: ignore
from ._version import VERSION

__version__ = VERSION

try:
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import *
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ManagementGroupsAPI",
]
__all__.extend([p for p in _patch_all if p not in __all__])
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,44 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for ManagementGroupsAPI.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
:keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
def __init__(
self, credential: "TokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2021-04-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.cloud_setting = cloud_setting
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-managementgroups/{}".format(VERSION))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING, cast
from typing_extensions import Self

from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.settings import settings
from azure.mgmt.core import ARMPipelineClient
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
from azure.mgmt.core.tools import get_arm_endpoints

from . import models as _models
from ._configuration import ManagementGroupsAPIConfiguration
from ._serialization import Deserializer, Serializer
from ._utils.serialization import Deserializer, Serializer
from .operations import (
EntitiesOperations,
HierarchySettingsOperations,
ManagementGroupSubscriptionsOperations,
ManagementGroupsAPIOperationsMixin,
ManagementGroupsOperations,
Operations,
_ManagementGroupsAPIOperationsMixin,
)

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
class ManagementGroupsAPI(_ManagementGroupsAPIOperationsMixin):
"""The Azure Management Groups API enables consolidation of multiple
subscriptions/resources into an organizational hierarchy and centrally
manage access control, policies, alerting and reporting for those resources.
Expand All @@ -50,8 +52,11 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl
:vartype entities: azure.mgmt.managementgroups.operations.EntitiesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is "https://management.azure.com".
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
:keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
Expand All @@ -60,9 +65,22 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl
"""

def __init__(
self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any
self,
credential: "TokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
self._config = ManagementGroupsAPIConfiguration(credential=credential, **kwargs)
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = ManagementGroupsAPIConfiguration(
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
Expand All @@ -81,7 +99,7 @@ def __init__(
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs)

client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
Expand Down
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 Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
Loading