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

## 10.0.0b2 (2025-04-24)

### Features Added

- Client `AdvisorManagementClient` added method `predict`
- Client `AdvisorManagementClient` added operation group `advisor_scores`
- Client `AdvisorManagementClient` added operation group `assessments`
- Client `AdvisorManagementClient` added operation group `assessment_types`
- Client `AdvisorManagementClient` added operation group `workloads`
- Client `AdvisorManagementClient` added operation group `resiliency_reviews`
- Client `AdvisorManagementClient` added operation group `triage_recommendations`
- Client `AdvisorManagementClient` added operation group `triage_resources`
- Model `ConfigData` added property `duration`
- Model `ConfigData` added property `system_data`
- Model `Resource` added property `system_data`
- Model `ResourceRecommendationBase` added property `risk`
- Model `ResourceRecommendationBase` added property `tracked`
- Model `ResourceRecommendationBase` added property `tracked_properties`
- Model `ResourceRecommendationBase` added property `review`
- Model `ResourceRecommendationBase` added property `resource_workload`
- Model `ResourceRecommendationBase` added property `source_system`
- Model `ResourceRecommendationBase` added property `notes`
- Model `ResourceRecommendationBase` added property `system_data`
- Model `SuppressionContract` added property `system_data`
- Added model `AdvisorScoreEntity`
- Added model `AdvisorScoreEntityProperties`
- Added model `AdvisorScoreResponse`
- Added enum `Aggregated`
- Added model `AssessmentListResult`
- Added model `AssessmentResult`
- Added model `AssessmentTypeListResult`
- Added model `AssessmentTypeResult`
- Added enum `CreatedByType`
- Added enum `Duration`
- Added model `ErrorAdditionalInfo`
- Added model `ErrorDetail`
- Added model `ErrorResponse`
- Added model `PredictionRequest`
- Added model `PredictionResponse`
- Added enum `PredictionType`
- Added enum `Priority`
- Added enum `PriorityName`
- Added model `ProxyResource`
- Added enum `Reason`
- Added enum `ReasonForRejectionName`
- Added model `RecommendationPropertiesResourceWorkload`
- Added model `RecommendationPropertiesReview`
- Added model `RecommendationRejectBody`
- Added enum `RecommendationStatusName`
- Added model `ResiliencyReview`
- Added model `ResiliencyReviewCollection`
- Added enum `ReviewStatus`
- Added enum `Risk`
- Added model `ScoreEntity`
- Added enum `State`
- Added model `SystemData`
- Added model `TimeSeriesEntityItem`
- Added model `TrackedRecommendationProperties`
- Added model `TrackedRecommendationPropertiesPayload`
- Added model `TrackedRecommendationPropertiesPayloadProperties`
- Added model `TriageRecommendation`
- Added model `TriageRecommendationCollection`
- Added model `TriageResource`
- Added model `TriageResourceCollection`
- Added model `WorkloadListResult`
- Added model `WorkloadResult`
- Model `RecommendationsOperations` added method `patch`
- Added model `AdvisorManagementClientOperationsMixin`
- Added model `AdvisorScoresOperations`
- Added model `AssessmentTypesOperations`
- Added model `AssessmentsOperations`
- Added model `ResiliencyReviewsOperations`
- Added model `TriageRecommendationsOperations`
- Added model `TriageResourcesOperations`
- Added model `WorkloadsOperations`
- Method `AdvisorManagementClient.predict` has a new overload `def predict(self: None, prediction_request: PredictionRequest, content_type: str)`
- Method `AdvisorManagementClient.predict` has a new overload `def predict(self: None, prediction_request: IO[bytes], content_type: str)`
- Method `ConfigurationsOperations.create_in_resource_group` has a new overload `def create_in_resource_group(self: None, configuration_name: Union[str, ConfigurationName], resource_group: str, config_contract: IO[bytes], content_type: str)`
- Method `ConfigurationsOperations.create_in_subscription` has a new overload `def create_in_subscription(self: None, configuration_name: Union[str, ConfigurationName], config_contract: IO[bytes], content_type: str)`
- Method `RecommendationsOperations.patch` has a new overload `def patch(self: None, resource_uri: str, recommendation_id: str, tracked_properties: TrackedRecommendationPropertiesPayload, content_type: str)`
- Method `RecommendationsOperations.patch` has a new overload `def patch(self: None, resource_uri: str, recommendation_id: str, tracked_properties: IO[bytes], content_type: str)`
- Method `SuppressionsOperations.create` has a new overload `def create(self: None, resource_uri: str, recommendation_id: str, name: str, suppression_contract: IO[bytes], content_type: str)`
- Method `AdvisorManagementClientOperationsMixin.predict` has a new overload `def predict(self: None, prediction_request: PredictionRequest, content_type: str)`
- Method `AdvisorManagementClientOperationsMixin.predict` has a new overload `def predict(self: None, prediction_request: IO[bytes], content_type: str)`
- Method `AssessmentsOperations.put` has a new overload `def put(self: None, assessment_name: str, assessment_contract: AssessmentResult, content_type: str)`
- Method `AssessmentsOperations.put` has a new overload `def put(self: None, assessment_name: str, assessment_contract: IO[bytes], content_type: str)`
- Method `TriageRecommendationsOperations.reject_triage_recommendation` has a new overload `def reject_triage_recommendation(self: None, review_id: str, recommendation_id: str, recommendation_reject_body: RecommendationRejectBody, content_type: str)`
- Method `TriageRecommendationsOperations.reject_triage_recommendation` has a new overload `def reject_triage_recommendation(self: None, review_id: str, recommendation_id: str, recommendation_reject_body: IO[bytes], content_type: str)`

## 10.0.0b1 (2022-10-28)

### Features Added
Expand Down
55 changes: 44 additions & 11 deletions sdk/advisor/azure-mgmt-advisor/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
# Microsoft Azure SDK for Python

This is the Microsoft Azure Advisor Client Library.
This package has been tested with Python 3.7+.
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_

_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_

# Usage
## Getting started

### Prerequisites

To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)

For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/advisor)
Code samples for this package can be found at [Advisor](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://github.com/Azure-Samples/azure-samples-python-management/tree/main/samples/advisor)
- Python 3.9+ is required to use this package.
- [Azure subscription](https://azure.microsoft.com/free/)

### Install the package

# Provide Feedback
```bash
pip install azure-mgmt-advisor
pip install azure-identity
```

If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.
### Authentication

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.advisor import AdvisorManagementClient
import os

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

## Examples

Code samples for this package can be found at:
- [Search Advisor](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)


## Troubleshooting

## Next steps

## Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.
10 changes: 5 additions & 5 deletions sdk/advisor/azure-mgmt-advisor/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "e82a24def11ffc98cc263884f9f1742c99f2df5e",
"commit": "960e00a10f8dd5d76f6f3ef02ab7a7c785d21afe",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"autorest": "3.10.2",
"use": [
"@autorest/python@6.2.1",
"@autorest/modelerfour@4.24.3"
"@autorest/python@6.34.1",
"@autorest/modelerfour@4.27.0"
],
"autorest_command": "autorest specification/advisor/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --tag=package-2020-01 --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/advisor/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.34.1 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
"readme": "specification/advisor/resource-manager/readme.md"
}
12 changes: 9 additions & 3 deletions sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/__init__.py
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 ._advisor_management_client import AdvisorManagementClient
from typing import TYPE_CHECKING

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

from ._advisor_management_client import AdvisorManagementClient # type: ignore
from ._version import VERSION

__version__ = VERSION

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

__all__ = [
"AdvisorManagementClient",
]
__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 @@ -7,28 +7,40 @@
# --------------------------------------------------------------------------

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
from . import models as _models
from ._configuration import AdvisorManagementClientConfiguration
from ._serialization import Deserializer, Serializer
from ._utils.serialization import Deserializer, Serializer
from .operations import (
AdvisorManagementClientOperationsMixin,
AdvisorScoresOperations,
AssessmentTypesOperations,
AssessmentsOperations,
ConfigurationsOperations,
Operations,
RecommendationMetadataOperations,
RecommendationsOperations,
ResiliencyReviewsOperations,
SuppressionsOperations,
TriageRecommendationsOperations,
TriageResourcesOperations,
WorkloadsOperations,
)

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


class AdvisorManagementClient: # pylint: disable=client-accepts-api-version-keyword
class AdvisorManagementClient(AdvisorManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes
"""REST APIs for Azure Advisor.
:ivar recommendation_metadata: RecommendationMetadataOperations operations
Expand All @@ -42,30 +54,64 @@ class AdvisorManagementClient: # pylint: disable=client-accepts-api-version-key
:vartype operations: azure.mgmt.advisor.operations.Operations
:ivar suppressions: SuppressionsOperations operations
:vartype suppressions: azure.mgmt.advisor.operations.SuppressionsOperations
:ivar advisor_scores: AdvisorScoresOperations operations
:vartype advisor_scores: azure.mgmt.advisor.operations.AdvisorScoresOperations
:ivar assessments: AssessmentsOperations operations
:vartype assessments: azure.mgmt.advisor.operations.AssessmentsOperations
:ivar assessment_types: AssessmentTypesOperations operations
:vartype assessment_types: azure.mgmt.advisor.operations.AssessmentTypesOperations
:ivar workloads: WorkloadsOperations operations
:vartype workloads: azure.mgmt.advisor.operations.WorkloadsOperations
:ivar resiliency_reviews: ResiliencyReviewsOperations operations
:vartype resiliency_reviews: azure.mgmt.advisor.operations.ResiliencyReviewsOperations
:ivar triage_recommendations: TriageRecommendationsOperations operations
:vartype triage_recommendations: azure.mgmt.advisor.operations.TriageRecommendationsOperations
:ivar triage_resources: TriageResourcesOperations operations
:vartype triage_resources: azure.mgmt.advisor.operations.TriageResourcesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Azure subscription ID. Required.
:type subscription_id: str
: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 api_version: Api Version. Default value is "2020-01-01". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "2024-11-18-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
) -> None:
_cloud = kwargs.pop("cloud_setting", None) 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 = AdvisorManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
ARMAutoResourceProviderRegistrationPolicy(),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
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)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
Expand All @@ -76,8 +122,23 @@ def __init__(
self.recommendations = RecommendationsOperations(self._client, self._config, self._serialize, self._deserialize)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.suppressions = SuppressionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.advisor_scores = AdvisorScoresOperations(self._client, self._config, self._serialize, self._deserialize)
self.assessments = AssessmentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.assessment_types = AssessmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.workloads = WorkloadsOperations(self._client, self._config, self._serialize, self._deserialize)
self.resiliency_reviews = ResiliencyReviewsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.triage_recommendations = TriageRecommendationsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.triage_resources = TriageResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)

def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -97,17 +158,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self):
# type: () -> None
def close(self) -> None:
self._client.close()

def __enter__(self):
# type: () -> AdvisorManagementClient
def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)
Loading