Skip to content

Commit

Permalink
CodeGen from PR 25305 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge adf2e882801a1b8a023e1655d1ea2fcc545a1e83 into 624dbc769880e5676ae8bb20d3c82ebd1783c64a
  • Loading branch information
SDKAuto committed Aug 18, 2023
1 parent 1c8ab17 commit 48c5457
Show file tree
Hide file tree
Showing 238 changed files with 11,576 additions and 566 deletions.
10 changes: 5 additions & 5 deletions sdk/costmanagement/azure-mgmt-costmanagement/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "493aa7224fd65fe1e5b4cff59bcae5c6cdf4525e",
"commit": "ed75b013ee35526ab272e5598fa29669cec53331",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"autorest": "3.9.7",
"use": [
"@autorest/python@6.6.0",
"@autorest/modelerfour@4.24.3"
"@autorest/python@6.7.1",
"@autorest/modelerfour@4.26.2"
],
"autorest_command": "autorest specification/cost-management/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-2022-10 --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/cost-management/resource-manager/readme.md --generate-sample=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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
"readme": "specification/cost-management/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class CostManagementClientConfiguration(Configuration): # pylint: disable=too-m
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
super(CostManagementClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2022-10-01")
api_version: str = kwargs.pop("api_version", "2023-08-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
AlertsOperations,
BenefitRecommendationsOperations,
BenefitUtilizationSummariesOperations,
BudgetsOperations,
CostAllocationRulesOperations,
DimensionsOperations,
ExportsOperations,
ForecastOperations,
GenerateBenefitUtilizationSummariesReportOperations,
GenerateCostDetailsReportOperations,
GenerateDetailedCostReportOperationResultsOperations,
GenerateDetailedCostReportOperationStatusOperations,
Expand All @@ -31,6 +34,7 @@
PriceSheetOperations,
QueryOperations,
ScheduledActionsOperations,
SettingsOperations,
ViewsOperations,
)

Expand All @@ -45,20 +49,18 @@ class CostManagementClient: # pylint: disable=client-accepts-api-version-keywor
:ivar operations: Operations operations
:vartype operations: azure.mgmt.costmanagement.operations.Operations
:ivar views: ViewsOperations operations
:vartype views: azure.mgmt.costmanagement.operations.ViewsOperations
:ivar alerts: AlertsOperations operations
:vartype alerts: azure.mgmt.costmanagement.operations.AlertsOperations
:ivar forecast: ForecastOperations operations
:vartype forecast: azure.mgmt.costmanagement.operations.ForecastOperations
:ivar dimensions: DimensionsOperations operations
:vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations
:ivar query: QueryOperations operations
:vartype query: azure.mgmt.costmanagement.operations.QueryOperations
:ivar generate_reservation_details_report: GenerateReservationDetailsReportOperations
operations
:vartype generate_reservation_details_report:
azure.mgmt.costmanagement.operations.GenerateReservationDetailsReportOperations
:ivar benefit_recommendations: BenefitRecommendationsOperations operations
:vartype benefit_recommendations:
azure.mgmt.costmanagement.operations.BenefitRecommendationsOperations
:ivar benefit_utilization_summaries: BenefitUtilizationSummariesOperations operations
:vartype benefit_utilization_summaries:
azure.mgmt.costmanagement.operations.BenefitUtilizationSummariesOperations
:ivar generate_benefit_utilization_summaries_report:
GenerateBenefitUtilizationSummariesReportOperations operations
:vartype generate_benefit_utilization_summaries_report:
azure.mgmt.costmanagement.operations.GenerateBenefitUtilizationSummariesReportOperations
:ivar budgets: BudgetsOperations operations
:vartype budgets: azure.mgmt.costmanagement.operations.BudgetsOperations
:ivar exports: ExportsOperations operations
:vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations
:ivar generate_cost_details_report: GenerateCostDetailsReportOperations operations
Expand All @@ -75,21 +77,34 @@ class CostManagementClient: # pylint: disable=client-accepts-api-version-keywor
GenerateDetailedCostReportOperationStatusOperations operations
:vartype generate_detailed_cost_report_operation_status:
azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperationStatusOperations
:ivar views: ViewsOperations operations
:vartype views: azure.mgmt.costmanagement.operations.ViewsOperations
:ivar alerts: AlertsOperations operations
:vartype alerts: azure.mgmt.costmanagement.operations.AlertsOperations
:ivar forecast: ForecastOperations operations
:vartype forecast: azure.mgmt.costmanagement.operations.ForecastOperations
:ivar dimensions: DimensionsOperations operations
:vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations
:ivar query: QueryOperations operations
:vartype query: azure.mgmt.costmanagement.operations.QueryOperations
:ivar generate_reservation_details_report: GenerateReservationDetailsReportOperations
operations
:vartype generate_reservation_details_report:
azure.mgmt.costmanagement.operations.GenerateReservationDetailsReportOperations
:ivar price_sheet: PriceSheetOperations operations
:vartype price_sheet: azure.mgmt.costmanagement.operations.PriceSheetOperations
:ivar scheduled_actions: ScheduledActionsOperations operations
:vartype scheduled_actions: azure.mgmt.costmanagement.operations.ScheduledActionsOperations
:ivar benefit_recommendations: BenefitRecommendationsOperations operations
:vartype benefit_recommendations:
azure.mgmt.costmanagement.operations.BenefitRecommendationsOperations
:ivar benefit_utilization_summaries: BenefitUtilizationSummariesOperations operations
:vartype benefit_utilization_summaries:
azure.mgmt.costmanagement.operations.BenefitUtilizationSummariesOperations
:ivar cost_allocation_rules: CostAllocationRulesOperations operations
:vartype cost_allocation_rules:
azure.mgmt.costmanagement.operations.CostAllocationRulesOperations
:ivar settings: SettingsOperations operations
:vartype settings: azure.mgmt.costmanagement.operations.SettingsOperations
: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".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand All @@ -107,14 +122,16 @@ def __init__(
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.views = ViewsOperations(self._client, self._config, self._serialize, self._deserialize)
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
self.forecast = ForecastOperations(self._client, self._config, self._serialize, self._deserialize)
self.dimensions = DimensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize)
self.generate_reservation_details_report = GenerateReservationDetailsReportOperations(
self.benefit_recommendations = BenefitRecommendationsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.benefit_utilization_summaries = BenefitUtilizationSummariesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.generate_benefit_utilization_summaries_report = GenerateBenefitUtilizationSummariesReportOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.budgets = BudgetsOperations(self._client, self._config, self._serialize, self._deserialize)
self.exports = ExportsOperations(self._client, self._config, self._serialize, self._deserialize)
self.generate_cost_details_report = GenerateCostDetailsReportOperations(
self._client, self._config, self._serialize, self._deserialize
Expand All @@ -128,16 +145,22 @@ def __init__(
self.generate_detailed_cost_report_operation_status = GenerateDetailedCostReportOperationStatusOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize)
self.scheduled_actions = ScheduledActionsOperations(
self.views = ViewsOperations(self._client, self._config, self._serialize, self._deserialize)
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
self.forecast = ForecastOperations(self._client, self._config, self._serialize, self._deserialize)
self.dimensions = DimensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize)
self.generate_reservation_details_report = GenerateReservationDetailsReportOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.benefit_recommendations = BenefitRecommendationsOperations(
self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize)
self.scheduled_actions = ScheduledActionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.benefit_utilization_summaries = BenefitUtilizationSummariesOperations(
self.cost_allocation_rules = CostAllocationRulesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize)

def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
_serialized.update(_new_attr) # type: ignore
_new_attr = _new_attr[k] # type: ignore
_serialized = _serialized[k]
except ValueError:
continue
except ValueError as err:
if isinstance(err, SerializationError):
raise

except (AttributeError, KeyError, TypeError) as err:
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
Expand Down Expand Up @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:keyword bool skip_quote: Whether to skip quote the serialized result.
Defaults to False.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is None
Expand All @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
# Treat the list aside, since we don't want to encode the div separator
if data_type.startswith("["):
internal_data_type = data_type[1:-1]
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
if not kwargs.get("skip_quote", False):
data = [quote(str(d), safe="") for d in data]
return str(self.serialize_iter(data, internal_data_type, **kwargs))
do_quote = not kwargs.get("skip_quote", False)
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))

# Not a list, regular serialization
output = self.serialize_data(data, data_type, **kwargs)
Expand Down Expand Up @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
not be None or empty.
:param str div: If set, this str will be used to combine the elements
in the iterable into a combined string. Default is 'None'.
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
Defaults to False.
:rtype: list, str
"""
if isinstance(data, str):
Expand All @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
for d in data:
try:
serialized.append(self.serialize_data(d, iter_type, **kwargs))
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized.append(None)

if kwargs.get("do_quote", False):
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]

if div:
serialized = ["" if s is None else str(s) for s in serialized]
serialized = div.join(serialized)
Expand Down Expand Up @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
for key, value in attr.items():
try:
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized[self.serialize_unicode(key)] = None

if "xml" in serialization_ctxt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import List, cast

from azure.core.pipeline.transport import HttpRequest


Expand All @@ -16,15 +14,3 @@ def _convert_request(request, files=None):
if files:
request.set_formdata_body(files)
return request


def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
# Need the cast, as for some reasons "split" is typed as list[str | Any]
formatted_components = cast(List[str], template.split("/"))
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
template = "/".join(components)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "4.0.1"
VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class CostManagementClientConfiguration(Configuration): # pylint: disable=too-m
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
super(CostManagementClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2022-10-01")
api_version: str = kwargs.pop("api_version", "2023-08-01")

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

0 comments on commit 48c5457

Please sign in to comment.