Skip to content

Commit 2c76d65

Browse files
author
SDKAuto
committed
CodeGen from PR 16840 in Azure/azure-rest-api-specs
Merge a8e684971c65f1763f535990620558b6d0df9ced into 23d896b
1 parent ce9fbbe commit 2c76d65

23 files changed

+2986
-1474
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"autorest": "3.7.2",
3+
"use": [
4+
"@autorest/[email protected]",
5+
"@autorest/[email protected]"
6+
],
7+
"commit": "2ef831feb01344d022a62fc97bca57e5829e817a",
8+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9+
"autorest_command": "autorest specification/powerbidedicated/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.7.2",
10+
"readme": "specification/powerbidedicated/resource-manager/readme.md"
11+
}
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3-
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
3+
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.7.2, generator: @autorest/[email protected])
64
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
75
# --------------------------------------------------------------------------
86

97
from ._power_bi_dedicated import PowerBIDedicated
10-
from ._version import VERSION
11-
12-
__version__ = VERSION
138
__all__ = ['PowerBIDedicated']
149

15-
try:
16-
from ._patch import patch_sdk # type: ignore
17-
patch_sdk()
18-
except ImportError:
19-
pass
10+
# `._patch.py` is used for handwritten extensions to the generated code
11+
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
12+
from ._patch import patch_sdk
13+
patch_sdk()
Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,43 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3-
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
3+
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.7.2, generator: @autorest/[email protected])
64
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
75
# --------------------------------------------------------------------------
86

97
from typing import TYPE_CHECKING
108

119
from azure.core.configuration import Configuration
1210
from azure.core.pipeline import policies
13-
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14-
15-
from ._version import VERSION
1611

1712
if TYPE_CHECKING:
1813
# pylint: disable=unused-import,ungrouped-imports
1914
from typing import Any
2015

21-
from azure.core.credentials import TokenCredential
22-
16+
VERSION = "unknown"
2317

2418
class PowerBIDedicatedConfiguration(Configuration):
2519
"""Configuration for PowerBIDedicated.
2620
2721
Note that all parameters used to create this instance are saved as instance
2822
attributes.
2923
30-
:param credential: Credential needed for the client to connect to Azure.
31-
:type credential: ~azure.core.credentials.TokenCredential
3224
:param subscription_id: A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
3325
:type subscription_id: str
3426
"""
3527

3628
def __init__(
3729
self,
38-
credential, # type: "TokenCredential"
3930
subscription_id, # type: str
4031
**kwargs # type: Any
4132
):
4233
# type: (...) -> None
43-
if credential is None:
44-
raise ValueError("Parameter 'credential' must not be None.")
34+
super(PowerBIDedicatedConfiguration, self).__init__(**kwargs)
4535
if subscription_id is None:
4636
raise ValueError("Parameter 'subscription_id' must not be None.")
47-
super(PowerBIDedicatedConfiguration, self).__init__(**kwargs)
4837

49-
self.credential = credential
5038
self.subscription_id = subscription_id
5139
self.api_version = "2021-01-01"
52-
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
53-
kwargs.setdefault('sdk_moniker', 'mgmt-powerbidedicated/{}'.format(VERSION))
40+
kwargs.setdefault('sdk_moniker', 'powerbidedicated/{}'.format(VERSION))
5441
self._configure(**kwargs)
5542

5643
def _configure(
@@ -62,10 +49,8 @@ def _configure(
6249
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
6350
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
6451
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
65-
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
52+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
6653
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
6754
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
6855
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
6956
self.authentication_policy = kwargs.get('authentication_policy')
70-
if self.credential and not self.authentication_policy:
71-
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"chosen_version": "2021-01-01",
3+
"total_api_version_list": ["2021-01-01"],
4+
"client": {
5+
"name": "PowerBIDedicated",
6+
"filename": "_power_bi_dedicated",
7+
"description": "PowerBI Dedicated Web API provides a RESTful set of web services that enables users to create, retrieve, update, and delete Power BI dedicated capacities.",
8+
"host_value": "\"https://management.azure.com\"",
9+
"parameterized_host_template": null,
10+
"azure_arm": false,
11+
"has_lro_operations": true,
12+
"client_side_validation": false,
13+
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"PowerBIDedicatedConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}",
14+
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"PowerBIDedicatedConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}"
15+
},
16+
"global_parameters": {
17+
"sync": {
18+
"subscription_id": {
19+
"signature": "subscription_id, # type: str",
20+
"description": "A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.",
21+
"docstring_type": "str",
22+
"required": true
23+
}
24+
},
25+
"async": {
26+
"subscription_id": {
27+
"signature": "subscription_id: str,",
28+
"description": "A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.",
29+
"docstring_type": "str",
30+
"required": true
31+
}
32+
},
33+
"constant": {
34+
},
35+
"call": "subscription_id",
36+
"service_client_specific": {
37+
"sync": {
38+
"api_version": {
39+
"signature": "api_version=None, # type: Optional[str]",
40+
"description": "API version to use if no profile is provided, or if missing in profile.",
41+
"docstring_type": "str",
42+
"required": false
43+
},
44+
"base_url": {
45+
"signature": "base_url=\"https://management.azure.com\", # type: str",
46+
"description": "Service URL",
47+
"docstring_type": "str",
48+
"required": false
49+
},
50+
"profile": {
51+
"signature": "profile=KnownProfiles.default, # type: KnownProfiles",
52+
"description": "A profile definition, from KnownProfiles to dict.",
53+
"docstring_type": "azure.profiles.KnownProfiles",
54+
"required": false
55+
}
56+
},
57+
"async": {
58+
"api_version": {
59+
"signature": "api_version: Optional[str] = None,",
60+
"description": "API version to use if no profile is provided, or if missing in profile.",
61+
"docstring_type": "str",
62+
"required": false
63+
},
64+
"base_url": {
65+
"signature": "base_url: str = \"https://management.azure.com\",",
66+
"description": "Service URL",
67+
"docstring_type": "str",
68+
"required": false
69+
},
70+
"profile": {
71+
"signature": "profile: KnownProfiles = KnownProfiles.default,",
72+
"description": "A profile definition, from KnownProfiles to dict.",
73+
"docstring_type": "azure.profiles.KnownProfiles",
74+
"required": false
75+
}
76+
}
77+
}
78+
},
79+
"config": {
80+
"credential": false,
81+
"credential_scopes": null,
82+
"credential_call_sync": null,
83+
"credential_call_async": null,
84+
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}",
85+
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}"
86+
},
87+
"operation_groups": {
88+
"capacities": "CapacitiesOperations",
89+
"operations": "Operations",
90+
"auto_scale_vcores": "AutoScaleVCoresOperations"
91+
}
92+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
#
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
#
6+
# The MIT License (MIT)
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the ""Software""), to
10+
# deal in the Software without restriction, including without limitation the
11+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12+
# sell copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24+
# IN THE SOFTWARE.
25+
#
26+
# --------------------------------------------------------------------------
27+
28+
# This file is used for handwritten extensions to the generated code. Example:
29+
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
30+
def patch_sdk():
31+
pass

sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_power_bi_dedicated.py

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,88 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3-
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# Code generated by Microsoft (R) AutoRest Code Generator.
3+
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.7.2, generator: @autorest/[email protected])
64
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
75
# --------------------------------------------------------------------------
86

7+
from copy import deepcopy
98
from typing import TYPE_CHECKING
109

11-
from azure.mgmt.core import ARMPipelineClient
10+
from azure.core import PipelineClient
1211
from msrest import Deserializer, Serializer
1312

13+
from . import models
14+
from ._configuration import PowerBIDedicatedConfiguration
15+
from .operations import AutoScaleVCoresOperations, CapacitiesOperations, Operations
16+
1417
if TYPE_CHECKING:
1518
# pylint: disable=unused-import,ungrouped-imports
1619
from typing import Any, Optional
1720

18-
from azure.core.credentials import TokenCredential
19-
20-
from ._configuration import PowerBIDedicatedConfiguration
21-
from .operations import CapacitiesOperations
22-
from .operations import Operations
23-
from .operations import AutoScaleVCoresOperations
24-
from . import models
25-
21+
from azure.core.rest import HttpRequest, HttpResponse
2622

2723
class PowerBIDedicated(object):
2824
"""PowerBI Dedicated Web API provides a RESTful set of web services that enables users to create, retrieve, update, and delete Power BI dedicated capacities.
2925
3026
:ivar capacities: CapacitiesOperations operations
31-
:vartype capacities: azure.mgmt.powerbidedicated.operations.CapacitiesOperations
27+
:vartype capacities: power_bi_dedicated.operations.CapacitiesOperations
3228
:ivar operations: Operations operations
33-
:vartype operations: azure.mgmt.powerbidedicated.operations.Operations
29+
:vartype operations: power_bi_dedicated.operations.Operations
3430
:ivar auto_scale_vcores: AutoScaleVCoresOperations operations
35-
:vartype auto_scale_vcores: azure.mgmt.powerbidedicated.operations.AutoScaleVCoresOperations
36-
:param credential: Credential needed for the client to connect to Azure.
37-
:type credential: ~azure.core.credentials.TokenCredential
38-
:param subscription_id: A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
31+
:vartype auto_scale_vcores: power_bi_dedicated.operations.AutoScaleVCoresOperations
32+
:param subscription_id: A unique identifier for a Microsoft Azure subscription. The
33+
subscription ID forms part of the URI for every service call.
3934
:type subscription_id: str
40-
:param str base_url: Service URL
41-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
35+
:param base_url: Service URL. Default value is 'https://management.azure.com'.
36+
:type base_url: str
37+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
38+
Retry-After header is present.
4239
"""
4340

4441
def __init__(
4542
self,
46-
credential, # type: "TokenCredential"
4743
subscription_id, # type: str
48-
base_url=None, # type: Optional[str]
44+
base_url="https://management.azure.com", # type: str
4945
**kwargs # type: Any
5046
):
5147
# type: (...) -> None
52-
if not base_url:
53-
base_url = 'https://management.azure.com'
54-
self._config = PowerBIDedicatedConfiguration(credential, subscription_id, **kwargs)
55-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
48+
self._config = PowerBIDedicatedConfiguration(subscription_id=subscription_id, **kwargs)
49+
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
5650

5751
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
5852
self._serialize = Serializer(client_models)
59-
self._serialize.client_side_validation = False
6053
self._deserialize = Deserializer(client_models)
54+
self._serialize.client_side_validation = False
55+
self.capacities = CapacitiesOperations(self._client, self._config, self._serialize, self._deserialize)
56+
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
57+
self.auto_scale_vcores = AutoScaleVCoresOperations(self._client, self._config, self._serialize, self._deserialize)
58+
59+
60+
def _send_request(
61+
self,
62+
request, # type: HttpRequest
63+
**kwargs # type: Any
64+
):
65+
# type: (...) -> HttpResponse
66+
"""Runs the network request through the client's chained policies.
67+
68+
>>> from azure.core.rest import HttpRequest
69+
>>> request = HttpRequest("GET", "https://www.example.org/")
70+
<HttpRequest [GET], url: 'https://www.example.org/'>
71+
>>> response = client._send_request(request)
72+
<HttpResponse: 200 OK>
73+
74+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
75+
76+
:param request: The network request you want to make. Required.
77+
:type request: ~azure.core.rest.HttpRequest
78+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
79+
:return: The response of your network call. Does not do error handling on your response.
80+
:rtype: ~azure.core.rest.HttpResponse
81+
"""
6182

62-
self.capacities = CapacitiesOperations(
63-
self._client, self._config, self._serialize, self._deserialize)
64-
self.operations = Operations(
65-
self._client, self._config, self._serialize, self._deserialize)
66-
self.auto_scale_vcores = AutoScaleVCoresOperations(
67-
self._client, self._config, self._serialize, self._deserialize)
83+
request_copy = deepcopy(request)
84+
request_copy.url = self._client.format_url(request_copy.url)
85+
return self._client.send_request(request_copy, **kwargs)
6886

6987
def close(self):
7088
# type: () -> None
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# --------------------------------------------------------------------------
2+
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.7.2, generator: @autorest/[email protected])
3+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
4+
# --------------------------------------------------------------------------
5+
6+
from azure.core.pipeline.transport import HttpRequest
7+
8+
def _convert_request(request, files=None):
9+
data = request.content if not files else None
10+
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
11+
if files:
12+
request.set_formdata_body(files)
13+
return request
14+
15+
def _format_url_section(template, **kwargs):
16+
components = template.split("/")
17+
while components:
18+
try:
19+
return template.format(**kwargs)
20+
except KeyError as key:
21+
formatted_components = template.split("/")
22+
components = [
23+
c for c in formatted_components if "{}".format(key.args[0]) not in c
24+
]
25+
template = "/".join(components)

0 commit comments

Comments
 (0)